2

I have xhtml form with two buttons: "OK" and "Cancel". Both buttons calls methods of @ViewScoped managed bean (accept() and cancel(), for example). Moreover, xhtml has viewParam and some validation.

In the managedBean state controlled by boolean variable edit. Method cancel turns edit variable to false.

The question is: how can I call cancel() method of managedBean without validation step? Say, I pressed "New record" button and change my mind. Now I want to cancel edit operation and when I push "Cancel" button - validation error appears, but managedBean changes state to browse (variable edit turns to false). The only I need - is to hide validation error message, or skip validation phase during POST request. If I use GET request, I am afraid that viewParam get lost, because view will be updated.

Is any way to skip validation phase in JSF?

Thank you for wasting your time.

gooamoko
  • 658
  • 12
  • 32
  • Maybe you want to use the `immediate` attribute? http://2.bp.blogspot.com/-txWIIU0O_vM/Ujk6Hu2mYmI/AAAAAAAAAEI/ocaRisuNkv8/s1600/JSf+LifeCycle.png. Note that, IIRC, the values **are** applied, so in the HTML form you will see the values that you wrote (if you wrote `foo` in a date field, no error will be raised but you will have `foo` again written in that field). – SJuan76 Aug 03 '15 at 08:17

1 Answers1

1

If I use GET request, I am afraid that viewParam get lost, because view will be updated.

Performing a full page refresh using GET is the right way (provided that you've a @ViewScoped bean). To cover the mentioned problem, just tell <h:link> or <h:button> in question to include view params.

<h:button value="Cancel" includeViewParams="true" />

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555