• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

f:setPropertyActionListener can not set value

 
ihsan kocak
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all.i am trying to set value of my backingbeans property via but it does not set the valu.it is surprising that i have initialized this property in the class but when i pushed the command link, it is set to null and gives null pointer exception.do you have any idea what is wrong?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that you are trying to do an awful lot of work that you do not have to do.

Under normal processing, JSF will automatically set any property values that were associated with controls on a JSF form. JSF will have validated these values and updated the backing beans automatically when the form was submitted and then JSF will invoke the action method.

Listeners are functions that are invoked as part of the form submit when an activity of interest occurs and are not intended to be used to set property values. In most cases, doing so will interfere with the normal JSF processing cycle with possibly unpredictable results.
 
ihsan kocak
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:I think that you are trying to do an awful lot of work that you do not have to do.

Under normal processing, JSF will automatically set any property values that were associated with controls on a JSF form. JSF will have validated these values and updated the backing beans automatically when the form was submitted and then JSF will invoke the action method.

Listeners are functions that are invoked as part of the form submit when an activity of interest occurs and are not intended to be used to set property values. In most cases, doing so will interfere with the normal JSF processing cycle with possibly unpredictable results.


so instead of setting values like this what should i do?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the point. Input controls with "value=" attributes are automatically updated when the form containing them is submitted. Since the form submit is only accepted when all input values are valid, the action method for the form is ensured that the new values are updated and valid. You don't have to code anything.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic