1 2 Previous Next 22 Replies Latest reply on May 13, 2009 6:12 AM by ilya_shaikovsky

    unable to update selectOneMenu in datatable

      I have 3 h:selectOneMenu in a row on h:dataTable. I want to update two of the lists when 1st list changes. It works fine in simple table but i am unable to do it in h:datatable.
      Any help

        • 1. Re: unable to update selectOneMenu in datatable
          ilya_shaikovsky

          please check richfaces-demo a4j:repeat sample. the same thing could be performed with rich:dataTable

          • 2. Re: unable to update selectOneMenu in datatable

             


            please check richfaces-demo a4j:repeat sample

            Sorry I can't find it. Please refer the link

            • 3. Re: unable to update selectOneMenu in datatable
              ilya_shaikovsky
              • 4. Re: unable to update selectOneMenu in datatable

                thanks
                Lot of confusion in this example. Still can't able to figure it out that how and from where actually does the value for selectOneMenu comming from?

                • 5. Re: unable to update selectOneMenu in datatable
                  ilya_shaikovsky

                  you could freelly check out the demo sources . follow the link in my signature.

                  • 6. Re: unable to update selectOneMenu in datatable

                    can you refer me some example(link) for rich:datatable?

                    • 7. Re: unable to update selectOneMenu in datatable
                      ilya_shaikovsky

                      dataTable is fully based on a4j:repeat (just provides table structure markup).. So nothing different for this case implementation with dataTable required.

                      • 8. Re: unable to update selectOneMenu in datatable

                        ok its work using rich:databale and i tested it using test application but when i implemented it in my original application, its showing me a little confusing behavoiur. Please see the code:

                        <rich:dataTable value="#{createRegular.empList}" var="emp">
                        
                        <rich:column>
                         <h:selectBooleanCheckbox value="#{emp.checkStatus}" id="mailCheckBoxes">
                         </h:selectBooleanCheckbox>
                        </rich:column>
                        <rich:column>
                         <f:facet name="header" >
                         <h:outputText value="Symbol" />
                         </f:facet>
                         <h:selectOneMenu value="#{emp.symbol}" required="true">
                         <f:selectItems value="#{PopulateInfo.symbol_list}"/>
                         </h:selectOneMenu>
                        </rich:column>
                        <rich:column>
                         f:facet name="header" >
                         <h:outputText value="Job No" />
                         </f:facet>
                         <a4j:region selfRendered="true" id="job_text">
                         <h:selectOneMenu value="#{emp.job_no}" required="true">
                         <f:selectItems value="#{PopulateInfo.job_no_list}"/>
                        <a4j:support event="onchange" reRender="cost_code_list"
                         action="#{createRegular.isAnySelected}" /> </h:selectOneMenu>
                         </a4j:region>
                        </rich:column>
                        <rich:column>
                         <f:facet name="header" >
                         <h:outputText value="Cost Code" />
                         </f:facet>
                         <h:selectOneMenu id="cost_code_list" value="#{emp.cost_code}" >
                         <f:selectItems value="#{emp.cost_code_list}"/>
                         </h:selectOneMenu>
                        <h:message id="cost_code_error_msg" for="cost_code_list"
                         showDetail="false" showSummary="true" styleClass="error"></h:message>
                        </rich:column>
                        ....
                        


                        public boolean isAnySelected() {
                         EmpList obj;
                         int temp = 0;
                         System.out.println(empList.size());
                         for(int i=0;i <this.empList.size();i++){
                         obj=(EmpList) empList.get(i);
                         System.out.println(obj.isCheckStatus());
                         if (obj.isCheckStatus()){
                         temp++;
                         break;
                         }
                         }
                         if(temp == 0) {
                         return false;
                         }
                         else {
                         return true;
                         }
                         }//end isAnySelected
                        

                        Now when i change the list it calls isAnySelected() but it shows false for the check box even if it is selected.
                        Please correct my mistake.

                        • 9. Re: unable to update selectOneMenu in datatable
                          ilya_shaikovsky

                          you used region... so changes outside the region doesn't get processed.. Works just as designed.

                          • 10. Re: unable to update selectOneMenu in datatable

                            removing region doesn't solve the problem either

                            • 11. Re: unable to update selectOneMenu in datatable

                              please can someone help me out its very urgent
                              thanks

                              • 12. Re: unable to update selectOneMenu in datatable
                                nbelaevski

                                Is action being called now when you've removed regions?

                                • 13. Re: unable to update selectOneMenu in datatable

                                  Ok it works fine now but now there is another issue.
                                  Suppose there are two rows in the datatable and i have a checkbox for every row. If user selects the checkbox then it updates the corresponding list. Now if i selects both checkbox and change the last list, it update the corresponding list perfectly. But if i changes first then it do not update it's corresponding list. OR
                                  Sometimes it throws an exception: java.util.NoSuchElementException
                                  Here is the code that update lists:

                                  public void getList()
                                   {
                                   if(isAnySelected()) {
                                   System.out.println("In if...");
                                   EmpList obj = null;
                                   String selectd_job = "";
                                   PopulateInfo pi = new PopulateInfo();
                                   List<SelectItem> temp_cost_code = new ArrayList<SelectItem>();
                                   List<SelectItem> temp_eq_code = new ArrayList<SelectItem>();
                                  
                                   for(int i = 0; i<empList.size(); i++) {
                                   obj = (EmpList)empList.get(i);
                                   if(obj.isCheckStatus()) {
                                   selectd_job = obj.getJob_no(); temp_cost_code.clear();
                                   temp_eq_code.clear();
                                  
                                   temp_cost_code = pi.getCodeList(selectd_job);
                                   temp_eq_code = pi.getEqCodeList(selectd_job);
                                   obj.setCost_code_list(temp_cost_code);
                                   obj.setEq_code_list(temp_eq_code);
                                   }//end if
                                   }//end for
                                  
                                   }//end if
                                   else {
                                   System.out.println("Select Check box");
                                   }//end else
                                  }
                                  


                                  • 14. Re: unable to update selectOneMenu in datatable

                                    any suggestion

                                    1 2 Previous Next