8 Replies Latest reply on Oct 22, 2012 7:34 AM by faycal facilus

    modalPanel disappears after a second

    Nicole Schweighardt Novice

      Hi,

       

      I have got a problem with modalPanels. It disappears after a second.

      I use RichFaces 3.2.2GA, JBoss 5.0.1GA and Facelets 1.5.15B1.

       

      I have got a facelets-template:

       

       <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html 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:rich="http://richfaces.org/rich">
      <head>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
          <title>CMT</title>
      
      <base href="#{facesContext.externalContext.request.scheme}://#{facesContext.externalContext.request.serverName}:#{facesContext.externalContext.request.serverPort}#{facesContext.externalContext.requestContextPath}/"/>
      
      <link rel="stylesheet" type="text/css" href="css/cmt.css" />
          <f:loadBundle basename="de.bundle.resources" var="rs"/>
          <f:loadBundle basename="de.bundle.messages" var="msg"/>
          
      </head>
      
      <body>
          <div align="center" id="base" >
          <div id="background" align="left">
                  
                  <div id="header">
                      <ui:insert name="header">
                          <ui:include src="../inc/header.xhtml"/>
                      </ui:insert>
                      <div id="headerinfo">
                          <ui:insert name="headerinfo">
                              <ui:include src="../inc/headerinfo.xhtml"/>
                          </ui:insert>
                      </div>
                  </div>    
              
                    <ui:insert name="menu">
                      <ui:include src="../inc/menu.xhtml" />
                  </ui:insert>
      
                  <div id="content">     
                      <ui:insert name="content">Place for content </ui:insert>
                  </div>    
              </div>
      </div>
      
      </body>
      </html>
      
      

       

      In the "content" div there is my document that contains the modelPanel:

      showCourses.xhtml

       

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:rich="http://richfaces.org/rich"
                      xmlns:a4j="http://richfaces.org/a4j"
                      xmlns:ns="http://www.cmt.de/jsf" 
                      template="/app/templates/basic.xhtml">
      <ui:define name="content"> 
      
          <a4j:form>
                <rich:modalPanel id="deleteCourse" minHeight="150" minWidth="200"
                        height="150" width="200" zindex="2000">
                <f:facet name="header">
                     <h:outputText value="#{rs.course_delete}" />
                </f:facet>
                <f:facet name="controls"> </f:facet> 
                  <h:outputText value="#{rs.confirm_course_delete}" /><br /><br />
                <h:commandButton action="#{courseBean.deleteCourse}" value="#{rs.delete}" onclick="#{rich:component('deleteCourse')}.hide()" styleClass="confirm_text_buttons"/>
                &#160;       
                <h:commandButton onclick="#{rich:component('deleteCourse')}.hide()" value="#{rs.cancel}" styleClass="confirm_text_buttons"/>                   
              </rich:modalPanel>
            </a4j:form>
              
          <h:form>
      ...
      <rich:dataTable value="#{courseBean.coursesForInstructor}" var="course" ..     
           <h:column>
                <h:commandLink alt="#{rs.delete}" action="#{courseBean.noticeId}" onclick="#{rich:component('deleteCourse')}.show()">
                 <f:param name="courseId" value="#{course.id}" />
                </h:commandLink>     
           </h:column>
           </rich:dataTable>
          </h:form>
      </ui:define> 
      </ui:composition>
      

       

      Do you have any ideas for me?

      Thank you a lot!

      Nickei

        • 1. Re: modalPanel disappears after a second
          Ilya Shaikovsky Master

          Moving to RichFaces space as has nothing about RichFaces Development.

           

          about the question - you using h:command - so after link request page refreshed and modal panel becames hidden. Just as it should be.

          solutions:

          • add return false; after show(), but it will cause the reuqest sending functionality of the link not working.
          • change link to a4j:command and show modal on oncomplete.
          • 2. Re: modalPanel disappears after a second
            Nicole Schweighardt Novice

            Thank you very much - it works.

             

            But what do you mean with:


            ilya_shaikovsky wrote:

             

            Moving to RichFaces space as has nothing about RichFaces Development.

            Sorry, I am confused....

             

            thanks!

            • 3. Re: modalPanel disappears after a second
              Ilya Shaikovsky Master
              I moved your thread from RichFaces development space to just RichFaces. Please create further usage topics there as Development space supposed to be used for design of RichFaces itself discussions.
              • 4. Re: modalPanel disappears after a second
                Nicole Schweighardt Novice

                Oh! Ok, sorry I did not see that.

                Thanks :-) - I will pay more attention in future for that.

                NcChweig
                • 5. Re: modalPanel disappears after a second
                  Chakradhar Kantipudi Newbie

                  hiii Schweighardt,

                   

                  i am facing same problem, can u please share your corrected code. as u said it works! it would be helpful for me.

                   

                  Thank You.

                  • 6. Re: modalPanel disappears after a second
                    Chakradhar Kantipudi Newbie

                    my modalPanel appeares for a second and then disappears pls help . my code is...

                     

                     

                     

                    <?xml version="1.0" encoding="UTF-8" ?>
                    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                    <html 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:rich="http://richfaces.org/rich">
                    <head>
                    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                    <title>Insert title here</title>
                    </head>
                    <body>
                    <ui:composition template="/Pages/templates/template.xhtml">
                        <ui:define name="loginContent">

                     

                            <!-- Modal Panel Wizard -->
                            <a4j:form id="wizardForm">
                                  <rich:modalPanel id="wizard">
                               
                                   
                                       
                                            <f:facet name="header">New Picture</f:facet>
                                            <f:facet name="controls">
                                                  <h:panelGrid>
                                                <a4j:commandButton value="Close" action="closeWizard"
                                                    onclick="Richfaces.hideModalPanel('wizard');" />
                                                  </h:panelGrid>
                                            </f:facet>
                                                     this is workspace
                                        
                                   
                               
                                </rich:modalPanel>
                            </a4j:form>
                            <h:form>
                                <h:panelGrid columns="2">
                                    <h:outputText value="Successfully Logged in!"></h:outputText>
                                    <h:commandLink value="Proceed" action="continue"></h:commandLink>
                                    <rich:tabPanel switchType="ajax" style="height:500px;width=700px">
                                        <rich:tab label="Home">
                                            Welcome User!
                                            <br />
                                            <h:outputLabel value="#{message}" />
                                        </rich:tab>
                                        <rich:tab label="Account">
                                            <rich:panel header="Profile Picture">
                                                  <a4j:region>
                                                <a4j:commandButton onclick="Richfaces.showModalPanel('wizard',{width:300,height:200});"
                                                    value="Add/Update Picture"/>
                                                  </a4j:region>
                                            </rich:panel>

                                        </rich:tab>
                                    </rich:tabPanel>

                     

                                </h:panelGrid>
                            </h:form>
                        </ui:define>
                    </ui:composition>
                    </body>
                    </html>

                    • 7. Re: modalPanel disappears after a second
                      Andrey Markhel Newbie

                      Answered in original post

                      • 8. Re: modalPanel disappears after a second
                        faycal facilus Newbie

                        I've used the <a4j:commandLink> as :

                         

                        <a4j:commandLink action="save" title="#{msg.btn_save}"  onclick="Richfaces.showModalPanel('popup'); return false;" 

                                                                                                        reRender="formPopup"  >

                                                                                                   <span class="btmiddle">#{msg.btn_save}</span>

                                                                                    </a4j:commandLink>

                         

                        Or as

                         

                        <a4j:commandLink action="save" title="#{msg.btn_save}"  onclick="#{rich:component('popup')}.show(); return false;" 

                          reRender="formPopup"  >

                                <span class="btmiddle">#{msg.btn_save}</span>

                          </a4j:commandLink>

                         

                        The popup is showed correctly but the action 'save' was not executed in Managed Bean !!!!

                         

                        What is the mistake in the code plz ?