aspose file tools*
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 Spring in Action this week in the Spring 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: 16145
    
  21

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: 16145
    
  21

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem by getting values from h:form