Replies
HI Bozhidar,
as i am not doing any mistake, let me compare with your demo code.
can you please send your demo code to my mail id or you can just add it here, or shall i send all the nessarry files to you?
thanks
dayananda b v
Hi Bozhidar,
is it working for you? for me it is not working, so that's what i asked is there anything i need to change?
daya
HI Bozhidar Dedov.
thanks for your replay, i appreciate
your continues help.
has you told i have changed the following code according to your suggestion, but it is not working.
is there anything else i need to change? in backing bean? or in design i.e. in JSP design ?
this.selectRow=function(domNode,select){var row=this.getTargetRow(domNode);if(!ig.isNull(row)){if(select){row.select();}
else{row.unselect();}
var grid=this.getGrid(domNode);if(!ig.isNull(grid)&&grid.isImmediateRowsChangeEvent()){ig.smartSubmit(grid.elm.id,null,null,null,this.customFLT);}}};
this.customFLT=function(httpReq){
ig.onPartialRefreshDefault(httpReq);
alert("hello");
var value = document.getElementById("form1:hiddenField1").value;
alert(value);
};
Hi Bozhidar,
actually i have tried printing (alert) the value of hidden variable along with your suggestion, but i am not able to get the value i.e. selected row first column value of GridView, here adding code to this replay, can you please verify what could be reason or what i am doing wrong. i have tried this for almost two three days. can you please help me.
i have filled up GridView some dummy data.
************************************************ JSP Code (User interface, which includes a GridView and hidden variable) ***********************
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ig="http://www.infragistics.com/faces/netadvantage"
xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:ui="http://www.sun.com/web/ui">
<jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
<f:view>
<ui:page binding="#{Page1.page1}" id="page1">
<ui:html binding="#{Page1.html1}" id="html1">
<ui:head binding="#{Page1.head1}" id="head1">
<ui:link binding="#{Page1.link1}" id="link1" url="/resources/stylesheet.css"/>
</ui:head>
<ui:body binding="#{Page1.body1}" id="body1" style="-rave-layout: grid">
<ui:form binding="#{Page1.form1}" id="form1">
<ig:gridView binding="#{Page1.floorsGrid}" dataSource="#{Page1.employees}" id="floorsGrid" pageSize="10" selectedRowsChangeListener="#{Page1.onSelectRowFloor}">
<ig:columnSelectRow showSelectAll="true"/>
<ig:column>
<f:facet name="header">
<h:outputText value="Portfolios"/>
</f:facet>
<h:outputText value="#{DATA_ROW.id}"/>
</ig:column>
<ig:column>
<f:facet name="header">
<h:outputText value="Assigned Profiles"/>
</f:facet>
<h:outputText value="#{DATA_ROW.name}"/>
</ig:column>
</ig:gridView>
<ui:hiddenField binding="#{Page1.hiddenField1}" id="hiddenField1" immediate="true"/>
</ui:form>
</ui:body>
</ui:html>
</ui:page>
</f:view>
</jsp:root>
************************************************************************ and here is the java code ***********************
import com.infragistics.faces.grid.component.RowItem;
import com.infragistics.faces.grid.component.html.HtmlGridView;
import com.infragistics.faces.grid.event.SelectedRowsChangeEvent;
import com.infragistics.faces.shared.smartrefresh.SmartRefreshManager;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.rave.web.ui.component.Body;
import com.sun.rave.web.ui.component.Form;
import com.sun.rave.web.ui.component.Head;
import com.sun.rave.web.ui.component.HiddenField;
import com.sun.rave.web.ui.component.Html;
import com.sun.rave.web.ui.component.Link;
import com.sun.rave.web.ui.component.Page;
import java.util.ArrayList;
import java.util.Iterator;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
import javax.faces.component.html.HtmlInputHidden;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
public class Page1 extends AbstractPageBean {
private int __placeholder;
ArrayList<Employee> emp = new ArrayList<Employee>();
private void _init() throws Exception {
}
private Page page1 = new Page();
public Page getPage1() {
return page1;
}
public void setPage1(Page p) {
this.page1 = p;
}
private Html html1 = new Html();
public Html getHtml1() {
return html1;
}
public void setHtml1(Html h) {
this.html1 = h;
}
private Head head1 = new Head();
public Head getHead1() {
return head1;
}
public void setHead1(Head h) {
this.head1 = h;
}
private Link link1 = new Link();
public Link getLink1() {
return link1;
}
public void setLink1(Link l) {
this.link1 = l;
}
private Body body1 = new Body();
public Body getBody1() {
return body1;
}
public void setBody1(Body b) {
this.body1 = b;
}
private Form form1 = new Form();
public Form getForm1() {
return form1;
}
public void setForm1(Form f) {
this.form1 = f;
}
private HtmlGridView floorsGrid = new HtmlGridView();
public HtmlGridView getFloorsGrid() {
return floorsGrid;
}
public void setFloorsGrid(HtmlGridView hgv) {
this.floorsGrid = hgv;
}
public Page1() {
for(int i=0;i<10;i++){
emp.add(new Employee("daya", i));
}
}
public void init() {
super.init();
try {
_init();
} catch (Exception e) {
log("Page1 Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}
}
public void preprocess() {
}
public void prerender() {
}
public void destroy() {
}
protected SessionBean1 getSessionBean1() {
return (SessionBean1)getBean("SessionBean1");
}
protected RequestBean1 getRequestBean1() {
return (RequestBean1)getBean("RequestBean1");
}
public ArrayList<Employee> getEmployees(){
for(Employee emp1 : emp){
System.out.println("emp1emp1 &&&&&&&&&&&&&&>>> "+emp1.getName());
}
return emp;
}
protected ApplicationBean1 getApplicationBean1() {
return (ApplicationBean1)getBean("ApplicationBean1");
}
public void onSelectRowFloor(SelectedRowsChangeEvent evt) {
String selectedid = "";
if (getFloorsGrid()!=null) {
Iterator selectedRows = getFloorsGrid().getSelectedRows().iterator();
while (selectedRows.hasNext()) {
RowItem rowItem = (RowItem) selectedRows.next();
{
int i = 0;
Iterator iter = (Iterator)rowItem.getCells().iterator();
while(iter.hasNext()) {
UIComponent cell=(UIComponent )iter.next();
Object object=cell.getChildren().get(0);
if(object instanceof UIOutput) {
if(i==0){
String selectedUnit = ((UIOutput)object).getValue().toString();
selectedid = selectedid + selectedUnit;
}
i++;
}
}
}
}
}
getHiddenField1().setValue(selectedid);
SmartRefreshManager srm = SmartRefreshManager.getCurrentInstance();
srm.removeSmartRefreshIds(getHiddenField1().getClientId(FacesContext.getCurrentInstance()));
srm.addSmartRefreshId(getHiddenField1().getClientId(FacesContext.getCurrentInstance()));
getHiddenField1().setImmediate(true);
System.out.println("getHiddenField1—> "+ getHiddenField1().getValue());
}
public class Employee{
private String name="Daya";
private int id;
public Employee(String name, int id){
setId(id);
}
public String getName() {
return "Daya";
}
public void setName(String name) {
this.name ="Daya";
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
private HiddenField hiddenField1 = new HiddenField();
public HiddenField getHiddenField1() {
return hiddenField1;
}
public void setHiddenField1(HiddenField hf) {
this.hiddenField1 = hf;
}
}
*************************************************************************************** and here is the java script code(part of igf_grid.js) ***********
if(ig){if(!ig.grid){function IgWebGridPackage(){this.TYPE_GRID="Grid";this.TYPE_GRID_CELL="GridCell";this.TYPE_GRID_ROW="GridRow";this.TYPE_GRID_ROW_SCROLL="GridRowScroll";this.TYPE_GRID_SECTION="GridSection";this.TYPE_GRID_ROW_SELECTOR="GridRowSelector";this.TYPE_GRID_COLUMN_HEADER="GridColumnHeader";this.PROP_JUNCTION_EXPANDED_ICON="ojei";this.PROP_JUNCTION_COLLAPSED_ICON="ojci";this.PROP_IS_SCROLLING="igscrlg";this.PROP_IS_LOAD_ON_DEMAND="igLoadOnDemand";this.PARTITIONED_ROW_COUNT="igRowCount";this.PROP_SINGLE_ROW_HEIGHT="singleRowHeight";this.PROP_PREVIOUS_SCROLL_TOP="previousScrollTop";this.PROP_CURRENT_VIRTUAL_PAGE="currentVirtualPage";this.PROP_LOD_MARKER_HEIGHT="lodMarkerHeight";this.PROP_IG_ROW_FETCH_SIZE="igRowFetchSize";this.PROP_IG_SCROLL_TOP_STATE="igScrollTopState";this.LOAD_ON_DEMAND_DEFAULT="default";this.LOAD_ON_DEMAND_PARTITIONED="partitioned";this.PROP_IG_LOADING_IMAGE="igLoadingImage";this.PROP_IG_CURRENT_ROW_COUNT="igCurrentRowCount";this.PROP_IG_NEEDS_SCROLLING="igNeedsScrolling";this.PROP_IG_VIRTUAL_PAGE_COUNT="igVirtualPageCount";this.PROP_IG_LOAD_ON_DEMAND_TIMER_DEFAULT=200;this.PROP_IG_LOAD_ON_DEMAND_TIMER_PARTITIONED=400;this.PROP_IG_LOAD_ON_DEMAND_THRESHOLD=0.25;this.PROP_IG_LOAD_ON_DEMAND_TOOLTIP_OFFSET=50;this.PROP_REMAINDER_COUNT="igRemainderCount";this.init=function(){ig.factory.addClass(ig.grid.TYPE_GRID,IgGrid);ig.factory.addClass(ig.grid.TYPE_GRID_CELL,IgGridCell);ig.factory.addClass(ig.grid.TYPE_GRID_ROW,IgGridRow);ig.factory.addClass(ig.grid.TYPE_GRID_ROW_SCROLL,IgGridScrollingRow);ig.factory.addClass(ig.grid.TYPE_GRID_SECTION,IgGridSection);ig.factory.addClass(ig.grid.TYPE_GRID_COLUMN_HEADER,IgGridColumnHeader);};this.initGrid=function(gridId){var e=ig.grid.getGrid(gridId);if(!ig.isNull(e)){e.init();var form=e.getForm(e.id);if(ig.grid.formsWithGrid[form.id]==null){ig.addEventListener(form,"submit",ig.grid.onBeforeSubmit,false);ig.grid.formsWithGrid[form.id]=form;}}};this.onExpandedOnDemand=function(httpReq){ig.onPartialRefreshDefault(httpReq);var node=ig.getUIElementById(httpReq.getSourceOfRequest());if(!ig.isNull(node)){node.focus();}};this.onExpandRow=function(row){if(!ig.isNull(row)){if(row.hasChild()){icon=(row.isExpanded())?row.getAttribute(ig.grid.PROP_JUNCTION_EXPANDED_ICON,true):row.getAttribute(ig.grid.PROP_JUNCTION_COLLAPSED_ICON,true);if(ig.isNull(row)||row.elm.childNodes.length==0){var scrollingRow=ig.getUIElementById(row.elm.id+"_sr");scrollingRow.updateJunctionIcon(icon);}else{row.updateJunctionIcon(icon);}}
row.repaint();}};this.selectAllRows=function(domNode,select){var grid=this.getGrid(domNode);if(!ig.isNull(grid)){grid.selectAllRows(select);if(grid.isImmediateRowsChangeEvent()){ig.smartSubmit(grid.elm.id,null,null);}}};
this.selectRow=function(domNode,select){var row=this.getTargetRow(domNode);if(!ig.isNull(row)){if(select){row.select();}
else{row.unselect();}
var grid=this.getGrid(domNode);if(!ig.isNull(grid)&&grid.isImmediateRowsChangeEvent()){ig.smartSubmit(grid.elm.id,null,null,null,this.customFLT);}}};
this.customFLT=function(){
alert("hello");
var value = document.getElementById("form1:hiddenField1").value;
alert(value);
};
Hi Bozhidar,
i am really sorry, the "Hello" alert message is coming, actually
alert message is inside the if condition, and i am checking hidden variable
value for null condition (meaning it as some value or not), but i am getting
the hidden variable value as blank(null value), because if the reason it is not going
inside the if condition. and i have checked in tomcat console, the value for hidden variable i am setting which is showing correctly.
alert("Hello");
alert(parent.frames.application_left.document.getElementById("form1:hiddenField1").value);
// here I am not(blank) getting the value.
What could be reason for this.
thanks
dayananda B V
Hi Bozhidar,
Thanks for quick replays
sorry i am not getting any "Hello" alert message, i have tried in different
combination. Is it the correct place what i placed the code i.e. “ig.smartSubmit(grid.elm.id,null,null,
null, this.customFLT);}}};” please let me know from end of I have three
bracket,(”}}}”) is that correct,
and I have tried like this also,
“ig.smartSubmit(grid.elm.id,null,null); ig.smartSubmit(grid.elm.id,null,null,
null, this.customFLT);}}};”
It’ s giving wired behavior, and I have tried like this also
“ig.smartSubmit(grid.elm.id,null,null); }} ig.smartSubmit(grid.elm.id,null,null,
null, this.customFLT);};”
It is also giving wired behavior
Thanks
Daynanda B V
sorry, i tried like that only, but the alert is not coming up,
this.selectRow=function(domNode,select){
var row=this.getTargetRow(domNode);
if(!ig.isNull(row)){if(select){row.select();}
else{row.unselect();}
var
grid=this.getGrid(domNode);if(!ig.isNull(grid)&&grid.isImmediateRowsChangeEvent()){
ig.smartSubmit(grid.elm.id,null,null,
null, this.customFLT);}}};
this.customFLT=function(){
alert("Hello”);
// alert("Hidden Field = " +
parent.frames.document.getElementById("form1:hiddenField1").value);
var arraystr= parent.frames.document.getElementById("form1:hiddenField1").value;
// here i am calling applet method pasing the
value of arraystr,
};