[jboss-user] [JBoss Seam] - Re: Seam 1.1 & Tomahawk Datatable
Newlukai
do-not-reply at jboss.com
Wed Nov 29 04:45:37 EST 2006
Sure. Here we go:
The session bean:
@Stateful
| @Scope(ScopeType.SESSION)
| @LoggedIn
| @Name("searchTestaction")
| public class SearchTestactionAction implements Serializable, SearchTestaction {
| @PersistenceContext(unitName = "aresDatabase")
| private transient EntityManager em;
|
| @In(required=false)
| private Testaction testaction;
|
| private List<Testaction> foundTestactions;
| @DataModelSelection
| @Out(required=false, scope=ScopeType.SESSION)
| private Testaction foundTestaction;
| //@DataModelSelectionIndex workaround
| private int foundTestactionIndex;
|
| @In(required=false)
| private Release selectedRelease;
|
| private String sortColumn = "id";
| private boolean ascending = true;
|
| @Factory("foundTestactions")
| public String search() {
| //omitted: generate the query
|
| if(query.length() != 0) {
| if(selectedRelease != null) {
| addPrefix(query);
| query.append("TACT_REL_ID=");
| query.append(selectedRelease.getID());
| }
| foundTestactions = EMHelper.execQuery(em, "from Testaction " + query.toString() + " order by TACT_ID asc");
| Collections.sort(foundTestactions, new TestactionComparator(sortColumn, ascending));
| }
|
| return "search";
| }
|
| @DataModel
| public List<Testaction> getFoundTestactions() {
| return foundTestactions;
| }
The page with a search form and a result list:
<ui:define name="content">
| <h1>#{ares_messages.header_searchTestaction}</h1>
| <h:form>
| <div id="errors"><h:messages layout="table" /></div>
| <div class="buttonLine">
| <h:outputText rendered="#{not empty searchTestaction.foundTestactions}"
| value="#{ares_messages.label_search_displaySearchForm}"
| onclick="switchVisibility('searchForm'); this.style.display='none';" styleClass="button"
| style="margin-right: 30px; padding: 5px; cursor: pointer;" />
| <h:commandButton action="#{searchTestaction.search}" image="img/find.gif" styleClass="graphical"
| style="margin-left: 0px; margin-right: 15px;" title="#{ares_messages.tooltip_searchTestaction}" />
| </div>
|
| <div id="release">
| <h:outputText value="#{ares_messages.filter_release}: " />
| <h:selectOneMenu value="#{releaseSelector.selectedReleaseNumber}">
| <f:selectItems value="#{releaseSelector.releaseItems}" />
| </h:selectOneMenu>
| </div>
|
| <div id="searchForm" style="display: #{empty searchTestaction.foundTestactions ? 'block' : 'none'};">
|
| ....
|
|
| <t:dataTable var="testaction_var"
| value="#{foundTestactions}"
| id="foundTestactionsTable"
| renderedIfEmpty="false"
| sortColumn="#{searchTestaction.sortColumn}"
| sortAscending="#{searchTestaction.ascending}"
| preserveSort="true"
| rows="20">
| <f:facet name="header">
| <h:outputText value="#{ares_messages.label_ResultCount}: #{foundTestactions.rowCount}" />
| </f:facet>
This ocde adresses the first problem I mentioned. The second problem occurs here:
Bean:
@Stateful
| @Scope(ScopeType.SESSION)
| @LoggedIn
| @Name("testactionValidator")
| public class TestactionValidatorAction extends TestactionHandling implements Serializable, TestactionValidator {
| @In(required=false)
| private Release selectedRelease;
|
| @In(required=false)
| private User selectedUser;
|
| private Long lastSelectedReleaseID;
| private String lastSelectedUserID;
|
| @Factory("testactionsForValidator")
| public void initTestactions() {
| if(hasAFilterChanged() || shouldRefresh() || testactions == null) {
| StringBuffer filter = new StringBuffer();
| if(selectedRelease != null) {
| filter.append(" and TACT_REL_ID=");
| filter.append(selectedRelease.getID());
| }
| testactions = EMHelper.execQuery(em.createQuery(
| "from Testaction where TACT_VALIDATOR_USR_ID=:validator and " +
| "TACT_BFV_ID=" + BugfixValidation.Constants.TO_VALIDATE.value() + " and " +
| "TACT_REV_ID!=" + Revisionclass.Constants.TO_BUGFIX.value() +
| filter.toString() +
| " order by TACT_ID asc"
| ).setParameter("validator", user.getIsAdmin().equals(new Integer(-1)) ? selectedUser.getID() : user.getID()));
|
| lastSelectedReleaseID = (selectedRelease == null) ? null : selectedRelease.getID();
| lastSelectedUserID = (selectedUser == null) ? null : selectedUser.getID();
| }
| Collections.sort(testactions, new TestactionComparator(column, ascending));
| }
|
| @DataModel(scope=ScopeType.PAGE)
| public List<Testaction> getTestactionsForValidator() {
| initTestactions();
| return testactions;
| }
And the page:
<t:dataTable var="testaction_var" value="#{testactionsForValidator}"
| renderedIfEmpty="false" sortColumn="#{testactionValidator.column}"
| sortAscending="#{testactionValidator.ascending}" preserveSort="true">
| <f:facet name="header">
| <h:outputText value="#{ares_messages.label_ResultCount}: #{testactionsForValidator.rowCount}" />
| </f:facet>
| <h:column>
| <f:facet name="header">
| <t:commandSortHeader columnName="id">
| <h:outputText value="#{ares_messages.label_testaction_ID}" />
| </t:commandSortHeader>
| </f:facet>
| <h:commandLink value="#{testaction_var.ID}"
| action="#{testactionValidator.select}" styleClass="rightAlignment" />
| </h:column>
The members "column" and "ascending" are defined in the superclass (with getters and setters). Perhaps that's is the problem?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3989607#3989607
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3989607
More information about the jboss-user
mailing list