[jboss-user] [JBoss Seam] - @DataModelSelection behavior : bug or feature ?
ve_rao
do-not-reply at jboss.com
Mon Jul 17 06:01:21 EDT 2006
When does a variable annotated as @DataModelSelection get injected? Is it only when a row in the <h:dataTable> is selected? Or does it get initialized whenever there is a postback, even from a control outside the <h:dataTable>?
I am observing that in addition to the first case above, the second is also true. Even when an action listener is invoked in response to a link outside the <h:dataTable> element, the @DataModelSelection variable is getting initialized to the first element of the @DataModel.
Is my observation correct? Is that the expected behavior? That is causing unexpected behavior in my code. I am attaching my sources below to better illustrate.
Thanks,
-- venkat
<h:form>
|
| <s:link value="Up one level"
| rendered="#{folderNavigator.curFolder != null}"
| action="#{folderNavigator.upOneLevel}" />
|
| <h:dataTable var="folder" value="#{folderList}" >
| <h:column>
| <s:link value="#{folder.folderName}"
| action="#{folderNavigator.selectFolder}" />
| </h:column>
| </h:dataTable>
|
| </h:form>
In the listing above, "folderList" is a @DataModel, declared and used in the folderNavigator stateful session bean, which is given below:
@Stateful
| @Scope(SESSION)
| @Name("folderNavigator")
| public class FolderNavigatorAction implements FolderNavigator, Serializable
| {
| @DataModel
| private List<Folder> folderList;
|
| @DataModelSelection
| private Folder curFolder;
|
| @Factory("folderList")
| public void retrieveFolderList() {
|
| if (curFolder == null) {
| folderList = rootFolderList; // Initialized in constructor
| }
| else {
| folderList = curFolder.getChildFolders();
| }
| }
|
| public void selectFolder() {
| retrieveFolderList();
| }
|
| public void upOneLevel() {
| curFolder = curFolder.getParent();
| retrieveFolderList();
| }
| }
When the upOneLevel() method is called, curFolder is automatically injected with the first element of folderList, even though it was not invoked in response to a data model selection.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3958418#3958418
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3958418
More information about the jboss-user
mailing list