I am trying to migrate an application from RichFaces to PrimeFaces 5.0 and upgrade JSF 1.2 to JSF 2.2. Earlier we had .jsp
pages which contained below piece of code.
<%
FacesContext fc = FacesContext.getCurrentInstance();
Login login = (Login) fc.getELContext().getELResolver().getValue(fc.getELContext(), null, "login");
if (null == login.getEmailAddress()) {
response.sendRedirect("./");
}
%>
Now we changed every .jsp
page to .xhtml
and as expected the above piece of code would not fit in the xhtml view. I tried searching replacement for the above functionality in view but unfortunately could not find anything regarding same. I also tried to put the above line of code within <!CDATA
, [not sure whether its a right way], as below:
<![CDATA[
<%
FacesContext fc = FacesContext.getCurrentInstance();
Login login = (Login)fc.getELContext().getELResolver().getValue(fc.getELContext(), null, "login");
if (null == login.getEmailAddress()) {
response.sendRedirect("./");
}
%>
]]>
and as expected that didn't even work well.
How else I would be able to achieve this within xhtml
? Will this be possible or should I be going for some other way to do this?
Note - The application is a Single Page Application