DataModel and DataModelSelection staying populated on select()
daxxy Aug 5, 2009 7:37 PMI have the following class:
@Scope(ScopeType.CONVERSATION) @Name("iosBreakdownList") public class IosBreakdownList { @In(create=true) private EntityManager entityManager; @DataModel private List<Object[]> iosVersions; @DataModelSelection @Out(required=false) private Object[] selectedIosVersion; public List<Object[]> getIosVersions() { List<Object[]> resultList = entityManager.createQuery("select d.devOsVer, count(*) from Devices d " + "where d.devOsVer != 'Error' group by d.devOsVer").getResultList(); iosVersions = resultList; return iosVersions; } public String select(){ return "os_selected"; } @Remove public void destroy(){ } }
The data is displayed in a datatable:
<rich:dataTable id="iosBreakdownList" var="_ios" value="#{iosBreakdownList.iosVersions}" rowClasses="rvgRowOne,rvgRowTwo"> <rich:column width="500px"> <f:facet name="header"> <h:outputText value="#{messages['ond.label.devosver']}" /> </f:facet> <s:link action="#{iosBreakdownList.select()}" value="#{_ios[0]}"></s:link> </rich:column> <rich:column width="100px"> <f:facet name="header"> <h:outputText value="Count" /> </f:facet> <h:outputText value="#{_ios[1]}" /> </rich:column> </rich:dataTable>
I am watching the flow of things in the debugger and I don't understand what I'm seeing. I have breakpoints on getIosVersions and select. When I render the page, getIosVersions is called several times. On the 2nd and subsequent times of calling it, selectedIosVersion is populated.
When I click on the link on the link, I jump to the breakpoint in my select() and both iosVersions and selectedIosVersions are null. The page simply rerenders at that point, which is OK for now. Ultimately I want to redirect to a new view using the selectedIosVersion as the input parameter.
But first I have to make sure I can even access iosVersions and selectedIosVersion.
Why is getIosVersion getting called multiple times?
Why is selectedIosVersion getting set when I haven't selected anything yet?
How are these things not hanging on to their content by the time I call select?
TDR