Pete, I'll start off with a very simple example:
Replace the following code inside search.xhtml of the contactlist example
application:
<!-- search results -->
| <table>
| <tr>
| <th>Name</th>
| <th>Cell Phone</th>
| <th>Home Phone</th>
| <th>Address</th>
| <th>City</th>
| <th>State</th>
| <th>Zip</th>
| <th>Country</th>
| </tr>
| <ui:repeat value="#{contacts.resultList}" var="cont">
| <tr>
| <td>
| <s:link view="/viewContact.xhtml" value="#{cont.firstName}
#{cont.lastName}">
| <f:param name="contactId" value="#{cont.id}"/>
| </s:link>
| </td>
| <td>#{cont.cellPhone}</td>
| <td>#{cont.homePhone}</td>
| <td>#{cont.address}</td>
| <td>#{cont.city}</td>
| <td>#{cont.state}</td>
| <td>#{cont.zip}</td>
| <td>#{cont.country}</td>
| </tr>
| </ui:repeat>
| </table>
|
with this code:
| <h:dataTable rendered="#{not empty contacts.resultList}"
value="#{contacts.resultList}" var="cont">
| <h:column>
| <s:link view="/viewContact.xhtml" value="#{cont.firstName}
#{cont.lastName}">
| <f:param name="contactId" value="#{cont.id}"/>
| </s:link>
| </h:column>
| <h:column>
| <f:facet name="header">Name</f:facet>
| <h:inputText value="#{cont.lastName}" />
| </h:column>
| <h:column>
| <f:facet name="header">Cell Phone</f:facet>
| <h:inputText value="#{cont.cellPhone}" />
| </h:column>
| <h:column>
| <f:facet name="header">Home Phone</f:facet>
| <h:inputText value="#{cont.homePhone}" />
| </h:column>
| <h:column>
| <f:facet name="header">Address</f:facet>
| <h:inputText value="#{cont.address}" />
| </h:column>
| <h:column>
| <f:facet name="header">City</f:facet>
| <h:inputText value="#{cont.city}" />
| </h:column>
| <h:column>
| <f:facet name="header">State</f:facet>
| <h:inputText value="#{cont.state}" />
| </h:column>
| <h:column>
| <f:facet name="header">Zip</f:facet>
| <h:inputText value="#{cont.zip}" />
| </h:column>
| <h:column>
| <f:facet name="header">Country</f:facet>
| <h:inputText value="#{cont.country}" />
| </h:column>
| </h:dataTable>
| <h:commandButton action="testHandler.save" value="Save entries">
| <s:conversationId />
| </h:commandButton>
|
|
TestHandler:
| @Name("testHandler")
| public class TestHandler
| {
|
| @In(create=true)
| private EntityManager entityManager;
|
| @In
| private EntityQuery contacts;
|
|
| @Begin(join=true)
| public void saveEntries() {
| for (Contact cont : (List<Contact>)contacts.getResultList()) {
| entityManager.merge(cont);
| }
| }
|
| }
Clicking on the save button one would assume that the changes inside the table
should be saved to the underlying records, however weird behavior occurs when
you either sort or page before making changes and then hit save:
e.g. When changing data on the second page, the records on the first page are
updated, which makes sense, as there is not pagination attribute inside the
h:commandLink
After having played around with sorting and all the other stuff I gave up and
created the SFSB mentioned earlier. The bean is dependent on a small framework
I created for dynamically creating tabled editable views, where you can
configure which columns are visible, by which columns an "Autofilter" (like
e.g. in Excel) is activated, automatic search over visible columns in the
database, etc.
The code is quite large, but I'll be glad to supply it, if you think that it
would be an interesting feature to add to Seam.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057428#4057428
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057428
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user