This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes problem by getting values from h:form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "problem by getting values from h:form" Watch "problem by getting values from h:form" New topic
Author

problem by getting values from h:form

Chrigi Pfister
Greenhorn

Joined: Jan 17, 2008
Posts: 6
i'll make it short:

i have this jsp with a form:



now i'm trying to get for example the username like this:

this.getFacesContext().getExternalContext().getRequestParameterMap().get("registration:scriptCollector1:form:username");
i just get null.

with this call i get an array with all the parameters from the form.
this.getFacesContext().getExternalContext().getRequestParameterMap().values().toArray();
[ January 17, 2008: Message edited by: Chrigi Pfister ]
Chrigi Pfister
Greenhorn

Joined: Jan 17, 2008
Posts: 6
got it!

this.getFacesContext().getExternalContext().getRequestParameterMap().get("subview1:registration:form:username");
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15962
    
  19

I hope there was a good reason for all this. If you'd just mapped the properties of a backing bean to the form, the'y be pushed into the bean via its property setters automatically and you wouldn't have had to code arcane JSF service calls. Or, for that matter, any calls at all.


Customer surveys are for companies who didn't pay proper attention to begin with.
Chrigi Pfister
Greenhorn

Joined: Jan 17, 2008
Posts: 6
no, there was no good reason ;-)

i was not aware of the possibilities with JSF, now i know better.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15962
    
  19

Here's a good rule for JSF:

Any JSF problem that results in a complex solution probably has a much cleaner and simpler one.

And its corollary:

The best JSF code is code that doesn't include any explicit JSF references in it at all.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem by getting values from h:form
 
Similar Threads
accessing input text field in controller class
Target Unreachable, identifier resolved to null (JSF 2.0)
I am unable to find error in this program.
Java Script Reference to JSF components
Exception during addition of data from UI