3 Replies Latest reply on Jul 16, 2012 1:04 AM by Daniel Yang

    how to get list from rich:dataTable on click of commandbutton whose immediate="true" .

    Aniket Murtarkar Newbie

      Hello,

       

      I am working on a form which contains form fields, crud buttons and datalist.

       

      I am using rich:dataTable and i am using check box to select records from list.

       

      outside to this I have a delete button.

      to bypass the form validation i have used immediate="true" on delete button.

       

      but now as I am trying to select and delete the records from list,

      I am unable to get the checked field's details from list. as the request values are bypassed by jsf due to immediate="true".

       

      Can any one help me.

      I am in a very serious need.

       

      Thanks in advance.

        • 1. Re: how to get list from rich:dataTable on click of commandbutton whose immediate="true" .
          Brendan Healey Master

          >to bypass the form validation i have used immediate="true" on delete button.


          A common misconception, validation will occur during the apply request values phase rather than the process

          validations phase. Regardless of this technicality, and despite the fact that you've not posted the code in question,

          I'd be looking at the scope of the backing bean (@ViewScoped may be needed) and ensuring that you are using

          execute="the id of the any inputs", assuming that you are using ajax (if you use a4j:commandButton/Link, you

          are).

           

          Regards,

          Brendan.

          • 2. Re: how to get list from rich:dataTable on click of commandbutton whose immediate="true" .
            Aniket Murtarkar Newbie

            Hello Brendan,

             

            Thanks for reply.

            Here is my code snippet. My code is working fine.  but now I have tried to use rich validations in my application

            but it is now affecting other functionalities.

             

             

            @ManagedBean()

            @RequestScoped

            public class CaseMaster {

             

             

            public String delete() {

                try {

                  this.massage = CommonMassages.deletefailed;

             

                  // view status new, view, update, delete

                  currentAppStatus(false, false, false, true);

                  CaseMasterOps cmOps = new CaseMasterOps();

                  List<String> checkedItems = cmOps.listSelectedItems(caseMasterList, checked);

                  String countDeleted = cmOps.deleteData(checkedItems);

             

                  this.massage = countDeleted + CommonMassages.deletesuccess;

             

                } catch (Exception e) {

                  System.out.println("Exception in MTD Delete()::::" + e.getMessage());

                }

                return "inputClient";

              }

             

             

             

             

            public List<CaseMasterBean> getCaseMasterList() {

                public List<CaseMasterBean> getCaseMasterList() {

                this.caseMasterList = new ArrayList<CaseMasterBean>();

                CaseMasterOps opsObj = new CaseMasterOps();

                opsObj.init();

                currentDetails();

                return this.caseMasterList = opsObj.getCasemaster();

              }

              }

             

             

             

            my jsp code is here

             

             

             

            <h:commandButton rendered="#{caseMaster.writePermission}"  value="#{lbl['label.add']}" immediate="true" action="#{caseMaster.add}"/>

            <h:commandButton rendered="#{caseMaster.viewPermission}"   value="#{lbl['label.view']}" immediate="true" action="#{caseMaster.view}"/>

            <h:commandButton rendered="#{caseMaster.writePermission}"  value="#{lbl['label.save']}" action="#{caseMaster.save}"/>

            <h:commandButton rendered="#{caseMaster.updateMode}" value="#{lbl['label.updatedata']}" action="#{caseMaster.updateData}"/>

            <h:commandButton rendered="#{caseMaster.updatePermission}" value="#{lbl['label.update']}" immediate="true" action="#{caseMaster.update}"/>

            <h:commandButton rendered="#{caseMaster.deletePermission}" value="#{lbl['label.delete']}" immediate="true" action="#{caseMaster.delete}"/>

             

             

             

            <rich:dataTable value="#{caseMaster.caseMasterList}" var="cases" id="table"

                                                    rows="3" style="width:100%;border: 2px;">

             

                                      <rich:column style="width:5%;">

                                        <f:facet name="header">

             

                                        </f:facet>

                                        <h:selectBooleanCheckbox value="#{cases.checked[cases.caseId]}"/>

                                      </rich:column>

                                     

                                      

                                      <rich:column style="width:5%;">

                                        <f:facet name="header">Id</f:facet>

                                        <h:outputText value="#{cases.caseId}"/>

                                      </rich:column>

                                     

                                      <rich:column style="width:10%;">

                                        <f:facet name="header">Number</f:facet>

                                        <h:outputText value="#{cases.caseNo}"/>

                                        <h:outputText value=" of "/>

                                        <h:outputText value="#{cases.caseYearDesc}"/>

                                      </rich:column>

                                     

                                      <rich:column style="width:20%;">

                                        <f:facet name="header" >Case Descriptions</f:facet>

                                        <h:outputText value="#{cases.caseTitle }"/>

                                      </rich:column>

                                     

                                      <rich:column style="width:10%;">

                                        <f:facet name="header" >View status</f:facet>

                                        <h:outputText value="#{cases.status}"/>

                                      </rich:column>

             

                

                                      <rich:column style="width:50%;">

                                        <f:facet name="header" >Attachment</f:facet>

                                        <rich:dataTable value="#{cases.files}" var="file" id="table1"

                                                        style="width:100%;border: 0px;">

             

                                          <rich:column style="width:20%;  border: 0px;">

                                            <h:outputText value="#{file.fileDescription}"/>

             

             

                                            <h:commandLink actionListener="#{caseMaster.downloadFile}"  value=" Download">

                                              <f:param name="fileName" value="#{file.name}"/>

            <!--                                  <f:param name="data" value="# {file.data}"/>-->

                                              <f:param name="caseFileId" value="#{file.caseFileId}"/>

                                            </h:commandLink>

             

                

                                          </rich:column>

             

                                        </rich:dataTable>

                                      </rich:column>

                                        </rich:dataTable>   

             

             

             

             

             

             

            Here I am using a Request Scope. I have tried using view scope but I was not getting values in my managedbean so I used request scope.

            Importantly I dont want to use a session scope.validation problem.gifvalidation problem 1.gif

             

            these are the same form images of different places.

            • 3. Re: how to get list from rich:dataTable on click of commandbutton whose immediate="true" .
              Daniel Yang Novice

              Hi, to avoid validate, you'd better try use a4j:region tag.

               

              And another solution is join the id of checked items and set the id string(it looks like "1,3,4") to a hidden input, and split it in your bean action, then you would know the checked items.