3 Replies Latest reply on Apr 9, 2013 5:06 AM by sivaprasad9394

    Dynamically adding tab content not update backing bean

    aindrilaacharya

      By using <a4j:repeat> I can successfully add dynamic tab.

      Thank u for such a useful component.

      On that dynamically added tab I create a <rich:panel> consist of some <h:inputtext>

      By my problem is that whenever I am putting some values on that text boxes and submit the form, backing bean values are not updated.

      Please tell me how could I get that values in backing bean

       

      Thanks in advance

      For ur ready reference I am attaching here with my code snippet:

       

      //XHTML PAGE CODE

      <ui:define name="content">

              <h:form id="homeForm">

              <h:panelGrid id="PanelGrid">

              <ui:insert name="body">

              <rich:tabPanel switchType="ajax" id="mainTabPanel" headerLocation="center">

              <rich:tab header="#{menuCreator.bodyHead}" id="mainTabPanel1">

                  <ui:include src="" />                       

              </rich:tab>

      //DYNAMICALLY ADDED TAB CODE PORTION GOES HERE

              <a4j:repeat value="#{beanClass.test}" var="skinName" >

              <rich:tab header="#{skinName}" name="#{skinName}">

              <ui:define name="body">

              <a4j:region id="abc">

                  <a4j:commandLink

                          action="#{beanClass.save}"

                          id="save"

                          render="homeForm:categoryPanel"

                          title="Save" execute="homeForm:abc" />

                         

                      <rich:panel header="INFORMATION" id="categoryPanel">

                          <h:outputLabel value="branchcode"/>

                          <h:inputText id="branchcode" value="#{beanClass.branchcode}"/>

                          <h:outputLabel value="branchname"/>

                          <h:inputText id="branchname" value="#{beanClass.branchname}" />

                      </rich:panel>

                     

                      </a4j:region>

                      </ui:define>               

              </rich:tab>

          </a4j:repeat>

      </rich:tabPanel>

                  </ui:insert>

              </h:panelGrid>   

             

       

          </h:form>

      </ui:define>

       

      //BEAN CLASS

       

      BeanClass is as follows:

      @SessionScope

              public class beanClass implements Serializable {       

             

                  @Column(name = "branchcode")  

                  private String branchcode;   

        

                  @Column(name = "branchname")   

                  private String branchname;

             

                   public String getBranchcode() {

                      return branchcode;

                  }

                  public void setBranchcode(String branchcode) {

                      this.branchcode = branchcode;

                  }

                  public String branchname() {       

                      return branchname;

                  }

                  public void setBranchname(String branchname) {       

                      this.branchname = branchname;

                  }       

              }

       

      I want to get the value of branchcode and branchname in bean class.

        • 1. Re: Dynamically adding tab content not update backing bean
          sivaprasad9394

          Hi,

           

          If you are using seam means please check with @In and @Out usage in the backing bean or pojo class.

          You can try with f:param attaribute or hidden attribute or setproperty actionListener.

          Either one you can make use to ge t the value in the backing end.

           

          Thank and Regards,

          Siva

          • 2. Re: Dynamically adding tab content not update backing bean
            aindrilaacharya

            Hi Siva,

             

            Thanks for ur reply.

            My persistence class is:

              public class entityClass implements Serializable {       

             

                        @Column(name = "branchcode")  

                        private String branchcode;   

             

                        @Column(name = "branchname")   

                        private String branchname;

             

                         public String getBranchcode() {

                            return branchcode;

                        }

                        public void setBranchcode(String branchcode) {

                            this.branchcode = branchcode;

                        }

                        public String branchname() {       

                            return branchname;

                        }

                        public void setBranchname(String branchname) {       

                            this.branchname = branchname;

                        }       

                    }

             

            beanClass:

            @SessionScoped

            public void beanClass implements Serializable{

             

            private entityClass entity= new entityClass();

            public void save(){

            entitymanager.merge(entity);

            }

             

            }

             

            I want to get the value in beanclass through persistence class from xhtml page.

            My problem is that whenever I am hitting save method ,I receive entity object as null.

            • 3. Re: Dynamically adding tab content not update backing bean
              sivaprasad9394

              Just use normal java script function to display values before clicking the save button.

              like document.getElementById(...).value.

               

              This is used to check the value is set to the property or not.

              If it is ok the create hidden variable and using f:param pass the hidden variable value and back end bean get it and assign it to the specific variable and persist the Entity class object.

              Normallynull object means value is not set to the proper variabvles.

              @In(create = false, required = false)

                  @Out(required = false,scope = ScopeType.REQUEST)  to get the variable value.It is not mandatory one .

               

              Thanks,

              Siva