Hi,
i have hidden variable which is update when the row is selected in GridView, and i need this value in java script, we are trying to modify in igf_grid.js
this.selectRow=function(domNode,select){
......}}this.customFLT()};
in the customFLT() method just i am tring to print value using alert(of javascript) method, which works fine and i am able to see the value i have seleted from GridView, and i have to use this variable to some other method, when i removed the alert method than i am not able to get the selected value. if i add alert method than its works fine. and i have set " immediate="true" " of hiddenvariable in JSF.
please let me know what is causing this problem.
thanks in advance.
dayananda b v
HI,
i guess the hidden variable is not updated, and if put alert message i hope it will take some time to display and click ok, so in the mean time the hidden variable getting update. if this is case what could be answer.
Hi, dayanandabv!
I'm affraid that the information send is not enough for me to reproduce the scenario. I'll try to think of some solution if you provide me with more detailed information, e.g. parts of your source code and also an explanation of what the idea of this hidden variable is.
Regards!
--Bozhidar
this is the code that I added to the igf_grid.js file.
// customer code
var row=this.getTargetRow(domNode);
else{row.unselect();}
alert("Hello");
// alert("Hidden Field = " + parent.frames.document.getElementById("form1:hiddenField1").value);
// here i am calling applet method pasing the value of arraystr,
};
// customer code END
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(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, dayananda B V!
as I told you everything seems to be OK, I'm getting the message with the value of the hidden field. Checking the name of the form that the hidden field is nested in is the advice I can give you now.
Regards.
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://es.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); };
ig.onPartialRefreshDefault(httpReq);
I hope this will help you. Yet I think this topic has gone a little bit farther than the purpose of this forum supposes since this is functionality not provided with our product and involves modifying files that should not be modified. For those aims customers are supposed to submit feature requests.
I will now apply all my source code:
JAVA BackingBean:
GridView grid;
List clientsList = DAO.getClientsList(); // adding some objects
HtmlInputHidden hiddenField1;
}
public void onChangeSelection(SelectedRowsChangeEvent e) {
String selectedid = "";
if (getGrid() != null) {
Iterator selectedRows = getGrid().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(
getHiddenField1().setImmediate(true);
System.out.println("getHiddenField1---> "
+ getHiddenField1().getValue());
public GridView getGrid() {
return grid;
public void setGrid(GridView grid) {
this.grid = grid;
public List getClientsList() {
return clientsList;
public void setClientsList(List clientsList) {
this.clientsList = clientsList;
public HtmlInputHidden getHiddenField1() {
return hiddenField1;
public void setHiddenField1(HtmlInputHidden hiddenField1) {
this.hiddenField1 = hiddenField1;
JSP page:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib prefix="ig"
uri="http://es.infragistics.com/faces/netadvantage"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<f:view>
<h:form id="form1">
<ig:gridView id="grid"
dataSource="#{webGridSelectionBean.clientsList}" pageSize="10"
pageChangeListener="#{webGridSelectionBean.onPageChange}"
dataKeyName="id"
selectedRowsChangeListener="#{webGridSelectionBean.onChangeSelection}"
binding="#{webGridSelectionBean.grid}">
<f:facet name="header">
<h:outputText value="Clients List"></h:outputText>
</f:facet>
<ig:columnSelectRow showSelectAll="true"></ig:columnSelectRow>
<ig:column>
<h:outputText value="Client Id"></h:outputText>
<h:outputText value="#{DATA_ROW.id}"></h:outputText>
</ig:column>
<h:outputText value="Company"></h:outputText>
<h:outputText value="#{DATA_ROW.companyName}"></h:outputText>
<h:outputText value="Reg. number"></h:outputText>
<h:outputText value="#{DATA_ROW.regNumber}"></h:outputText>
<h:outputText value="Selected"></h:outputText>
<h:outputText value="#{DATA_ROW.selected}"></h:outputText>
</ig:gridView>
< <h:inputHidden binding="#{webGridSelectionBean.hiddenField1}"
id="hiddenField1" immediate="true"></h:inputHidden>
<table>
<tr>
<td><h:outputText id="messOnPage"
value="#{webGridSelectionBean.msgRowsOnPage}"
binding="#{webGridSelectionBean.textRowsNoPage}"></h:outputText></td>
</tr>
<td><h:outputText id="messSelected"
value="#{webGridSelectionBean.msgRowsSelected}"
binding="#{webGridSelectionBean.textRowsSelected}"></h:outputText></td>
</table>
</h:form>
</f:view>
</body>
</html>
Changes in igf_grid.js:
Replace the following code
var row = this.getTargetRow(domNode);
row.select();
row.unselect();
if (!ig.isNull(grid) && grid.isImmediateRowsChangeEvent()) {
this.selectRow = function(domNode, select) {
if (!ig.isNull(row)) {
Please, for further help consult our support policies. Thanks in advance!
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?