I have the following page:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:o="http://omnifaces.org/ui" xmlns:thehub="http://java.sun.com/jsf/composite/components/thehub" template="/templates/masterTemplate.xhtml"> <f:metadata> <f:viewParam id="returnToViewParam" name="returnTo" value="#{loginMB.returnTo}" required="true" /> <f:viewParam id="oauth_verifierViewParam" name="oauth_verifier" value="#{loginMB.oauth_verifier}" /> <f:viewParam id="oauth_tokenViewParam" name="oauth_token" value="#{loginMB.oauth_token}" /> <f:event type="preRenderView" listener="#{loginMB.preRenderView()}" /> </f:metadata> <ui:define name="body"> <o:form id="loginForm" includeViewParams="true"> <div class="form-vertical well"> <h4>New Users</h4> <h5> <h:link outcome="signup">Click here to create an account</h:link> </h5> <hr /> <h4>Existing Users</h4> <h:commandButton id="googleLoginCommandLink" styleClass="btn" action="#{loginMB.redirect()}" value="Google"> <f:param name="returnTo" value="#{param.returnTo}" /> </h:commandButton> <div class="clearfix"></div> </div> </o:form> </ui:define> </ui:composition>
And the following bean:
@ManagedBean @RequestScoped public class LoginMB implements Serializable { private static final long serialVersionUID = 1L; private String returnTo; public void redirect() { log.debug("redirect() returnTo:{}", returnTo); ......getter/setters }
No matter what I do, I cannot get returnTo bound after pressing the commandButton button. Since this is a login page, I would not want LoginMB to be @ViewScoped bean.
Tips? Is there a better way to handle this scenario?
EDIT:
- I run this on TomEE + Server v1.5.1 which is served by MyFaces 2.1.10
- Full page added
- Clarified Problem: inside
redirect() function returnTo is null
source share