Pagination between tabs
sandman202 Apr 1, 2009 8:19 PMI am hoping someone might have a solution to what I am about to describe.
Using...
Seam-2.1.1.GA
Richfaces-3.3.0.GA
I have a detail screen for user (uzer.xhtml). On the bottom of the screen are 2 tabs. One for phone numbers (phone.xhtml) and the other for addresses (address.xhtml). My application framework is similar to that described in Seam in Action
.
For testing purposes, I have set the maxResults to 3 within phoneList.java and to 1 within address.java. I created 9 different phone numbers and 2 addresses for this test user.
On the initial display of the user, the phone tab is the default tab displaying the first 3 phone numbers. I advance the page to the next 3 phone numbers. So far, so good. Then, when I click on the address tab, I am getting the message no addresses found
and on the bottom of the tab I see the first page
and previous page
. If I click on on of those, one of the addresses appears.
It appears as if the pagination is being carried over from one tab to another. Is there a way to prevent this from happening??? Do I need to pass the page number as a param and set it to 0
every time I change tabs?
AddressList.page.xml
<param name="firstResult" value="#{addressList.firstResult}" />
<param name="addressListSort" value="#{addressList.orderColumn}"/>
<param name="dir" value="#{addressList.orderDirection}" />
PhoneList.page.xml
<param name="firstResult" value="#{phoneList.firstResult}" />
<param name="phoneListSort" value="#{phoneList.orderColumn}" />
<param name="dir" value="#{phoneList.orderDirection}" />
uzer.xhtml
<ui:composition 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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
template="/layout/template.xhtml">
<ui:define name="body">
<rich:panel>
<f:facet name="header">User Details</f:facet>
...
<div style="clear: both" />
</rich:panel>
<div class="actionButtons">
<s:button view="/role/admin/UzerEdit.xhtml"
id="edit"
value="Edit" />
<s:button view="#{empty uzerFrom ? '/role/admin/UzerList' : uzerFrom}.xhtml"
id="done"
value="Done" />
</div>
<rich:tabPanel switchType="ajax">
<rich:tab label="Phone Numbers">
<ui:include src="/role/admin/PhoneTable.xhtml">
<ui:param name="phoneFrom" value="/role/admin/Uzer"/>
</ui:include>
<div class="actionButtons">
<s:button id="addPhone" value="Add Phone Number"
view="/role/admin/PhoneEdit.xhtml">
<f:param name="uzerId" value="#{uzerHome.instance.id}" />
<f:param name="phoneFrom" value="/role/admin/Uzer" />
</s:button>
</div>
</rich:tab>
<rich:tab label="Addresses">
<ui:include src="/role/admin/AddressTable.xhtml">
<ui:param name="addressFrom" value="/role/admin/Uzer"/>
</ui:include>
<div class="actionButtons">
<s:button id="addAddress" value="Add Address"
view="/role/admin/AddressEdit.xhtml">
<f:param name="uzerId" value="#{uzerHome.instance.id}" />
<f:param name="addressFrom" value="/role/admin/Uzer" />
</s:button>
</div>
</rich:tab>
</rich:tabPanel>
</ui:define>
</ui:composition>
PhoneTable.xhtml
<a4j:form id="phoneTableForm"
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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
template="/layout/template.xhtml" >
<div class="association" id="phones">
<h:outputText value="No phone number exists"
rendered="#{empty phoneList.resultList}"/>
<rich:dataTable id="phoneList"
var="_phone"
value="#{phoneList.resultList}"
rendered="#{not empty phoneList.resultList}">
<h:column>
<f:facet name="header">
<s:decorate template="/layout/sort.xhtml">
<ui:param name="entityListName" value="phoneList"/>
<ui:param name="entityList" value="#{phoneList}"/>
<ui:param name="propertyLabel" value="Name"/>
<!-- doesn't support two sort fields -->
<ui:param name="propertyPath" value="uzer.name"/>
</s:decorate>
</f:facet>
#{_phone.uzer.name}
</h:column>
...
<h:column>
<f:facet name="header">Action</f:facet>
<s:link view="#{empty from ? '/role/admin/Phone' : from}.xhtml"
value="Select"
id="phoneSelect"
propagation="none">
<f:param name="phoneFrom"
value="#{phoneFrom}"/>
<f:param name="phoneId"
value="#{_phone.id}"/>
</s:link>
</h:column>
</rich:dataTable>
</div>
<div class="tableControl">
<s:link view="#{phoneFrom}.xhtml"
rendered="#{phoneList.previousExists}"
value="#{messages.left}#{messages.left} First Page"
id="phoneListFirstPage">
<f:param name="firstResult" value="0"/>
</s:link>
<s:link view="#{phoneFrom}.xhtml"
rendered="#{phoneList.previousExists}"
value="#{messages.left} Previous Page"
id="phoneListPreviousPage">
<f:param name="firstResult"
value="#{phoneList.previousFirstResult}"/>
</s:link>
<s:link view="#{phoneFrom}.xhtml"
rendered="#{phoneList.nextExists}"
value="Next Page #{messages.right}"
id="phoneListNextPage">
<f:param name="firstResult"
value="#{phoneList.nextFirstResult}"/>
</s:link>
<s:link view="#{phoneFrom}.xhtml"
rendered="#{phoneList.nextExists}"
value="Last Page #{messages.right}#{messages.right}"
id="phoneListLastPage">
<f:param name="firstResult"
value="#{phoneList.lastFirstResult}"/>
</s:link>
</div>
</a4j:form>
AddressTable.xhtml
<a4j:form id="addressTableForm"
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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<div class="association" id="addresss">
<h:outputText value="No address exists"
rendered="#{empty addressList.resultList}"/>
<rich:dataTable id="addressList"
var="_address"
value="#{addressList.resultList}"
rendered="#{not empty addressList.resultList}">
<h:column>
<f:facet name="header">
<s:decorate template="/layout/sort.xhtml">
<ui:param name="entityListName" value="addressList"/>
<ui:param name="entityList" value="#{addressList}"/>
<ui:param name="propertyLabel" value="Name"/>
<!-- doesn't support two sort fields -->
<ui:param name="propertyPath" value="uzer.name"/>
</s:decorate>
</f:facet>
#{_address.uzer.name}
</h:column>
...
<h:column>
<f:facet name="header">
<s:decorate template="/layout/sort.xhtml">
<ui:param name="entityListName" value="addressList"/>
<ui:param name="entityList" value="#{addressList}"/>
<ui:param name="propertyLabel" value="Address 1"/>
<!-- doesn't support two sort fields -->
<ui:param name="propertyPath" value="address.address1"/>
</s:decorate>
</f:facet>
#{_address.address1}
</h:column>
...
<h:column>
<f:facet name="header">Action</f:facet>
<s:link view="#{empty from ? '/role/admin/Address' : from}.xhtml"
value="Select"
id="addressSelect"
propagation="none">
<f:param name="addressFrom"
value="#{addressFrom}"/>
<f:param name="addressId"
value="#{_address.id}"/>
</s:link>
</h:column>
</rich:dataTable>
</div>
<div class="tableControl">
<s:link view="#{addressFrom}.xhtml"
rendered="#{addressList.previousExists}"
value="#{messages.left}#{messages.left} First Page"
id="addressListFirstPage">
<f:param name="firstResult" value="0"/>
</s:link>
<s:link view="#{addressFrom}.xhtml"
rendered="#{addressList.previousExists}"
value="#{messages.left} Previous Page"
id="addressListPreviousPage">
<f:param name="firstResult"
value="#{addressList.previousFirstResult}"/>
</s:link>
<s:link view="/role/admin/AddressTable.xhtml"
rendered="#{addressList.nextExists}"
value="Next Page #{messages.right}"
id="addressListNextPage">
<f:param name="firstResult"
value="#{addressList.nextFirstResult}"/>
</s:link>
<s:link view="#{addressFrom}.xhtml"
rendered="#{addressList.nextExists}"
value="Last Page #{messages.right}#{messages.right}"
id="addressListLastPage">
<f:param name="firstResult"
value="#{addressList.lastFirstResult}"/>
</s:link>
</div>
</a4j:form>