Probably I am missing something here.
I have a template with a menu, with the options passign parameters to the JSF page:
<rich:menuItem label="Todos" action="#{mainMenuCtrl.listTickets}">
<f:param name="baseLocation" value=""/>
<f:param name="ticketStatus" value="Solicitado"/>
</rich:menuItem>
<rich:menuItem label="H. General" action="#{mainMenuCtrl.listTickets}">
<f:param name="baseLocation" value="HGN"/>
<f:param name="ticketStatus" value="Solicitado"/>
</rich:menuItem>
The controller just redirects to the page:
public String listTickets() {
return "ticketsList.xhtml?faces-redirect=true&includeViewParams=true";
}
And ticketsList.xhtml has the metadata section:
<f:metadata>
<f:viewParam name="baseLocation" value="#{ticketsListCtrl.baseLocation}" converter="es.caib.gesma.gesman.data.converter.LocationConverterByShortCode"/>
<f:viewParam name="ticketStatus" value="#{ticketsListCtrl.ticketStatus}" converter="es.caib.gesma.gesman.data.converter.TicketStatusConverter"/>
<f:event type="preRenderView" listener="#{ticketsListCtrl.retrieveTickets()}" />
</f:metadata>
The problem is that, when I am at another page (index.xhtml) that uses the same template, clicking in any of the menu items drives me ticketsList.xhtml but both params are empty.
../ticketsList.xhtml?baseLocation=&ticketStatus=
When I click the same item from ticketsList.xhtml, it shows the correct URL and from there anything works ok.
../ticketsList.xhtml?baseLocation=HGN&ticketStatus=Solicitado
Can anyone point to me why are the view-params missing when clicking from other pages?
Thanks in advance.
The
includeViewParamswill include the view parameters of the current view, not of the target view.You basically need to define the to-be-included view parameters as
<f:viewParam>inindex.xhtmlas well, or to look for an alternate approach.