Forums Register Login

How to compare bean values.

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Thanks Tim.
Can you smell this for me? I think this tiny ad smells like blueberry pie!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1701 times.
Similar Threads
Need advice for converting this page to JSF
Wrapping long text using h:outputText
scopes
Dependency Injection, can it solve my problem
Displaying h:columns in different rows
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:01:06.