Pre-Loading data in managed bean
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Friday, September 11, 2009 03:15 PM

I am using a managed bean to load data for a form and also have a method in my managed bean for persisting the data. The managed bean properties are tied to my input field by using the value attribute. This all works well except that the data from the bean is NOT being preloaded on the page. When I step through with my debugger I see that the bean is loading it's data but prior to the "getter" methods being called, each of my "setter" methods is called with a blank value. I can work around this by initializing my bean through a fake property setter at the end of my property list and I've seen this approach recommended by a few people, but it seems wrong.    More>>

I am using a managed bean to load data for a form and also have a method in my managed bean for persisting the data.


The managed bean properties are tied to my input field by using the value attribute.




This all works well except that the data from the bean is NOT being preloaded on the page. When I step through with my debugger I see that the bean is loading it's data but prior to the "getter" methods being called, each of my "setter" methods is called with a blank value.


I can work around this by initializing my bean through a fake property setter at the end of my property list and I've seen this approach recommended by a few people, but it seems wrong.

My question is: why is it necessary for JSF to call managed bean "setter" methods when a page is loading? Shouldn't it only be calling the "getter" methods? Is there a way to stop it from calling a "setter"?

Thanks,
Matthew

   <<Less
About | Sitemap | Contact