3 Replies Latest reply on Sep 7, 2009 1:42 PM by Jaime Martin

    how to store datatable values into another table

    karunakaran t Newbie

      hi there,


      Anyone plz tell how to store datatable values, which is reterived from one table and i want to store those same values into another table


      thanks in advance.

        • 1. Re: how to store datatable values into another table
          Arbi Sookazian Master

          Your question doesn't make sense.  are you trying to use one db table (or result set from a JPA query) as the basis for more than one dataTable?

          • 2. Re: how to store datatable values into another table
            karunakaran t Newbie
            hi,

            this is my database design


            acmdb(database)
            -----

            department(table)
            ----------
            deptid
            deptname

            role(table)
            ----
            rolename
            roleid

            formdetails(table)
            -----------
            screenid
            screenname

            rights (table)
            ------
            rights


            accessrights(table)
            ------------

            deptname
            rolename
            screenname
            rights

            <rich:dataTable id="formdetailsList"  var="_formdetails"
                          value="#{formdetailsList.resultList}"
                       rendered="#{not empty formdetailsList.resultList}">
                     <h:column>
                        <f:facet name="header">
                            <ui:include src="layout/sort.xhtml">
                            <ui:param name="entityList" value="# formdetailsList}"/>
                                <ui:param name="propertyLabel" value="Screenname"/>
                                <ui:param name="propertyPath" value="formdetails.screenname"/>
                            </ui:include>
                        </f:facet>
                        <h:inputText value="#{_formdetails.screenname}"/>
                    </h:column>
                    <rich:column styleClass="action">
                        <f:facet name="header">Action</f:facet>
                        <h:selectManyCheckbox id="roles" value="" layout="pageDirection" styleClass="roles" style=" width : 128px;">
                         <f:selectItems value="#{rightstbList.rights}"/>
                        </h:selectManyCheckbox>
                    </rich:column>
                </rich:dataTable>

            i have displayed department,role,screenname and rights from the above mentioned tables and finally i want to store these things to the accessrights table.

            • 3. Re: how to store datatable values into another table
              Jaime Martin Apprentice

              In you xhtml add a button or link that calls a method defined in your pojo home (if you have used seam-gen you should have AccessRights and AccessRightsHome) In this method create a new AccessRights instance and assign values to its fields. Then call to the persist method of the object. If needed, you may pass as parameters the info you require to your method so as to populate the fields before persisting.