Infragistics Home

Infragistics Forums

Infragistics community online discussions.
Welcome to Infragistics Forums Sign in | FAQ
in Search

Getting variable value which is set in JSF using javascript in igf_grid.js

Last post 08-06-2008 7:02 by [Infragistics] Bozhidar Dedov. 23 replies.
Page 2 of 2 (24 items) < Previous 1 2
Sort Posts: Previous Next
  • 08-06-2008 5:00 In reply to

    Re: Getting variable value which is set in JSF using javascript in igf_grid.js

     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);
     };

    • Post Points: 20
  • 08-06-2008 5:13 In reply to

    Re: Getting variable value which is set in JSF using javascript in igf_grid.js

    Hi, dayanandabv!

    I just added this line ig.onPartialRefreshDefault(httpReq); into the igf_grid.js file at the place shown. I did not change anything else.

     

    Bozhidar Dedov
    Jr. Developer Support Engineer
    Infragistics JSF Team
    • Post Points: 20
  • 08-06-2008 5:30 In reply to

    Re: Getting variable value which is set in JSF using javascript in igf_grid.js

     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 

    • Post Points: 20
  • 08-06-2008 5:56 In reply to

    Re: Getting variable value which is set in JSF using javascript in igf_grid.js

    Hi, dayanandabv!

    I think I was clear but if not it is probably my fault. Let me explain again what I am doing to reproduce your sample. Since I necessarily don't have all your classes, I made a simple application realizing the functionality you describe, namely to select a value selected from a WebGrid row in a message box. For that aim I have a JSP page with WebGrid and a hidden field. The WebGrid sends a SelectedRowsChangeEvent that is being caught by a listener method where I added your code. In the igf_grid.js file I replace the Infragistics code in the this.selectRow = function(domNode, select) with your customer code and I made the necessary changes (described so far) so that the value of the hiddenField element displayed in the message updates (this was also explained). This configuration works as it is supposed to.

    Bozhidar Dedov
    Jr. Developer Support Engineer
    Infragistics JSF Team
    • Post Points: 20
  • 08-06-2008 6:05 In reply to

    Re: Getting variable value which is set in JSF using javascript in igf_grid.js

    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 

    • Post Points: 65
  • 08-06-2008 6:34 In reply to

    Re: Getting variable value which is set in JSF using javascript in igf_grid.js

    Hi,

    I will now apply all my source code:

    JAVA BackingBean: 

    public class ForumExampleBean {

    GridView grid;

    List clientsList = DAO.getClientsList(); // adding some objects

    HtmlInputHidden hiddenField1;

    public
    ForumExampleBean() {

    }

    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(

    FacesContext.getCurrentInstance()));

    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://www.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">

    <title>
    Forum Example</title>

    </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>

    <f:facet name="header">

    <h:outputText value="Client Id"></h:outputText>

    </f:facet>

    <h:outputText value="#{DATA_ROW.id}"></h:outputText>

    </ig:column>

    <ig:column>

    <f:facet name="header">

    <h:outputText value="Company"></h:outputText>

    </f:facet>

    <h:outputText value="#{DATA_ROW.companyName}"></h:outputText>

    </ig:column>

    <ig:column>

    <f:facet name="header">

    <h:outputText value="Reg. number"></h:outputText>

    </f:facet>

    <h:outputText value="#{DATA_ROW.regNumber}"></h:outputText>

    </ig:column>

    <ig:column>

    <f:facet name="header">

    <h:outputText value="Selected"></h:outputText>

    </f:facet>

    <h:outputText value="#{DATA_ROW.selected}"></h:outputText>

    </ig:column>

    </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>

    <tr>

    <td><h:outputText id="messSelected"

    value="#{webGridSelectionBean.msgRowsSelected}"

    binding="#{webGridSelectionBean.textRowsSelected}"></h:outputText></td>

    </tr>

    </table>

    </h:form>

    </f:view>

    </body>

    </html>

    Changes in igf_grid.js:

    Replace the following code

    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);

    }

    }

    };

    with this one

    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);

    var value = document.getElementById("form1:hiddenField1").value;alert("value: " + value);

     

    };

    Please, for further help consult our support policies. Thanks in advance!

    Bozhidar Dedov
    Jr. Developer Support Engineer
    Infragistics JSF Team
    • Post Points: 5
  • 08-06-2008 6:49 In reply to

    Re: Getting variable value which is set in JSF using javascript in igf_grid.js

     

    Bozhidar Dedov
    Jr. Developer Support Engineer
    Infragistics JSF Team
    • Post Points: 5
  • 08-06-2008 6:49 In reply to

    Re: Getting variable value which is set in JSF using javascript in igf_grid.js

     

    Bozhidar Dedov
    Jr. Developer Support Engineer
    Infragistics JSF Team
    • Post Points: 5
  • 08-06-2008 7:02 In reply to

    Re: Getting variable value which is set in JSF using javascript in igf_grid.js

     

    Bozhidar Dedov
    Jr. Developer Support Engineer
    Infragistics JSF Team
    • Post Points: 5
Page 2 of 2 (24 items) < Previous 1 2
Powered by Community Server (Commercial Edition), by Telligent Systems