This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to compare bean values.  RSS feed

 
Manohar Chhapolia
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I just started learning JSF.
I am displaying a page with some of the field and before submitting the page I change any of the field value. In my bean class, I want to check if the state of the bean is same or changed.
Though, I can do it by saving the whole bean in session before displaying it and compare it with bean attributes one by one after submission but I would like to know if JSF frame work provide anything to achieve this.

Thanks in advance.

Regards,
Manohar
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, but you can set a "dirty" flag inside the bean and have the property setters set it to true if the property value is changed, then reset it back to false when you've committed the changes (or whatever).

One advantage of that approach is that it doesn't require JSF to implement - it's all straight Java.

The disadvantage is that you have to add the extra logic yourself unless you're running the bean in some sort of Aspect-Oriented Programming context where the change detection can be implemented as a cross-cutting concern.
 
Manohar Chhapolia
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!