Nargzul
asked on
retrieve GET parameter in a request bean
Hi!
I have a page accessed by a link into an email.
How can I retrieve a GET parameter from my Request Bean?
Thank you!
(I use JSF/JSP under a glassfish server with netbeans)
I have a page accessed by a link into an email.
How can I retrieve a GET parameter from my Request Bean?
Thank you!
(I use JSF/JSP under a glassfish server with netbeans)
Why not store it in the request map and have your bean access that?
ASKER
I'm sorry, I don't understand what you mean.
request map == face-config?
The url in the email will be something lik
http://myWebSite.com/MyPage.jsf?idDeal=3517&authKey=341AFE80CFB419750D
I want to have a direct access to this page.
request map == face-config?
The url in the email will be something lik
http://myWebSite.com/MyPage.jsf?idDeal=3517&authKey=341AFE80CFB419750D
I want to have a direct access to this page.
>>request map == face-config?
request.setAttribute("x", y);
request.setAttribute("x", y);
ASKER
>>request.setAttribute("x" , y);
How do we get this object?
Email are in a mail, I don't think it works and they aren't sent from the same server(and it's not a J2EE server).
How do we get this object?
Email are in a mail, I don't think it works and they aren't sent from the same server(and it's not a J2EE server).
ASKER
You don't really help here...
When must I use this?
What do I write in the email?
Is this really done for JSP/JSF?(because I see always "servlet" in the javadoc)
How do I get this ExternalContext?
Why is it so complicated???
It's just amazing, I only want to retrieve a Get variable. In php it's only a $_GET['my_var_name'], in .NET it's only a Request.QueryString("param eter1")
When must I use this?
What do I write in the email?
Is this really done for JSP/JSF?(because I see always "servlet" in the javadoc)
How do I get this ExternalContext?
Why is it so complicated???
It's just amazing, I only want to retrieve a Get variable. In php it's only a $_GET['my_var_name'], in .NET it's only a Request.QueryString("param
The difference is you're using multi-layered technologies. PHP is shallow in comparision. Exactly what layer of your app are you in? If you have access to the request object, then of course it's equally easy
ASKER
Theses layer must simplify the development no?
I'm in a Bean with a Request scope, in a getter of one attribut of my bean.
I'm in a Bean with a Request scope, in a getter of one attribut of my bean.
>>Theses layer must simplify the development no?
No, that's not the objective. They actually make it more complex. The objective is to increase reusability and scalability
A bean is not meant to have circular references to the request, hence your problem. You would be better to rethink the design, but a kludge would be to pass the request into the bean
No, that's not the objective. They actually make it more complex. The objective is to increase reusability and scalability
A bean is not meant to have circular references to the request, hence your problem. You would be better to rethink the design, but a kludge would be to pass the request into the bean
ASKER
But say me how I can do it differently?
I need to have:
-a link from an email
-can load an object corresponding to the given ID in my RequestBean
I need to have:
-a link from an email
-can load an object corresponding to the given ID in my RequestBean
So the user clicks on a link in an email?
>>can load an object corresponding to the given ID in my RequestBean
What object?
>>can load an object corresponding to the given ID in my RequestBean
What object?
ASKER
It's an Entity object, I've a facade(session bean) to load it
@EJB
private MatchFacadeRemote matchfac;
public Match getMatchToReview() {
if(matchToReview == null){
int idMatch = xxxxxx;//here we get this object
matchToReview = matchfac.find(idMatch);
}
return matchToReview;
}
What is the first thing that gets hit when the user clicks on the link in the email? Do you have jsp, servlet or what?
ASKER
It's a JSP page
ASKER
Yeah it's an email, it was specified in the first message ;)
In that case it would be e.g.
String authKey = request.getParameter("authKey");
ASKER
I've try but I don't have this request var
That's *always* present in a jsp
ASKER
I'm confuse, I've responded to fast to your question, I've only JSF pages
In that case we're back with http:#24905473
See http://www.java-samples.com/showtutorial.php?tutorialid=474
See http://www.java-samples.com/showtutorial.php?tutorialid=474
ASKER
I've tried to create an ExternalContext, but it's an abstract class.
I've created a FaceContext, but there isn't any getRequestMap on this method.
I've check there isn't any :
get***Map() on the ExternalContext
I've created a FaceContext, but there isn't any getRequestMap on this method.
I've check there isn't any :
get***Map() on the ExternalContext
You need to read the link i posted to you - it tells you exactly what to do
ASKER
Okay,
So I've try to do mixes, but when I call the page like this:
http://localhost:8080/TrustBN-war/faces/ReviewExchange.jsp?idReview=120938120839
I get a null in my code
So I've try to do mixes, but when I call the page like this:
http://localhost:8080/TrustBN-war/faces/ReviewExchange.jsp?idReview=120938120839
I get a null in my code
FacesContext context = FacesContext.getCurrentInstance();
String idReview = (String)context.getExternalContext().getRequestMap().get("idReview");
System.out.println(idReview);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yeah it works
Thank you sooo much!
Thank you sooo much!
:-)