0 Replies Latest reply on Nov 12, 2010 12:41 PM by paul.dijou

    Navigation validation



      I am trying to make a CRUD using Seam-gen. So, in my entity list, for each row, I have s:button which have the entity Id as param and redirect to the edit page. Everything works fine. But, there is the problem of an user editing the url and trying to edit an entity that perhaps doesn't exist. So, I need to check if the Id is valid or not before rendering the page. I want to do that as describe in chapter 3.4.1 of Seam in action, using pages.xml. Here is my navigation :

      <page view-id="/pages/identification/permissionEdit.xhtml">
           <action execute="#{permissionQuery.valid}"/>
             <navigation from-action="#{permissionQuery.valid}">
                 <rule if-outcome="invalid">
                     <redirect view-id="/pages/identification/permissionsList.xhtml">
                         <message severity="WARN">Invalid Id.</message>

      And permissionQuery.valid() method :

      public String valid()
           return "valid";

      (yeah, just for the test). If I change the method and return invalid, it works fine. But if it returns valid, like in the example, a 404 error occurs :

      Etat HTTP 404 - /Reaction/pages/identification/valid.seam

      If the method return validBis, it will be :

      Etat HTTP 404 - /Reaction/pages/identification/validBis.seam

      As I can see, if a navigation case is referring to from-action and have no rule that match the return result of the method, it will try to render /classpath/myReturnResult.seam page, which of course doesn't exist. Is it normal or not ?

      I can avoid the problem by adding :

      <render view-id="/pages/identification/permissionEdit.xhtml">

      after the closing rule tag. But I don't want this because it will render the page and, in consequence, hide all modal panel. So, if I use an a4j:commandButton to show a modal panel, it will submit informations, and so execute the valid method and render the page, meaning hiding the modal panel... I just want to make the redirect if the Id is invalid and do nothing special if the Id is valid.

      Thanks if you can solve the problem,