File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes f:setPropertyActionListener can not set value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "f:setPropertyActionListener can not set value" Watch "f:setPropertyActionListener can not set value" New topic
Author

f:setPropertyActionListener can not set value

ihsan kocak
Ranch Hand

Joined: Mar 14, 2012
Posts: 31
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

Joined: Jun 25, 2001
Posts: 16058
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
ihsan kocak
Ranch Hand

Joined: Mar 14, 2012
Posts: 31
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

Joined: Jun 25, 2001
Posts: 16058
    
  21

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: f:setPropertyActionListener can not set value