This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes JSF and the fly likes handling cancel action effectively Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSF
Reply Bookmark "handling cancel action effectively" Watch "handling cancel action effectively" New topic
Author

handling cancel action effectively

Joshua Antony
Ranch Hand

Joined: Jun 05, 2006
Posts: 254
I have a situation in which there is an input text and a submit and cancel button.

The input text value is associated with a backing bean property.

Suppose the user enters any value and clicks cancel, the same page is displayed with the input text in view mode(not editable)

The problem is that since we are re-displaying the page the backing bean has been associated with the value that was set when the user entered the value in input text and hence the same value is displayed.

I am currently using 2 properties in the backing bean and doing some manipulations to overcome this issue.

Is there any better way around?

Regards,
Joshua


SCJP,SCWCD, Into ATG now!
Venkat Sadasivam
Ranch Hand

Joined: May 10, 2008
Posts: 139
Add immediate="true" attribute for your Cancel button.

Create a navigation rule for your Cancel button action which points to the same page.


“Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ”<br>
-Martin Fowler
Joshua Antony
Ranch Hand

Joined: Jun 05, 2006
Posts: 254
Thanks Venkat,

But now I am facing another problem, when I am redisplaying the same page the value in the text field is not getting changed(it is having the value that was entered before cancel button was clicked)

I am not able to understand this behaviour, since I guess due to immediate=true the model values would not have been updated and hence the property of the backing bean which is associated with the input text should not have been updated and should have displayed value of the property in the input text.

But the text entered before cancel action is getting displayed.

Regards,
Joshua
Praveen Palani
Greenhorn

Joined: Jul 03, 2008
Posts: 2
iam a newbie and guess it worx

change
<managed-bean-scope>session</managed-bean-scope>
to
<managed-bean-scope>request</managed-bean-scope>
in the faces-config.xml file.
Venkat Sadasivam
Ranch Hand

Joined: May 10, 2008
Posts: 139
Also you need navigation rule defined. If there is no validation after cancel button action, bean update phase will get executed.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: handling cancel action effectively
 
Similar Threads
Custom tag use in <h:dataTable>
Problem with Inputtext renderer
Page not getting submitted if my text box is not part of backing bean...
Validation Problem ... again!
CRUD approach