3 Replies Latest reply on Aug 27, 2009 10:01 PM by yyq2009

    A4J:Form and Navigation-Rule problem

    karam

      Hi,
      i use
      <a4j:form ajaxsubmit="true"> for a login Panel.

      My Problem:

      See Pic 1
      http://www.db-itech.de/pic1.jpg

      If i click there to Mitglied werden my navigation-rule works perfect.

      But if i click to Einloggen ( see Pic2 )
      http://www.db-itech.de/pic2.jpg

      and then to ausloggen ( see Pic 3 ) then the navigation-rule doesn't work.
      [img]
      http://www.db-itech.de/pic3.jpg
      [/img]


      My JSF for the Login Panel

      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
      <rich:panel id="loginPanel">
       <f:facet name="header">
       <h:outputText value="Login" />
       </f:facet>
       <h:panelGrid id="login" width="100%">
       <h:panelGroup rendered="#{loginBean.userOnline}">
       <h:panelGrid width="100%">
       <h:panelGroup>
       <h:panelGrid width="100%">
       <h:form id="test2">
       <h:commandLink value="Mein Postfach" action="goToMessages" styleClass="commandLink"/>
       </h:form>
       <rich:separator width="100%"/>
       <a4j:commandLink value="Mein Profil" styleClass="commandLink"/>
       <rich:separator width="100%"/>
       <a4j:commandLink value="Meine Kontakte" styleClass="commandLink"/>
       <rich:separator width="100%"/>
       <rich:spacer width="1" height="10" />
       <a4j:form reRender="loginPanel" ajaxSubmit="true" id="logoutA4JForm">
       <h:commandButton value="Ausloggen" styleClass="button">
       <a4j:support event="onclick" action="#{loginBean.logout}" />
       </h:commandButton>
       </a4j:form>
       </h:panelGrid>
       </h:panelGroup>
       </h:panelGrid>
       </h:panelGroup>
       <h:panelGroup rendered="#{!loginBean.userOnline}">
       <h:panelGrid width="100%">
       <h:panelGroup>
       <a4j:form reRender="loginPanel" ajaxSubmit="true" id="loginA4JForm">
       <h:panelGrid width="100%">
       <h:outputLabel id="loginNickname" value="Nickname" />
       <h:inputText label="loginNickname" value="#{loginBean.nickname}">
       </h:inputText>
       </h:panelGrid>
       <h:panelGrid width="100%">
       <h:outputLabel id="loginPassword" value="Passwort" />
       <h:inputSecret label="loginPassword" value="#{loginBean.password}">
       </h:inputSecret>
       </h:panelGrid>
       <rich:spacer width="1" height="10" />
       <h:panelGrid width="100%" >
       <h:commandButton value="Einloggen" styleClass="button">
       <a4j:support event="onclick" action="#{loginBean.login}" />
       </h:commandButton>
       </h:panelGrid>
       </a4j:form>
       <rich:spacer width="1" height="10" />
       <rich:separator width="100%"/>
       <h:panelGrid width="100%">
       <h:form id="test1">
       <h:commandLink value="Mitglied werden?" action="goToRegistration" styleClass="commandLink"/>
       </h:form>
       <rich:separator width="100%"/>
       <a4j:commandLink value="Passwort vergessen?" styleClass="commandLink"/>
       <rich:separator width="100%"/>
       </h:panelGrid>
      
       </h:panelGroup>
       </h:panelGrid>
       </h:panelGroup>
       </h:panelGrid>
      </rich:panel>
      
      
      



      My Navigation Rule on Faces-config

       <navigation-rule>
       <display-name>login</display-name>
       <from-view-id>*</from-view-id>
       <navigation-case>
       <from-outcome>goToRegistration</from-outcome>
       <to-view-id>/registration.jsp</to-view-id>
       <redirect />
       </navigation-case>
       </navigation-rule>
      



      if i don't use the ajaxsubmit="true" then it works....

        • 1. Re: A4J:Form and Navigation-Rule problem
          ilya_shaikovsky

          seems you should read more before continue just "playing with tags and attributes"...

          I'm not sure you really wanted next things to happens :

          1) The commandLink causes normal form submit and support inside causes additional parallel ajax request to be sent.
          1.1) the same for command button
          2) ajax form attribute you using - causes normal JSF links behave as a4j ones.. Why just not to use a4j:commandLink and not use this attribute. It was designed for special cases like ajax-ify some third party component which is not designed to work via ajax.
          3) some action components not wrapped with form.
          4) conditionally rendered components reRendering not allowed.

          • 2. Re: A4J:Form and Navigation-Rule problem
            karam

            hmmm ok, then i make a very small code.
            Can you say me what's there wrong?
            it's the same problem

            <rich:panel id="loginPanel">
             <f:facet name="header">
             <h:outputText value="Login" />
             </f:facet>
             <h:panelGrid id="login" width="100%">
            
             <h:panelGroup rendered="#{loginBean.userOnline}">
             <h:panelGrid width="100%">
             <h:form id="logoutA4JForm">
             <a4j:commandButton value="Ausloggen" action="#{loginBean.logout}" styleClass="button" reRender="loginPanel" />
             </h:form>
             </h:panelGrid>
             </h:panelGroup>
            
             <h:panelGroup rendered="#{!loginBean.userOnline}">
             <h:panelGrid width="100%">
             <h:panelGroup>
             <h:form id="loginA4JForm">
             <h:panelGrid width="100%" >
             <a4j:commandButton value="Einloggen" action="#{loginBean.login}" styleClass="button" reRender="loginPanel" />
             </h:panelGrid>
             </h:form>
             <h:panelGrid width="100%">
             <h:form id="test1">
             <h:commandLink value="Mitglied werden?" action="goToRegistration" styleClass="commandLink"/>
             </h:form>
             </h:panelGrid>
             </h:panelGroup>
             </h:panelGrid>
             </h:panelGroup>
            
             </h:panelGrid>
            </rich:panel>
            


            • 3. Re: A4J:Form and Navigation-Rule problem
              yyq2009

              Hi, if you add a navigation-rule to the page, it is no longer a ajax request and the whole page will be refreshed not the loginPanel which you want to refresh.