Hello,
My aim is to show filtered data in table where filter depends on request parameter. That data might be large therefore I don't want to store it in the session. I have hard time trying to pass that request parameter to filtering java code. So I created separate session bean that contains only one string for that parameter and I added it to backup bean, which performs filtering:
public class AType { private String type; // getter & setter }
public class ActivityController { private AType atype; //... public List<Activity> getAll() { String type = atype.getType(); System.out.println("Type = " + type); if ("future".equals(type)) { return getFutureActivities(); } else { return getTodayActivities(); } } }
I'm obtaining the parameter in this way:
<f:metadata> <f:viewParam name="type" value="#{activityController.atype.type}" /> </f:metadata> <ui:composition template="WEB-INF/pages/template.xhtml"> <ui:define name="body"> <f:view> <h:form> <rich:extendedDataTable ... value="#{activityController.all}" var="item" > ...
The problem is that for some reason activityController.atype.type is usually initialised twice - firstly the right value is set and after that (but not always) its previous value is set. So I have to press links many times before I reach desired page. But when I change URL (not clicking at the link), everything works in the proper way.
What's wrong with this, what do I do wrong?
P.S. btw links on which I pressed were added in this way:
<h:outputLink value="activities.xhtml?type=future"> <h:outputText value="Future Activities"></h:outputText> </h:outputLink>
Answered here:
http://community.jboss.org/message/617221