[jboss-user] [JBoss Seam] - DataModelSelection returns wrong entry.

hubaer do-not-reply at jboss.com
Wed Feb 14 09:40:30 EST 2007


Hi all,

I have a strange problem with a DataModel. I have a list of item entities referring with a button on a detail information page. 
Now after showing the overview page the first time and clicking on an item entry I always get the first item in the list.
If I go back with the browsers back button and then select this item again, it is displayed correctly ?!?


Are there errors in my annotations? There is not much code that can go wrong :)

The overview bean with the data model:

@Stateful
@Name("itemOverview")
@Scope(ScopeType.EVENT)
public class ItemOverviewActionBean implements ItemOverviewAction, Serializable {
    
    @DataModel(scope=ScopeType.PAGE)
    private List itemList;
    
    @DataModelSelection
    @Out(required=false)
    private Item item;
    
    @Factory("itemList")
    public void initItems() {
        itemList =  getItemList();
    }

    public String showDetails() {
        return "itemDetails";
    }
    
    @Remove @Destroy
    public void destroy() {
    }
}


The corresponding jsf page:

<f:view xmlns="http://www.w3.org/1999/xhtml"
        xmlns:s="http://jboss.com/products/seam/taglib"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:c="http://java.sun.com/jstl/core"
        xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" > 
    
    
        <h:form>        
            <h1><h:outputText value="#{messages['item.overview']}"  /></h1>
            <h:outputText value="#{messages['item.overview.noItemAvailable']}" rendered="#{itemList.rowCount==0}"/>
            <h:dataTable var="itm" value="#{itemList}" rendered="#{itemList.rowCount>0}">
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="#{messages['item.title']}"/>
                    </f:facet>
                    <h:outputText value="#{itm.title}" />
                </h:column>
                <h:column>
                    <h:commandButton value="Details" action="#{itemOverview.showDetails}"/>
                </h:column>
            </h:dataTable>
        </h:form>
    
    
</f:view>



The details bean.

@Stateful
@Name("itemDetail")
@Scope(ScopeType.CONVERSATION)
public class ItemDetailActionBean implements ItemDetailAction, Serializable {
    
    @In(required=true)
    @Out(required=true)
    private Item item;
    
    /** Creates a new instance of OverviewActionBean */
    public DetailActionBean() {
    }
    
    @Remove @Destroy
    public void destroy() {
    }
    
    ...
}



I'm using JBoss 4.0.5 with Seam 1.1.6 on Windows XP Pro.

I hope someone could explain me this strange behaviour, and how to solve it.



Regards
Marco



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016395#4016395

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016395



More information about the jboss-user mailing list