问题
I have a page that has two GET params:
round = [some integer]
group = [some string]
See URL above.
These are the two components of the group's PK, an INT + a VARCHAR.
Facelet code:
<f:metadata>
<f:viewParam name="round" value="#{groupHandler.roundId}">
<f:convertNumber integerOnly="true" />
</f:viewParam>
<f:viewParam name="group" value="#{groupHandler.groupCode}" />
<f:viewAction action="#{groupHandler.loadEntity}" />
</f:metadata>
...
<p:button widgetVar="reloadPageButton"
value="Reload page"
outcome="#{view.viewId}?includeViewParams=true" />
<h1>Group Manager</h1>
...
As you can see, the groupHandler
bean receices the round ID via <h:viewParam name="round" value="#{groupHandler.roundId}">
using a number converter.
I construct a button to reload the page including the view parameters. When clicking this button, the page gets reloaded correctly, however, it now includes a comma character %2C
in the new URL:
EDIT #1:
This is what a p:link
hover has to say:
EDIT #2:
Minimal reproducible example:
XHTML:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://java.sun.com/jsf/html">
<f:view encoding="UTF-8">
<f:metadata>
<f:viewParam name="round" value="#{groupHandler.roundId}">
<f:convertNumber integerOnly="true" />
</f:viewParam>
<f:viewParam name="group" value="#{groupHandler.groupCode}" />
<f:viewAction action="#{groupHandler.loadEntity}" />
</f:metadata>
<h:head>
<title>PrimeFaces View Param Int Reload Test</title>
</h:head>
<h:body>
<p:link widgetVar="reloadPageButton"
value="Reload page"
outcome="#{view.viewId}?includeViewParams=true" />
<p />
<h:form id="test-form">
The selected group is: [#{groupHandler.roundId}, #{groupHandler.groupCode}]
</h:form>
</h:body>
</f:view>
</html>
Bean:
@Named
@ViewScoped
public class GroupHandler implements Serializable
{
private static final long serialVersionUID = 1L;
private Integer roundId;
private String groupCode;
public Integer getRoundId()
{
return roundId;
}
public void setRoundId( Integer roundId )
{
this.roundId = roundId;
}
public String getGroupCode()
{
return groupCode;
}
public void setGroupCode( String groupCode )
{
this.groupCode = groupCode;
}
public void loadEntity()
{
System.out.println( GroupHandler.class.getSimpleName() + ".loadEntity(): round ID = " + getRoundId() + ", group code = " + getGroupCode() );
}
}
QUESTION:
Why is this happening?
How do I get rid of this?
I'm using Mojarra 2.3.x, PrimeFaces 8, WildFly 14
来源:https://stackoverflow.com/questions/60673695/jsf-reloading-page-via-pbutton-using-includeviewparams-true-results-in-2c