This content has been marked as final.
Show 5 replies
-
1. Re: Multiple Seam DataModelSelection in one action: Selectio
bram_ Jul 9, 2007 10:18 AM (in response to bram_)Just to be clear:
If I select any object from the list, the first object is always injected into current. -
2. Re: Multiple Seam DataModelSelection in one action: Selectio
bram_ Jul 9, 2007 10:35 AM (in response to bram_)I've tried to go back to only using single DataModel(Selection) pairs, but this also didn;t work anymore. I've found out that this doesn't work (in my page):
<rich:dataTable id="myRequestsDataTable" var="result" value="#{investmentAction.searchResults}" rows="10">
but this does work:<rich:dataTable id="myRequestsDataTable" var="result" value="#{searchResults}" rows="10">
-
3. Re: Multiple Seam DataModelSelection in one action: Selectio
bram_ Jul 9, 2007 10:49 AM (in response to bram_)This works a lot better for the abstract DataModel:
@DataModelSelection("searchResults") protected T current; @DataModel protected List<T> searchResults;
I'm now gonna try the same for the secondary model.
I'm still interested in a tutorial / example on how the DataModel and DataModelSelection annotations work
in multiples like above, so if someone has a clear example / doc / tutorial, please post. -
4. Re: Multiple Seam DataModelSelection in one action: Selectio
pmuir Jul 9, 2007 6:48 PM (in response to bram_)Can you post the whole page/bean (working, but remove any irrelevant fields/methods from then).
-
5. Re: Multiple Seam DataModelSelection in one action: Selectio
bram_ Jul 10, 2007 4:47 AM (in response to bram_)This is the working code:
Abstract class:package com.nxp.cda.commons.controller; import java.math.BigDecimal; ... import org.jboss.seam.annotations.datamodel.DataModel; import org.jboss.seam.annotations.datamodel.DataModelSelection; ... import com.nxp.cda.commons.model.DomainObject; public abstract class AbstractSearchAction<T extends DomainObject> implements SearchAction<T> { /**Current (selected) object */ @DataModelSelection("searchResults") @Out(required = false) protected T current; /**Resultset.*/ @DataModel protected List<T> searchResults; public List<T> getSearchResults() { return this.searchResults; } protected void setSearchResults(List<T> searchResults) { this.searchResults = searchResults; } public T getCurrent() { return current; } public void setCurrent(T current) { this.current = current; } }
And the specific implementation:package com.nxp.atinvestor.web.controller; ... import org.jboss.seam.annotations.datamodel.DataModel; import org.jboss.seam.annotations.datamodel.DataModelSelection; import com.nxp.atinvestor.domain.Investment; import com.nxp.atinvestor.domain.OrganizationalLevel; import com.nxp.atinvestor.domain.User; import com.nxp.cda.commons.controller.AbstractAction; ... @Stateful @Name("userAction") @Scope(ScopeType.SESSION) public class UserActionImpl extends AbstractAction<User> implements UserAction { /** The current user: */ private User user; /** All OrganizationalLevels that this user is an approver of. */ // This is the secondary model:@DataModel private List<OrganizationalLevel> organizationalLevels; // This is the secondary model selected item:@DataModelSelection("organizationalLevels") private OrganizationalLevel currentOrganizationalLevel; public List<OrganizationalLevel> getOrganizationalLevels() { return organizationalLevels; } public void setOrganizationalLevels( List<OrganizationalLevel> organizationalLevels) { this.organizationalLevels = organizationalLevels; } public OrganizationalLevel getCurrentOrganizationalLevel() { return currentOrganizationalLevel; } public void setCurrentOrganizationalLevel( OrganizationalLevel currentOrganizationalLevel) { this.currentOrganizationalLevel = currentOrganizationalLevel; } }