Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference Between JSF request and HttpServletRequest and how do you retreive parameters from them

 
Joe Richard
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am having a problem retreiving the values from my form submit.
I never have any of the input parameters come back.

Here is my code:



Here are the bean methods:



Any help would be greatly appreciated.
 
Guy deLyonesse
Ranch Hand
Posts: 200
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say you aren't getting the input parameters back, what do you mean? If I understand your code correctly you're trying to do a form submit when the selectOneMenu value changes. It seems to be the only input control on the form.

For JSF to do a form submit you need an ActionListener, usually triggered by a commandButton or commandLink control with a type="submit" attribute.

 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guy deLyonesse wrote:

For JSF to do a form submit you need an ActionListener, usually triggered by a commandButton or commandLink control with a type="submit" attribute.



Listeners are used too much in JSF. A simple action method is usually sufficient, simpler to code, and doesn't tie the backing bean as strongly to a particular technology. I think the whole listener thing came about because stale information has a remarkable way of hanging around the Internet forever. Listeners have their uses, but not as often as people think. I don't think I've ever done an ActionListener, for example, since the only real reason to would be to fire multiple methods from a single command.

The original post misses the point, however. It's an attempt to apply legacy design to an entire new paradigm. JSF is intended to allow people to be able to design a View, present it to the client, go through a series of postbacks until all submitted data in the form passes validation, then fire an Action to act on the submitted data. You don't retrieve data, it's presented to you. The more logic you code in JSF, the more likely you're doing it wrong. And the more times you explicitly reference classes in the javax.faces package tree - excepting the datamodel classes - the more likely you're doing it wrong.

JSF is designed to make things simple and easy, and the biggest problem with it is that too many people keep trying to make it not be simple and easy.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic