Two Laptop Bag*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 15951
    
  19

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: 15951
    
  19

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: f:setPropertyActionListener can not set value
 
Similar Threads
Disabling a cell in Datagrid
Unable to populate values obtained from ajax call using PrimeFaces
Can't set invisible border for Table inside P:dataTable.
DataTable Sortby does not work
Navigating page links with parameters