6 Replies Latest reply on Apr 22, 2008 11:48 AM by dilsent

    Modal Panl Validation

    dilsent

      I have created a login screen using a Modal Panel and it works fine. But I wanted it to remain open until the validation is completed.I referred the wiki
      link
      http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4061517

      and tried uisng the javascript provided,but it doesn't seem to work.

      Here is the code

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:c="http://java.sun.com/jstl/core"
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:rich="http://richfaces.org/rich">



      <rich:toolBar>

      <rich:toolBarGroup location="right">






      function requestWindowClose(){

      if (document.getElementById('
      loginFormId:error'
      )==null){
      RichFaces.hideModalPanel('loginPanelGroupId');
      }
      }




      <a4j:repeat var="toolBarItem" value="#{appProfile.toolBar}">


      function mouseOver#{toolBarItem}( idVar )
      {
      idVar.src = "img/accordToolBar/#{toolBarItem}MouseOn.gif";
      }
      function mouseOut#{toolBarItem}( idVar )
      {
      /*if ( something == "true") */
      idVar.src = "img/accordToolBar/#{toolBarItem}On.gif"
      /* else
      idVar.src = "img/accordToolBar/#{toolBarItem}Off.gif" */
      }


      <s:button rendered="true" view="/#{toolBarItem}.xhtml"
      value="#{toolBarItem}"
      image="img/accordToolBar/#{toolBarItem}On.gif"
      onmouseover="mouseOver#{toolBarItem}"
      onmousemove="mouseOver#{toolBarItem}(this)"
      onmouseout="mouseOut#{toolBarItem}(this)" />
      <s:button rendered="false"
      image="img/accordToolBar/#{toolBarItem}Off.gif" disabled="true" />
      </a4j:repeat>

      <h:outputText id="menuWelcomeId"
      value="Welcome, #{agent.firstName} #{agent.lastName}"
      rendered="#{identity.loggedIn}" />

      <a4j:commandLink
      onclick="javascript:Richfaces.showModalPanel('loginPanelGroupId',{left:'auto', top:'auto'})">

      <h:outputText value="Login" rendered="#{not identity.loggedIn}" />

      </a4j:commandLink>

      <s:link id="menuLogoutId" view="/home.xhtml"
      action="#{identity.logout}" value="Logout"
      rendered="#{identity.loggedIn}" />

      </rich:toolBarGroup>
      </rich:toolBar>

      <rich:modalPanel id="loginPanelGroupId" width="300" height="190"
      resizeable="false">
      <f:facet name="header">
      <h:outputText value="Login"></h:outputText>

      </f:facet>
      <h:form id="loginFormId">
      <a4j:outputPanel ajaxRendered="true">
      <h:messages id="error"></h:messages>
      </a4j:outputPanel>
      Please login using any username and password
      <h:panelGrid id="loginPanelGridId"
      columns="2" rowClasses="prop" columnClasses="name,value">
      <h:outputLabel for="username">Username</h:outputLabel>
      <h:inputText id="username" value="#{identity.username}"
      required="true" />
      <h:outputLabel for="password">Password</h:outputLabel>
      <h:inputSecret id="password" value="#{identity.password}"
      required="true" />
      <h:outputLabel for="rememberMe">Remember me</h:outputLabel>
      <h:selectBooleanCheckbox id="rememberMe"
      value="#{identity.rememberMe}" />
      </h:panelGrid>
      <h:commandButton id="loginButtonId"
      value="Login" action="#{identity.login}"
      oncomplete="requestWindowClose();" reRender="Login" />

      </h:form>
      </rich:modalPanel>
      </ui:composition>

      Would appreciate any assistance to solve this issue

      Thanks in advance.

        • 1. Re: Modal Panl Validation
          dilsent

          Sorry, I missed to paste the script.Here is the complete code

          <ui:composition xmlns="http://www.w3.org/1999/xhtml"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:a4j="http://richfaces.org/a4j"
          xmlns:c="http://java.sun.com/jstl/core"
          xmlns:s="http://jboss.com/products/seam/taglib"
          xmlns:rich="http://richfaces.org/rich">



          <rich:toolBar>

          <rich:toolBarGroup location="right">






          function requestWindowClose(){

          if (document.getElementById('
          loginFormId:error'
          )==null){
          RichFaces.hideModalPanel('loginPanelGroupId');
          }
          }




          <a4j:repeat var="toolBarItem" value="#{appProfile.toolBar}">


          function mouseOver#{toolBarItem}( idVar )
          {
          idVar.src = "img/accordToolBar/#{toolBarItem}MouseOn.gif";
          }
          function mouseOut#{toolBarItem}( idVar )
          {
          /*if ( something == "true") */
          idVar.src = "img/accordToolBar/#{toolBarItem}On.gif"
          /* else
          idVar.src = "img/accordToolBar/#{toolBarItem}Off.gif" */
          }


          <s:button rendered="true" view="/#{toolBarItem}.xhtml"
          value="#{toolBarItem}"
          image="img/accordToolBar/#{toolBarItem}On.gif"
          onmouseover="mouseOver#{toolBarItem}"
          onmousemove="mouseOver#{toolBarItem}(this)"
          onmouseout="mouseOut#{toolBarItem}(this)" />
          <s:button rendered="false"
          image="img/accordToolBar/#{toolBarItem}Off.gif" disabled="true" />
          </a4j:repeat>

          <h:outputText id="menuWelcomeId"
          value="Welcome, #{agent.firstName} #{agent.lastName}"
          rendered="#{identity.loggedIn}" />

          <a4j:commandLink
          onclick="javascript:Richfaces.showModalPanel('loginPanelGroupId',{left:'auto', top:'auto'})">

          <h:outputText value="Login" rendered="#{not identity.loggedIn}" />

          </a4j:commandLink>

          <s:link id="menuLogoutId" view="/home.xhtml"
          action="#{identity.logout}" value="Logout"
          rendered="#{identity.loggedIn}" />

          </rich:toolBarGroup>
          </rich:toolBar>

          <rich:modalPanel id="loginPanelGroupId" width="300" height="190"
          resizeable="false">
          <f:facet name="header">
          <h:outputText value="Login"></h:outputText>

          </f:facet>
          <h:form id="loginFormId">
          <a4j:outputPanel ajaxRendered="true">
          <h:messages id="error"></h:messages>
          </a4j:outputPanel>
          Please login using any username and password
          <h:panelGrid id="loginPanelGridId"
          columns="2" rowClasses="prop" columnClasses="name,value">
          <h:outputLabel for="username">Username</h:outputLabel>
          <h:inputText id="username" value="#{identity.username}"
          required="true" />
          <h:outputLabel for="password">Password</h:outputLabel>
          <h:inputSecret id="password" value="#{identity.password}"
          required="true" />
          <h:outputLabel for="rememberMe">Remember me</h:outputLabel>
          <h:selectBooleanCheckbox id="rememberMe"
          value="#{identity.rememberMe}" />
          </h:panelGrid>
          <h:commandButton id="loginButtonId"
          value="Login" action="#{identity.login}"
          oncomplete="requestWindowClose();" reRender="Login" />

          </h:form>
          </rich:modalPanel>
          </ui:composition>

          • 2. Re: Modal Panl Validation
            dilsent

            Sorry, I missed to paste the script.Here is the complete code

            <ui:composition xmlns="http://www.w3.org/1999/xhtml"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:a4j="http://richfaces.org/a4j"
            xmlns:c="http://java.sun.com/jstl/core"
            xmlns:s="http://jboss.com/products/seam/taglib"
            xmlns:rich="http://richfaces.org/rich">



            <rich:toolBar>

            <rich:toolBarGroup location="right">






            function requestWindowClose(){

            if (document.getElementById('
            loginFormId:error'
            )==null){
            RichFaces.hideModalPanel('loginPanelGroupId');
            }
            }




            <a4j:repeat var="toolBarItem" value="#{appProfile.toolBar}">


            function mouseOver#{toolBarItem}( idVar )
            {
            idVar.src = "img/accordToolBar/#{toolBarItem}MouseOn.gif";
            }
            function mouseOut#{toolBarItem}( idVar )
            {
            /*if ( something == "true") */
            idVar.src = "img/accordToolBar/#{toolBarItem}On.gif"
            /* else
            idVar.src = "img/accordToolBar/#{toolBarItem}Off.gif" */
            }


            <s:button rendered="true" view="/#{toolBarItem}.xhtml"
            value="#{toolBarItem}"
            image="img/accordToolBar/#{toolBarItem}On.gif"
            onmouseover="mouseOver#{toolBarItem}"
            onmousemove="mouseOver#{toolBarItem}(this)"
            onmouseout="mouseOut#{toolBarItem}(this)" />
            <s:button rendered="false"
            image="img/accordToolBar/#{toolBarItem}Off.gif" disabled="true" />
            </a4j:repeat>

            <h:outputText id="menuWelcomeId"
            value="Welcome, #{agent.firstName} #{agent.lastName}"
            rendered="#{identity.loggedIn}" />

            <a4j:commandLink
            onclick="javascript:Richfaces.showModalPanel('loginPanelGroupId',{left:'auto', top:'auto'})">

            <h:outputText value="Login" rendered="#{not identity.loggedIn}" />

            </a4j:commandLink>

            <s:link id="menuLogoutId" view="/home.xhtml"
            action="#{identity.logout}" value="Logout"
            rendered="#{identity.loggedIn}" />

            </rich:toolBarGroup>
            </rich:toolBar>

            <rich:modalPanel id="loginPanelGroupId" width="300" height="190"
            resizeable="false">
            <f:facet name="header">
            <h:outputText value="Login"></h:outputText>

            </f:facet>
            <h:form id="loginFormId">
            <a4j:outputPanel ajaxRendered="true">
            <h:messages id="error"></h:messages>
            </a4j:outputPanel>
            Please login using any username and password
            <h:panelGrid id="loginPanelGridId"
            columns="2" rowClasses="prop" columnClasses="name,value">
            <h:outputLabel for="username">Username</h:outputLabel>
            <h:inputText id="username" value="#{identity.username}"
            required="true" />
            <h:outputLabel for="password">Password</h:outputLabel>
            <h:inputSecret id="password" value="#{identity.password}"
            required="true" />
            <h:outputLabel for="rememberMe">Remember me</h:outputLabel>
            <h:selectBooleanCheckbox id="rememberMe"
            value="#{identity.rememberMe}" />
            </h:panelGrid>
            <h:commandButton id="loginButtonId"
            value="Login" action="#{identity.login}"
            oncomplete="requestWindowClose();" reRender="Login" />

            </h:form>
            </rich:modalPanel>
            </ui:composition>

            • 3. Re: Modal Panl Validation
              ilya_shaikovsky

              From the very beggining - you should not use h:command* working with MP if you want it not to be closed. After page reloading caused by this controls it'll be surelly hidden.

              • 4. Re: Modal Panl Validation
                dilsent

                Thanks for your reply.Could you elaborate..Is that i shouldn't be using the h:commandButton?Would you please be able explain an alternative.

                Thanks

                • 5. Re: Modal Panl Validation
                  ilya_shaikovsky

                  use corresponding a4j:command* controls


                  http://wiki.jboss.org/wiki/ModalPanelValidation

                  • 6. Re: Modal Panl Validation
                    dilsent

                    Thanks.Got it..Its working now