I know I'm making some obvious mistake below, and it's driving me to
distraction....
I have a page which displays a list and allows selection to go to a detailed view of the
selected item:
| @Stateful
| @Scope(SESSION)
| @Name("dataSourceList")
| @LoggedIn
| public class DataSourceListAction implements DataSourceList, Serializable
| {
| ...
|
| @DataModel
| private List<DataSource> dataSources;
| @DataModelSelection
| @In(required=false)
| @Out(scope=SESSION, required=false)
| private DataSource dataSource;
|
| @Factory
| @Observer("createDataSourceConfirmed")
| public void getDataSources()
| {
| dataSources = em.createQuery("from DataSource s where s.user.username =
:username")
| .setParameter("username", user.getUsername())
| .getResultList();
| }
|
| public String selectDataSource()
| {
| log.info("get datasource: #0 for #{user.username}",
dataSource.getId());
| dataSource = em.find(DataSource.class, dataSource.getId());
| log.info("got datasource: #0 for #{user.username}",
dataSource.getName());
| events.raiseEvent("selectDataSource");
| return "datasource";
| }
|
| public void delete()
| {
| dataSources.remove(dataSource);
| em.remove(dataSource);
| dataSource=null;
| }
|
| @Destroy @Remove
| public void destroy() {}
|
| }
|
I want the selection outjected to drive a detailed view page, which among other things
displays an attribute which is a list of objects using a @DataModel and dataTable. The
backing code looks like:
| @Stateful
| @Scope(SESSION)
| @Name("dataSourceView")
| @LoggedIn
| public class DataSourceViewAction implements DataSourceView, Serializable
| {
| ...
|
| @In(scope=SESSION, required=true)
| private DataSource dataSource;
|
| @DataModelSelection(value="dataFields")
| @Out(scope=SESSION, required=false)
| private DataField dataField;
|
| @DataModel(value="dataFields")
| @Observer("selectDataSource")
| public List<DataField> getDataFields()
| {
| log.info("in new getDataFields for #0", dataSource == null ?
"null" : dataSource.getName());
| return dataSource.getDataFields();
| }
|
| public String selectDataField()
| {
| log.info("get dataField: #0", dataField.getName());
| return "dataviewer";
| }
|
| @Destroy @Remove
| public void destroy() {}
|
| }
|
I'm confused over the behavior. I create two items in the list in other code. When I
select the first item in the list, it shows the simple attributes of the first item, but
the list attribute contains the values from the second, most recently created item.
Similarly if I subsequently select the second item from the list, it shows the simple
attributes from the second item, but the list attrbute from the first. If I select the
second item again, everything looks fine. The debugging statements in the observer do
show that the dataSource object I expect to be selected is the previously outjected one.
I'm missing something clear and simple in the lifecycle here - anyone have any
advice?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3975290#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...