-
1. Re: Save data from a datatable
pdhaigh Sep 8, 2009 4:48 PM (in response to jasti_jenny)hi jenny,
Presuming your datatable just interates through a number of Entity instances, you should just be able to have each row containing the relevant h:input tags, and then just have your
save
button call a function that causes a flush. Everything should then be saved. -
2. Re: Save data from a datatable
jasti_jenny Sep 8, 2009 11:47 PM (in response to jasti_jenny)Thankyou for your reply, I am using the dataTable with inputText Boxes and when the user updates the textboxes I am trying to save the data back to the database:
I am using a factory method to display the workflowData when the user comes to the page
<h:form id="workflowForm" styleClass="edit"> <rich:dataTable var="workflowUsers" value="#{workflowData}" rendered="#{workflowData.rowCount>0}" > <h:column> <f:facet name="header"> <h:outputText value="Review Order"/> </f:facet> <s:decorate id="userIdField" template="layout/edit.xhtml"> <h:inputText id="reviewOrder" required="true" value="#{workflowUsers.reviewOrder}" size="3"> </h:inputText> </s:decorate> </h:column> <h:column> <f:facet name="header"> <h:outputText value="Role"/> </f:facet> <h:selectOneMenu value="#{workflow.getRoles()}"> <s:convertEntity /> <s:selectItems value="#{workflow.getRoles()}" var="userRole" label="#{userRole.roleDescription}" noSelectionLabel="list"/> </h:selectOneMenu> </h:column> </rich:dataTable> <div class="actionButtons"> <h:commandButton id="workflow" value="Save Workflow" action="#{workflow.saveWorkflow}"/> </div> </h:form>
When I change the value of ReviewOrder filed the control is still going to Factroy method even if the workflowdata is not null.
Here is the code of my backing bean
@Factory("workflowData") public void getWorkflowData() { log.info("33333333333333 "); workflowData = em.createQuery("from GwpsProofWorkflow w where w.gwpsProof=:gwpsProof") .setParameter("gwpsProof", proof ) .getResultList(); log.info("3333333333333 "+workflowData.size()); for(GwpsProofWorkflow workflow: workflowData) { log.info(workflow.getGwpsUserByUserId().getEmailAddress()+"userName"+workflow.getGwpsProof().getProofId()); } }
Before going to saveWorkflow method the control is going to getWorkflowData(), can someone tell me why?
Thanks.