Immediate Action and page fragment refresh

I have a problem and do not know how to get arround it.

Lets say I have a page (A.jsp) including a page fragment (B.jspf) with an input field (lastname). Lastname is bound to a variable in the SessionBean. The page also has a cancel button.

The idea of the page is that the user can modify data, but if he does not like his current changes, he presses the cancel button and the original data is beeing displayed again.

So in the action listener for the cancel button I reload the data from the database and update the lastname variable in the sesion bean, then return null to redisplay the page.

public String cancel_button_action(){

getSessionBean1().refreshPerson();

returnnull;

}

That works basically as expected. When I press the cancel button, the visible data is beeing completely refreshed.

Now the problem starts if I set the "Immediate Action" property for the cancel button. If I press the cancel button now the fields are still showing the partly modified data which I entered before pressing the cancel button.

The reason for setting the immediate action property is because some fields in the page fragment have validators in place and I do not want them to fire messages if I want to refresh the page.

So my question is, is this a known problem or a feature and how can I get arround it?

Thanks,

Ulf

[1551 byte] By [uschenk@fastobjects.com] at [2007-11-26 11:31:33]
# 1

What about sending the original values along as JavaScript variables, and have the button execute some JavaScript that restores the original values (and then returns false, preventing the form from being submitted)?

That way, your validators are not called, because the browser does submit the form.

jnawk at 2007-7-7 3:47:16 > top of Java-index,Development Tools,Java Tools...
# 2
jnawk,thanks for the answer. But I use a framework to just get relieve from such pain, like writing javascript code to update fields manually.I believe there has to be an easier way to solve this...~Ulf
uschenk@fastobjectscom at 2007-7-7 3:47:16 > top of Java-index,Development Tools,Java Tools...
# 3
Hi!You can use virtual forms for this purpose. You can read about it here: http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/vir tual_form.htmlThanks,Roman.
Grif at 2007-7-7 3:47:16 > top of Java-index,Development Tools,Java Tools...