2 Replies Latest reply on Feb 26, 2008 4:27 AM by Martin Ahrer

    AJAX request (for modal panel) , outcome and navigation rule

    Martin Ahrer Newbie

      I'm implementing a fairly simple page browser.jsp. This one is showing a list of objects that can be selected for being edited in a modal panel.

      It contains a panel offering some actions, one of them is creating a new object

      <a4j:form>
       <rich:panel id="actionPanel" rendered="#{controller.selectedObject.item != null}">
       <a4j:commandLink action="#{controller.newFolderItem}" reRender="formPanel" oncomplete="Richfaces.showModalPanel('editPanel')">
       <h:outputText value="New Folder"/>
       </a4j:commandLink>
       </rich:panel>
      </a4j:form>
      


      The called method is responsible for creating a new object instance and making if available through property editedObject. The issue is the return value of this method. It is the outcome that should indicate whether it failed or was successful.


      public String newFolderItem() {
       try {
       final FolderItem newInstance = getFolderItemClass().newInstance();
       setEditedObject(new FolderItemWrapper(newInstance));
       } catch (Exception e) {
       // TODO log
       return "fail";
       }
       return "success";
      }
      


      After creating the new object the modal panel should be displayed! This only works when returning a null from the action method newFolderItem. Returning a non-null value just does not display the modal panel.

      <rich:modalPanel id="editPanel">
       <a4j:form id="formPanel">
       <a4j:include viewId="/#{controller.editedObject.editorName == null ? 'blank' : controller.editedObject.editorName}.jsp"/>
       </a4j:form>
      </rich:modalPanel>


      The modal panel is including a JSP form that fits the type of the created instance.

      So now I need to know if I'm doing something terribly wrong that prevents the solution form working.
      I suspect that the problem lies within the navigation rules. So far I have only one rule that says just stay in this view!


      <navigation-rule>
       <from-view-id>/browser.jsp</from-view-id>
       <navigation-case>
       <to-view-id>/browser.jsp</to-view-id>
       </navigation-case>
      </navigation-rule>