2 Replies Latest reply on Oct 28, 2009 2:06 PM by amayingenta

    Pageflow, Manual Validation and FacesMessages.addToControl

    amayingenta

      Hi, I'm trying to implement some manual validation for fields that can be null when an entity is saved, but are required when it is submitted for processing.
      I'm using pageflow for my form and I'm calling the validation from a decision expression - if it passes it goes to the next page, otherwise I want to stay on the current page.


      In my validation code I use FacesMessages.addToControlFromResourceBundle() and pass the component id (e.g. purpose). The Faces Messages are added globally rather than to the individual control.


      When I debug FacesMessages.getClientId() the View Root does not have any children and this appears to be why it can't find a matching component. Is this because this is called from a decision node?


      Here's some of the pageflow:


      <page name="edit" view-id="/purchase/edit.xhtml" redirect="true">
          <transition name="continue" to="validate"/>
      </page>
      
      <decision name="validate" expression="#{purchaseHome.isValid()}">
         <transition name="true" to="preview"/>
         <transition name="false" to="edit"/>
      </decision>



      Is there any way I can change the pageflow so that the validation will be called when the full page is available and it can find the client ids?
      Or will I have to use FacesContext.addMessage() using the full clientId (e.g. purchase:purposeField:purpose)?


      Thanks, Andrew