File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Backing Bean query

 
zaxxon25
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a screen in which all values being dislayed are stored in java backing bean.
i have to code particular functionality under which whenever a person cliks OK button at end of screen a call needs to be made to server to compare current values on screen with stored value in backing beans. If values are different an alert is sent to user informing him that values have changed. If he opts yes then new values are retained and old values lost.
The new values will also be stored in same bean. Can any one using some sample code explain me how this can be done .....

In summary how can i use my form bean's same field to store different values on each form submission and also retain old values for comparision purpose....
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no silver bullet that I am aware of for doing this. You'll just need to store old values in session (most likely) and then compare the new values coming in off the request to the session values. Replacing values in both scopes when necessary.
 
Rick Beaver
Ranch Hand
Posts: 464
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can write a custom validator that will read the new values off the request, and compare them against the values in the backing bean.

Remember, your new values will not overwrite the old values until after validation.

Something like this for a String value (if you are using non-String values you will need to convert your request value to the correct type:



Now you want to do a confirm and then proper submit, to do this you can set a backing bean boolean to true on the first submit and check for it in the validator - if they that value is true you know this is the second submit (the confirm) and you can ignore the validation.
 
zaxxon25
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
will using valuechangeListener work ....something like this ....

JSF
<h:inputText valueChangeListener="#{myBean.inputListener}" />



MyBean
public void inputListener(ValueChangeEvent event) {
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
// do your thing
}
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic