2 Replies Latest reply on Mar 16, 2009 10:32 AM by Roland Schöler

    Submitting row contents in datatable

    Vassiliy Dubkin Newbie


      I have a small problem but I think there is a simple solution for it. I am using a dataTable (bind to a java.util.List of entities) and I want to enable direct editing of the results (similiar to Excel). That's quite easy, I just use <h:inputText /> instead of <h:outputText /> elements within <rich:column>. Small example:

      <rich:column sortBy="#{item.createdOn}">
       <f:facet name="header">
       <h:outputText value="#{messages['createdOn']}" />
       <h:inputText value="#{item.createdOn}" />
       <f:facet name="header">
       <h:outputText value=" " />
       <a4j:commandLink action="#{manager.save}"
       <a4j:actionparam name="saveParam" value="#{item.id}"
       assignTo="#{manager.id}" />
       <h:graphicImage value="/images/save.png"/>

      But now I have the problem that the values are bound to the list of items but I need a way to transmit the values for one row when the user clicks the save link. For short: When the user clicks the save link, the whole row contents shall be submitted, but unfortunately I don't know how to do.

      Thanks in advance!

        • 1. Re: Submitting row contents in datatable
          Ilya Shaikovsky Master

          Sorry but can't get the problem :/ All the changes should passed to model items just after button click.. Or I miss something?

          • 2. Re: Submitting row contents in datatable
            Roland Schöler Newbie

            Hello wark2007, one possible way is to use a4j:support alone or in combination with f:setPropertyChangeListener (JSF 1.2), or use a4j:commandLink etc.

            I write this examples only out from my mind - therefore semantic failures are possible (only show you possible ways to go....8-})!

            VAR 1 - only a4j:support
            <a4j:support event="onclick" actionListener="#{YOURBEAN.processMETHOD}" reRender="YOUR-TABLEID" eventsQueue="USE_OR_NOT"/>

            VAR 2 - var contains the OID of the changedtable and target contains the variable of the BEAN, which store the OID.....during work of the action-Method you can take this OID of the row to do your saving stuff
            <a4j:support event="onclick" reRender="YOUR-TABLEID">
            <f:setPropertyChangeListener var="SOURCE" target="target" />

            VAR 3: direct usage of a4j:commandLink