• Post Reply Bookmark Topic Watch Topic
  • New Topic

handling cancel action effectively  RSS feed

 
Joshua Antony
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Venkat Sadasivam
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add immediate="true" attribute for your Cancel button.

Create a navigation rule for your Cancel button action which points to the same page.
 
Joshua Antony
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also you need navigation rule defined. If there is no validation after cancel button action, bean update phase will get executed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!