1

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.

SJuan76
  • 24,532
  • 6
  • 47
  • 87

1 Answers1

1

The includeViewParams will 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> in index.xhtml as well, or to look for an alternate approach.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • There are several pages (and many more to come), and from http://stackoverflow.com/questions/7344056/jsf2-how-achieve-site-wide-viewparam-handling-policy-using-a-template it seems I cannot put it in the template. The only option left is the `ManagedProperty`? – SJuan76 Sep 07 '12 at 13:26
  • That's the best alternative left, yes. Best would be to design a separate/distinct request scoped bean for this. – BalusC Sep 07 '12 at 13:41
  • The "separate/distinct request scoped bean" means a bean only for the two parameters, to be used by the bean of the receiving page? Otherwise I don't understand it. – SJuan76 Sep 07 '12 at 13:46