• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Saving form without validation

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Recently I have been working on a multi-page form (wizard) for internet users. One of the requirements is the necessity to save data already entered within the form so that a user can come back to it later. Is there a way to submit the data and ensure it is not validated when the save button is hit? In essence, I would like the validation phase skipped when selecting the save button but not skipped when the Submit button is selected?

Regards

Matt
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
immediate="true" but you will not be able to read any of the input fields this is good if you are going to open a popup or go to another div
 
author
Posts: 82
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Mr. Gaunt, thanks for your question. This is a tough one because the validation guarantee is one of the bulwark principles of JSF security. Nonetheless, your use case is a valid one (ha!).

I haven't yet done this myself, but with the new @FacesComponent annotation and the composite component features it's very easy to do so. Here's a sketch. When I have more time I'll flesh it out in a blog entry.

Make a composite component, the tag for which is, say my:bypassValidation. For this component, make a custom top level component: (use the @FacesComponent annotation on a java class that extends from UINamingContainer, then use the componentType attribute on the cc:interface composite component tag. The value of the annotation an the right hand side of componentType must match.

In the custom top level component with the @FacesComponent annotation, override the processValidations method to take a look at piece of state (probably not a query parameter, for security reasons) and simply be a no-op or call super.processValidations() depending on the value of the state.

That should do the trick.

Ed
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

We have tried to implement your suggestion without any success.
Here is another approach, may be simpler
http://www.springfuse.com/2011/12/15/skip-jsf-validation-depending-on-action.html

It would be a real plus to provide this natively in JSF. An attribute on commandButton such as skipValidationFor="xxx" where xxx could be '@all' or a list of ids, would be so convenient.
With all my respect, I think it is not up to the framework to prevent certain usage. In the end, people either choose another framework or loose some precious time elaborating workarounds.

Sincerely,

Nicolas.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic