URL parameter passing
Posted: 12 Feb 2013, 19:52
I'm not sure why this is not working, it seems straightforward. I've hard-coded the parameter I want to pass. I believe the problem is my @ManagedBean and mor importantly my @ManagedParameter is not finding or sync'd up with the <f:param in proauth.xhtml.
When I debug this, I get to the backing bean, but userid is null, even with XBBBB being hard-coded in the proauth.xhtml code.
I've increased the size of that code.
I'm calling http://....index.jsp
index.jsp (actually hard coding the parameter)
<jsp:forward page="proauth.xhtml?userid=XBBBB"></jsp:forward>
proauth.xhtml (here instead of trying to get the param from the http request, I'm hard-coding it also)
<!DOCTYPE xhtml>
<html 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"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<link rel="stylesheet" type="text/css" href="themes/local/tinstyle.css"/>
</h:head>
<script type="text/javascript">
function doSubmit() {
document.getElementById('proAuthForm:proAuthBtn').click();
}
</script>
<h:body onload="doSubmit()">
<h:form id="proAuthForm">
<f:param name="userid" value="XBBBB" />[/b]
<p:commandButton id="proAuthBtn" value="" action="#{profileAuthorizationBean.doProfileAuth}" ajax="false" />
</h:form>
</h:body>
</html>
Java backing bean (fragment
@ManagedProperty(value="#{userid}")
private String userid;
/**
* <dl>
* <dt><b>Actions</b></dt>
* <ul>
*
* <li>Grabs the User ID and uses it to retriev the user profile.</li>
* <li>Elements of the user profile are then used to obtain the authorization for this user</li>
* <li>Authorized users are sent to the landing page</li>
* <li>Unauthorized user are sent to an error page</li>
*
* @return next page
*/
public String doProfileAuth() {
String retValue = "landingPage";
try {
//HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
//System.out.println(request.getParameter("UserID"));
When I debug this, I get to the backing bean, but userid is null, even with XBBBB being hard-coded in the proauth.xhtml code.
I've increased the size of that code.
I'm calling http://....index.jsp
index.jsp (actually hard coding the parameter)
<jsp:forward page="proauth.xhtml?userid=XBBBB"></jsp:forward>
proauth.xhtml (here instead of trying to get the param from the http request, I'm hard-coding it also)
<!DOCTYPE xhtml>
<html 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"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<link rel="stylesheet" type="text/css" href="themes/local/tinstyle.css"/>
</h:head>
<script type="text/javascript">
function doSubmit() {
document.getElementById('proAuthForm:proAuthBtn').click();
}
</script>
<h:body onload="doSubmit()">
<h:form id="proAuthForm">
<f:param name="userid" value="XBBBB" />[/b]
<p:commandButton id="proAuthBtn" value="" action="#{profileAuthorizationBean.doProfileAuth}" ajax="false" />
</h:form>
</h:body>
</html>
Java backing bean (fragment
@ManagedProperty(value="#{userid}")
private String userid;
/**
* <dl>
* <dt><b>Actions</b></dt>
* <ul>
*
* <li>Grabs the User ID and uses it to retriev the user profile.</li>
* <li>Elements of the user profile are then used to obtain the authorization for this user</li>
* <li>Authorized users are sent to the landing page</li>
* <li>Unauthorized user are sent to an error page</li>
*
* @return next page
*/
public String doProfileAuth() {
String retValue = "landingPage";
try {
//HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
//System.out.println(request.getParameter("UserID"));