Can't Pass String as parameter JSF 2.3

603 views Asked by At

I'm using Primefaces 6.0 and JSF 2.3, i passed String as parameter but it become empty! java:

FacesContext context = FacesContext.getCurrentInstance();
ExternalContext extContext = context.getExternalContext();
String redirected = extContext.encodeActionURL(context.getApplication().getViewHandler().getActionURL(context, url));

URIBuilder builder = new URIBuilder(redirected);
builder.addParameter("action", "A")
extContext.getFlash().setKeepMessages(true);
extContext.redirect(builder.toString());

XHTML:

......
<f:metadata>
    <f:viewParam name="action" value="#{mybean.action}" />
</f:metadata>
.......

It works fine when i pass Boolean or Long, below an example Long :

<f:viewParam name="id" value="#{mybean.id}" converter="javax.faces.Long" />
1

There are 1 answers

0
Sidaoui Majdi On BEST ANSWER

I added OmniFaces library and it works very well :

pom.xml:

<dependency>
   <groupId>org.omnifaces</groupId>
   <artifactId>omnifaces</artifactId>
   <version>3.1</version>
</dependency>

XHTML:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
//Add this tag
    xmlns:o="http://omnifaces.org/ui">

......
<f:metadata>
    <o:viewParam name="action" value="#{mybean.action}" />
</f:metadata>
.......