2 Replies Latest reply on May 28, 2007 8:48 PM by blackers

    Validation in Restful mode

    blackers

      I have an action that is called from a form on another site and am using the restful mode. I have an action called from pages.xml. The issue I have is that using this method my validation does not get called, is there a way that the hibernate validation (annotations in my entity bean) can be called so that the action will only be called if validation succeeds. If I have the parameter

      if="#{validation.succeeded}"

      set in the action element my restful post will not work, if I remove the parameter then the action is called, but my validations are not being called. Is there a way that I can get it to work in a restful application? It works fine if the form is submitted from the subscribe.seam action.


      <page view-id="/subscribe.xhtml" >
       <param name="subscribe:title" value="#{subscription.title}"/>
       <param name="subscribe:firstName" value="#{subscription.firstName}"/>
       <param name="subscribe:lastName" value="#{subscription.lastName}"/>
       <param name="subscribe:country" value="#{subscription.country}"/>
       <param name="subscribe:postcode" value="#{subscription.postcode}"/>
       <param name="subscribe:email" value="#{subscription.email}"/>
       <param name="subscribe:confirmEmail" value="#{subscription.confirmEmail}"/>
      
       <action execute="#{subscriber.subscribe}" if="#{validation.succeeded}"/>
      
       <navigation from-action="#{subscriber.subscribe}">
       <redirect view-id="/subscribeConfirm.xhtml"/>
       </navigation>
      
       </page>


        • 1. Re: Validation in Restful mode
          gavin.king

          Currently Seam has no validation for page parameters, but I agree that it would be a very-nice-to-have, and easy to implement. So my question really is: exactly what should actually *happen* when page parameter validation fails?? It's not like we can redisplay the form with error messages ;-)

          Options:

          * set validation.succeeded to false (allowing you to skip the page action) and add the validation messages to the page?
          * add the validation messages to the page and then redirect to some view-id defined in pages.xml?
          * throw an exception that you can handle in pages.xml?

          I can see good arguments for each one...

          Please create an issue in JIRA for this, and let's kick off discussion in this thread - I really don't know what is the best option....

          • 2. Re: Validation in Restful mode
            blackers

            The way I would like to use this feature would be option 1. I have a page living on a separate site that would have its form posting to my seam page. If the validation fails it would be nice to add the validation messages to the page where the form can be fixed up and submitted again from within my site. However I can see merits in the other options and it would be interesting to see what others think.