URL parameter passing

UI Components for JSF
Post Reply
DougMH
Posts: 30
Joined: 11 Nov 2012, 04:03

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"));
Windows 8.1
JSF 2.2 (Mojarra 2.2.6)
primefaces-4.0.9.jar
sunny-1.0.10.jar

DougMH
Posts: 30
Joined: 11 Nov 2012, 04:03

12 Feb 2013, 21:57

I think I've actually come a bit closer to this:

index.jsp (actually hard coding the parameter)

<jsp:forward page="proauth.xhtml?userid=XBBBB">
<jsp:param name="userid" value="XBBBB" />
</jsp:forward>

<!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">
<p:commandButton id="proAuthBtn" value="" action="#{profileAuthorizationBean.doProfileAuth}" ajax="false">

<f:param name="userid" value="XBBBB" />
<f:param name="userid" value="#{request.parameter.userid}" />
<f:param name="userid" value="#{parameter.userid}" />

</p:commandButton>
</h:form>
</h:body>
</html>

In my backing bean, if I use the line that is in bold and in italics, I see XBBBB as the value for userid if I get the HttpServletRequest parameterMap

If I use the line that underlined, I get an error saying it doesn't understand request.parameter.userid

If I use the f:param line below those two, I don't get any errors going to my backing bean, but nothing is getting passed.

I simply don't think my parameter from the .jsp file is making it to the .xhtml file, but I can't figure out why.
Windows 8.1
JSF 2.2 (Mojarra 2.2.6)
primefaces-4.0.9.jar
sunny-1.0.10.jar

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 17 guests