HtmlDataTable in jsf

Discussions

Web tier: servlets, JSP, Web frameworks: HtmlDataTable in jsf

  1. HtmlDataTable in jsf (4 messages)

    <h:dataTable styleClass="dataTable" id="list" value="#{PostCodeBean.postCodeList}" var="plist" rows="10" >
    <f:facet name="footer">
    <hx:panelBox styleClass="panelBox" id="box1">
    <hx:pagerWeb styleClass="pagerWeb" id="web1" />
    </hx:panelBox>
    </f:facet>

    <h:column>
    <h:selectBooleanCheckbox styleClass="selectOneRadio" id="pcheck" value="#{plist.postCodeValue}"></h:selectBooleanCheckbox>
    </h:column>

    <h:column>
    <f:facet name="header">
    <h:outputText styleClass="outputText" value="Post Code" ></h:outputText>
    </f:facet>
    <h:outputText id="postCodeValue" value="#{plist.postCodeValue}" />
    </h:column>
    <h:column></h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText styleClass="outputText" value="City Name"></h:outputText>
    </f:facet>
    <h:outputText id="postCodeArea" value="#{plist.postCodeArea}" />
    </h:column>

    </h:dataTable>

    i am using this code in jsp to display the values.
    when i select one row and click on button, i want to display that values in next jsp.
    kindly give the idea how to get the selected value in java class.

    Threaded Messages (4)

  2. HtmlDataTable in jsf[ Go to top ]

    You need a binding to the dataTable

    <h:dataTable styleClass="dataTable" id="list" value="#{PostCodeBean.postCodeList}" var="plist" rows="10"
    binding="#{PostCodeBean.postCodeTable}">

    Java Code:
    private UIData postCodeTable;
    <- setter and getter for this variable ->

    then you can access the selected row with:
    Object selectedObject = (Object) postCodeTable.getRowData();
  3. probelem with datatable[ Go to top ]

    i used the following code to display the list of values using datatable. after that i want to select one row and click on ok then i want get that perticular row data in java class.
    but i got javax.faces.el.EvaluationException: java.lang.IllegalArgumentException when i am trying to call getRowData methos from UIData object.

    <h:dataTable styleClass="dataTable" id="list" value="#{PostCodeBean.postCodeList}" var="plist" rows="10"
    binding="#{PostCodeBean.postCodeTable}">

    and having the getter and setter methods of UIData type varialbe in PostCodeListBean

    i wrote the follwing code in selectPostCode() method of PostCodeListBean class and when i click on ok buttom in jsp i am calling this methd.but i got java.lang.IllegalArgumentException

    Object selectedObject = (Object) postCodeTable.getRowData();



    Thanks
    Siva
  4. probelem with datatable[ Go to top ]

    Have you defined the postCodeTable as HtmlDataTable? getRowData is a method on that...
    Here's a sample that I happen to have which does this:

      private HtmlDataTable _dataTable;

      public void setDataTable(HtmlDataTable dataTable)
      {
        this._dataTable = dataTable;
      }

      public HtmlDataTable getDataTable()
      {
        return _dataTable;
      }


      public String editLinkAction()
      {
        /* pull out the currently selected contact */
        Contact editContact = (Contact)this.getDataTable().getRowData();
        FacesContext ctx = FacesContext.getCurrentInstance();
        ValueBinding binding = ctx.getApplication().createValueBinding("#{editContact}");
        binding.setValue(ctx,editContact);
        return "drilldown";
      }
    (You can see the related stuff here if you are interested)
  5. Problem with datatable[ Go to top ]

    Hi, I folloewed your suggestions to select a row from h:datatable and manipulate the selected records at the back end bean. Unfortunately, the getRowData() or getRowInder(), is throwing an " javax.faces.el.EvaluationException: java.lang.IllegalArgumentException" error. I used the same code as given beow. I also tried to get only the getrowIndexx() and it is returning -1 Please let me know Thanks Aish