jsf flash.keep and redirects does not seem to work
- by user384706
Hi,
I am trying to use JSF 2.0 flash via redirects.
I have a class named UserBean (ManagedScoped and RequestScoped).
It has a method called getValuesFromFlash which essentially gets the values from the flash
and sets the coresponding properties of the UserBean
public void getValuesFromFlash() {
Flash flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();
firstName= (String) flash.get("firstName");
lastName = (String) flash.get("lastName");
}
In the entry page the <h:inputText> are bound to the flash.
Snippet follows:
Entry.xhtml
<h:form>
<table>
<tr>
<td>First Name:</td>
<td>
<h:inputText id="fname" value="#{flash.firstName}"
required="true"/>
<h:message for="fname" />
</td>
</tr>
<tr>
<td>Last Name:</td>
<td>
<h:inputText id="lname" value="#{flash.lastName}" required="true"/>
<h:message for="lname" />
</td>
</tr>
</table
<p><h:commandButton value="Submit" action="confirmation?faces-redirect=true" /></p>
</h:form>
In confirmation.xhtml these values are supposed to be displayed but they are not.
Snippet follows:
<table>
<tr>
<td>First Name:</td>
<td>
<h:outputText value="#{flash.keep.firstName}" />
</td>
</tr>
<tr>
<td>Last Name:</td>
<td>
<h:outputText value="#{flash.keep.lastName}"/>
</td>
</tr>
</table>
<h:form>
<p><h:commandButton value="Confirm" action="finished?faces-redirect=true" /></p>
</h:form>
In finished.xhtml I want all these to be displayed so:
<h:body>
<h:form>
#{userBean.getValuesFromFlash( )}
<table>
<tr>
<td>First Name:</td>
<td>
<h:outputText value="#{userBean.firstName}" />
</td>
</tr>
<tr>
<td>Last Name:</td>
<td>
<h:outputText value="#{userBean.lastName}"/>
</td>
</tr>
</table>
</h:form>
</h:body>
Instead when I get redirected to confirmation.xhtml neither first nor last name is displayed, despite I used flash.keep
Also in finished.xhtml I get
org.apache.el.parser.ParseException:
Encountered " "(" "( "" at line 1,
column 30. Was expecting one of: "}"
... "."
If I remove the parenthesis from the expression #{userBean.getValuesFromFlash( )} and make it = #{userBean.getValuesFromFlash}
javax.el.ELException: /done.xhtml:
Property 'getValuesFromFlash' not
found on type com.UserBean
But why no property??It is a method! Why is the method not visible?
What I am doing wrong here please?
I am using JSF2.0 (MyFaces), Eclipse Helios and Tomcat 6 (Have also tried in Tomcat 7 but no luck).
Any help is appreciated.
Thanks!