无法将字符串作为参数传递 JSF 2.3
Can't Pass String as parameter JSF 2.3
我正在使用 Primefaces 6.0
和 JSF 2.3
,我将字符串作为参数传递,但它变成了空!
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>
.......
当我传递 Boolean 或 Long 时它工作正常,下面是一个 Long 示例:
<f:viewParam name="id" value="#{mybean.id}" converter="javax.faces.Long" />
我添加了 OmniFaces 库,它运行良好:
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>
.......
我正在使用 Primefaces 6.0
和 JSF 2.3
,我将字符串作为参数传递,但它变成了空!
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>
.......
当我传递 Boolean 或 Long 时它工作正常,下面是一个 Long 示例:
<f:viewParam name="id" value="#{mybean.id}" converter="javax.faces.Long" />
我添加了 OmniFaces 库,它运行良好:
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>
.......