11 Replies Latest reply on Jul 18, 2011 7:25 PM by puneet138

    Issue in Using h:selectOnemenu inside richdatatable

    puneet138

      Hi ,

       

      We are building a web application with JSF 2.0 , rich faces 4.0

       

      We have to use h:selectOnemenu inside richdatatable . If the drop down is binded with a backing bean , on submit of form the values are not getting passed to java layer.

       

      Hard coding the value in drop down and calling java method results in correct behaviour.

       

      Any suggestions or pointers on the use of h:selectOnemenu inside richdatatable

       

      Thanks,

      Puneet

        • 1. Re: Issue in Using h:selectOnemenu inside richdatatable
          nbelaevski

          Hi Puneet,

           

          Please post bean/page code.

          • 2. Re: Issue in Using h:selectOnemenu inside richdatatable
            dushyant_purohit

            Hi Nick,

             

            I am posting this on behalf of Puneet.

             

            XHTML Code :

             

            <h:form id="testDetailsForm">

                        <div id="testDetailsDiv" class="detailsDiv"

                            style="margin-top: 15px;">

                    <a4j:region>

                        <h:outputLabel id="testLabel" value="TEST"  styleClass="key"></h:outputLabel>

                    <rich:dataTable id="testDetailsDataTable" binding="#{testDetailsHandler.testDetailsDataTable}"

                    var="testInfo" style="border-top:none;border-bottom:none;">

                    <rich:column id="testType" style="width:20%; vertical-align: top;" >

                        <h:selectOneMenu id="testDetailsTypeSelectMenu" binding="#{testDetailsHandler.testDetailsTypeSelectMenu}" style="width:100%;"

                            value="#{testInfo.TEST_PURPOSE_TYPE_ID}">

                            <f:selectItem binding="#{testDetailsHandler.testDetailsTypeSelectItem}" itemLabel="--Select--" itemValue="" ></f:selectItem>

                        </h:selectOneMenu>

                    </rich:column>

                    <rich:column id="testColumn" style="width:70%;">

                        <h:inputText id="testInputText" value="#{testInfo.TEST}" style="width:98%;"></h:inputText>

                    </rich:column>

               

                </rich:dataTable>

            </a4j:region>

                        </div>

                        </h:form>

             

             

            Bean Code :

             

            import javax.faces.bean.ManagedBean;

            import javax.faces.bean.RequestScoped;

            import javax.faces.component.UISelectItem;

            import javax.faces.component.html.HtmlInputHidden;

            import javax.faces.component.html.HtmlSelectOneMenu;

             

            import org.richfaces.component.UIDataTable;

             

            @ManagedBean

            @RequestScoped

            public class TestDetails {

                private UIDataTable testDetailsDataTable;

                private HtmlSelectOneMenu testDetailsTypeSelectMenu;

                private UISelectItem testDetailsTypeSelectItem;

               

               

                public UIDataTable getTestDetailsDataTable() {

                    return testDetailsDataTable;

                }

                public void setTestDetailsDataTable(UIDataTable testDetailsDataTable) {

                    this.testDetailsDataTable = testDetailsDataTable;

                }

                public HtmlSelectOneMenu getTestDetailsTypeSelectMenu() {

                    return testDetailsTypeSelectMenu;

                }

                public void setTestDetailsTypeSelectMenu(

                        HtmlSelectOneMenu testDetailsTypeSelectMenu) {

                    this.testDetailsTypeSelectMenu = testDetailsTypeSelectMenu;

                }

                public UISelectItem getTestDetailsTypeSelectItem() {

                    return testDetailsTypeSelectItem;

                }

                public void setTestDetailsTypeSelectItem(

                        UISelectItem testDetailsTypeSelectItem) {

                    this.testDetailsTypeSelectItem = testDetailsTypeSelectItem;

                }

               

            }

             

             

            The selectOneMenu is getting populated from the java layer. But the selected value and the value entered into the input text are not going to the java layer.

            • 3. Re: Issue in Using h:selectOnemenu inside richdatatable
              nbelaevski

              How does TestInfo look like? Try adding rich:messages to the page and check if there are any,

              • 4. Re: Issue in Using h:selectOnemenu inside richdatatable
                dushyant_purohit

                The testDetailsDataTable contains an arraylist of linked hashmaps. The var "testinfo" is mapped to a linked hashmap.

                We did not find any messages even after implementing the rich:messages in the page.

                 

                The problem here is , we are able to see the rendered values in the UI for the same dataTable with the same bindings. But  we are failing while trying

                to get the values of this data table inside java layer.

                • 5. Re: Issue in Using h:selectOnemenu inside richdatatable
                  nbelaevski

                  Where is data table value set? What's the scope of that value?

                  • 6. Re: Issue in Using h:selectOnemenu inside richdatatable
                    dushyant_purohit

                    The value is request scoped.

                     

                    The data table value gets set in one handler.

                     

                    Below is the code:

                     

                    if(finalDetailsResult != null && finalDetailsResult.getTestDetails() != null){

                                    finalDetailsResult.getTestDetails().add(testDetailsLinkedHashMap);

                                }

                    else{

                                    testAL.add(testDetailsLinkedHashMap);

                    }

                     

                    Here finalDetailsResult.getTestDetails() is an arrayList which is populated from testDetailsLinkedHashMap. testDetailsLinkedHashMap is mapped

                    to "testinfo". "If" block serves the purpose of showing existing details but for getting new information saved "else" block comes under picture.

                    testAL is a new arrayList.

                     

                    Below is the exact code where the value of data table gets set which is followed after the code mentioned above.

                     

                    if(finalDetailsResult.getTestDetails() != null){

                                if(testDetailsHandler.getTestDetailsDataTable()==null){

                                    testDetailsHandler.setTestDetailsDataTable(StringUtil.getUIDataTable(finalDetailsResult.getTestDetails()));

                                }

                                else

                                {

                                    testDetailsHandler.getTestDetailsDataTable().setValue(StringUtil.getArrayListForUIDataTable(finalDetailsResult.getTestDetails()));

                                }

                            }

                            else{

                                if(testDetailsHandler.getTestDetailsDataTable()==null){

                                    testDetailsHandler.setTestDetailsDataTable(StringUtil.getUIDataTable(testAL));

                                   

                                }

                                else

                                {

                                    testDetailsHandler.getTestDetailsDataTable().setValue(testAL);

                                   

                                }

                            }

                    • 7. Re: Issue in Using h:selectOnemenu inside richdatatable
                      nbelaevski

                      Please take a look if that's the case: https://issues.jboss.org/browse/RF-3314

                      • 8. Re: Issue in Using h:selectOnemenu inside richdatatable
                        puneet138

                        Hi Nick,

                         

                        The solution given at the link suggests using session scope beans. Is this the only solution? We would try to avoid keeping beans in session.

                         

                        Thanks for your help.

                         

                        Regards,

                        Puneet

                        • 9. Re: Issue in Using h:selectOnemenu inside richdatatable
                          dushyant_purohit

                          Hi Nick,

                           

                          We have already tried with keeping the beans session scoped.

                           

                          When we put the beans in session scope then the data table does not get rendered at all.

                           

                          Regards,

                          Dushyant

                          • 10. Re: Issue in Using h:selectOnemenu inside richdatatable
                            nbelaevski

                            Not necessarily session scope, data table requires that data model is provided for subsequent requests only - take a look at the linked issue for details.

                            You can store query parameters and the re-fetch the data again.

                            • 11. Re: Issue in Using h:selectOnemenu inside richdatatable
                              puneet138

                              Hi Nick,

                               

                              We are not able to solve the issue. Would you please provide some example which shows that selectonemenu works in rich data table.

                               

                              Thanks,

                              Puneet