[jboss-user] [JBoss Seam] - Re: How to use ice:dataTable and @DataModel?
danoakland
do-not-reply at jboss.com
Tue Mar 6 11:42:47 EST 2007
I wouldn't say that it's without problems, but I did get the sortable table working with Seam 1.1.5 (and now upgraded to 1.1.6). I haven't gone to 1.2 yet.
The trick that I had to use is to provide the ice:dataTable with the actual DataModel itself, not the outjected variable from Seam. For example, I have a bean that manages a table of companies that can be sorted by name or main office location:
| @Stateful
| @Name("companyList")
| @Scope(ScopeType.SESSION)
| public class CompanyListBean extends CompanyList {
| ...
|
| @DataModel
| private List<CompanyListObject> companies;
|
| ...
|
| public boolean isAscending() {
| // getter
| }
|
| public void setAscending(boolean ascending) {
| // setter
| }
|
| public String getSortColumn() {
| // getter
| }
|
| public void setSortColumn(String columnName) {
| // setter
| }
|
| ...
|
| public javax.faces.model.DataModel getResults() {
| if (companies.size() > 1) {
| // do sort logic if necessary...
| java.util.Collections.sort(companies, someComparator);
| }
| return (javax.faces.model.DataModel) Contexts
| .getSessionContext().get("companies");
| }
|
Then in the Faces view you use ice:dataTable like this:
| <ice:dataTable value="#{companyList.results}" var="result"
| sortColumn="#{companyList.sortColumn}"
| sortAscending="#{companyList.ascending}" ... >
| <ice:column>
| <f:facet name="header">
| <ice:commandSortHeader columnName="name" arrow="true">
| <ice:outputText value="Company Name" />
| </ice:commandSortHeader>
| </f:facet>
| <h:outputLink value="#{result.url}">
| #{result.name}
| </h:outputLink>
| </ice:column>
| <ice:column>
| <f:facet name="header">
| <ice:commandSortHeader columnName="city" arrow="true">
| <ice:outputText value="Main Office" />
| </ice:commandSortHeader>
| </f:facet>
| <h:outputText>
| #{result.city}
| </h:outputText>
| </ice:column>
| </ice:dataTable>
|
and it works for me. I may have omitted some stuff from my example there, but hopefully you get the gist of it...
It seems that Seam doesn't outject the updated DataModel on a partial submit, but the "getResults" method will.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4025472#4025472
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4025472
More information about the jboss-user
mailing list