0

I've got an application with two user interfaces, one for mobile and one for desktop. Users can switch between them no matter in which device they are using, for example, they can watch desktop interface from a mobile device. To accomplish this, the application adds a parameter to the url that specifies the interface to load.

The solution I found is to add

<f:metadata>
    <f:viewParam name="param" value="#{myBean.param}"></f:viewParam>
</f:metadata>

in all pages, that's because I saw that isn't possible to define it on the template page (JSF 2 facelets <f:metadata/> in template and page).

Is there a way in JSF to pass a get parameter to all pages without having to put the viewparam definition on every page?

Community
  • 1
  • 1
  • 1
    This question is somewhat ambiguous. It isn't exactly clear how you're navigating. Second half of answer in http://stackoverflow.com/q/17734230 explains how `` can be used in case you're navigating via postbacks. – BalusC Jul 06 '15 at 19:20
  • If your design permits it, it would be easier to just store the parameter in a `SessionScoped` bean. – DavidS Jul 06 '15 at 20:39
  • @BalusC, I'm using postback and direct access (h:links) navigation. I tried with the o:form tag, using the useRequestURI, and doesn't work, but maybe is because I didn't now how. – Luis González Jul 08 '15 at 19:41
  • @DavidS, Putting the value in the user session is not a possibility because of the consistency with the back button of the browser. – Luis González Jul 08 '15 at 19:41

0 Answers0