This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply 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: 14491
    
    7

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: 14491
    
    7

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://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: problem by getting values from h:form
 
Similar Threads
accessing input text field in controller class
I am unable to find error in this program.
Java Script Reference to JSF components
Exception during addition of data from UI
Target Unreachable, identifier resolved to null (JSF 2.0)