1 2 Previous Next 18 Replies Latest reply: Jan 6, 2012 4:26 PM by Damien Lepage RSS

(a4j:status) and request

Leandro godoy Newbie

Hello everybody.
I tried using the example found in: http://community.jboss.org/wiki/Howtousestatusfornon-ajaxcontrolsin33x
but did not succeed, the example only works if I set a starttext = "Wait ..." for <a4j: status.
In my case I use an image in a modal panel as below:

 

 

<rich:modalPanel id="statusPanel" autosized="true"

    styleClass="transparent">

    <h:graphicImage value="/images/ajax-loader.gif" />

    <h:outputText value="Aguarde..." />

</rich:modalPanel>

 

<a4j:status onstart="javaScript:Richfaces.showModalPanel('statusPanel')" 

 

    id="status" onstop="javaScrpt:Richfaces.hideModalPanel('statusPanel');" >

 

</a4j:status>

 

The above code snippet is inside my template and is used by all
other system screens, is there any way When Using the example described in
http://community.jboss.org/wiki/Howtousestatusfornon-ajaxcontrolsin33x with a modal panel and an image?
All help and welcome.
Thanks

  • 1. (a4j:status) and request
    Leandro godoy Newbie

    it´s no possible ?

    Please reply me team.

     

  • 2. (a4j:status) and request
    Mark Paluch Master

    Hi Leandro,

    just remove the javaScript: from your onstart/on stop, then it should work.

     

    <a4j:status onstart="Richfaces.showModalPanel('statusPanel')"

     

        id="status" onstop="Richfaces.hideModalPanel('statusPanel');" >

     

    </a4j:status>

     

     

    Best regards,

    Mark

  • 3. (a4j:status) and request
    Leandro godoy Newbie

    Hello Mark, I tried as you showed up but did not work so I tried also:

     

    <a4j:status onstart="#{rich:component('statusPanel')}.show();" 

        id="status" onstop="#{rich:component('statusPanel')}.hide();" >

    </a4j:status>

     

    what might be going wrong?
    Thanks.

  • 4. (a4j:status) and request
    Ilya Shaikovsky Master

    any js errors?

  • 5. (a4j:status) and request
    Leandro godoy Newbie

    No error displayed in firebug and I put two alert's a before and after the call
    as below and all the alert's are usually displayed:

    I have a template where the <a4j: status and see Modal Panel:

     

     

     

    <?xml version="1.0" encoding="ISO-8859-1" ?>

    <!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="X-UA-Compatible" content="IE=EmulateIE8" />

    <link rel="shortcut icon" type="image/x-icon"

        href="#{facesContext.externalContext.requestContextPath}/images/favicon.ico" />

     

    <link

        href="#{facesContext.externalContext.requestContextPath}/css/estilos.css"

        rel="stylesheet" type="text/css" />

    <title>Sistema Corporativo de Gestão Industrial</title>

    <script src="menu.js" language="javascript"></script>

    <a4j:loadScript src="/js/scripts.js" />

    <a4j:loadScript src="/js/jquery-1.4.2.js" />

    <a4j:loadScript src="/js/jquery.maskedinput-1.2.2.js" />

     

     

    <script>

    /* <![CDATA[ */             

                    var $jq = jQuery.noConflict();

            /* ]]> */  

           

     

    $jq(function () {

      $jq(window).load(function () {

        $jq(':input:visible:enabled:first').focus();

      });

    })

     

             function switchStatus(){

            alert('test 1');   

                  document.getElementById('_viewRoot:status.start').style.display='inline';

                  document.getElementById('_viewRoot:status.stop').style.display='none';   

             alert('test 2');   

                  }

        

    </script>

    </head>

    <body>

    <ui:define name="teste">

        <ui:debug hotkey="d" />

        <h:form id="sciDefaultForm">

            ... varios componentes aki

        </h:form>

        <div id="conteudo" align="center">

        <ui:insert name="conteudo" />

        </div>

     

    </ui:define>

     

     

     

     

    <rich:modalPanel id="statusPanel" autosized="true"

        styleClass="transparent">

        <h:graphicImage value="/images/ajax-loader.gif" />

        <h:outputText value="Aguarde..." />

    </rich:modalPanel>

     

    <a4j:status onstart="#{rich:component('statusPanel')}.show();" 

        id="status" onstop="#{rich:component('statusPanel')}.hide();" >

    </a4j:status>

     

    </body>

    </html>

     

     

     

     

    The above template for a page and used to generate reports as
    and demonstrated below on this page that perform the function switchStatus:

     

     

     

     

     

    <?xml version="1.0" encoding="ISO-8859-1" ?>

    <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:rich="http://richfaces.org/rich" template="default.xhtml" >

     

        <ui:define name="conteudo">

        <h1>Relatórios</h1>

        <div id="txt_sub"  style=" margin-bottom: 40px;">Informe os dados abaixo para gerar um relatório.</div>

            <a4j:keepAlive beanName="mbRelatorio" />

            <a4j:keepAlive beanName="mbFiltroParametros" />

            <h:form id="gerarRelatorios">   

                <a4j:outputPanel id="region" ajaxRendered="true">

                <div class="contorno_azul" style="width: 300px;" align="center">

                <table cellpadding="3" cellspacing="0">

                    <tr>

                        <td style="width: 90px;">Relatório:</td>

                        <td colspan="2">

                        <h:selectOneMenu

                            value="#{mbRelatorio.reportType}" style="width:155px;">

                            <f:selectItems value="#{mbGerenciarMenu.tipoRelatorios}" />

                                <a4j:support event="onchange"

                                actionListener="#{mbRelatorio.reloadFilters}"

                                reRender="region" />

                        </h:selectOneMenu></td>

                    </tr>                   

                    <tr>

                        <td><h:outputText value="Modulo:" rendered="#{mbRelatorio.exibeModulo}"/></td>

     

                        <td colspan="2">

                        <h:selectOneMenu

                            rendered="#{mbRelatorio.exibeModulo}"

                            value="#{mbRelatorio.modulo}" style="width:155px;">

                            <f:selectItems value="#{mbParametros.listaModulos}"

                                id="listaModulosId" />

                            <a4j:support event="onchange" ajaxSingle="true"

                                actionListener="#{mbRelatorio.reloadUR}"

                                reRender="gerarRelatorios:region" />

                        </h:selectOneMenu>

                        </td>

                   

     

                    </tr>

                    <tr>

                       

                        <td><h:outputText value="UR:" rendered="#{mbRelatorio.exibeUr}"/></td>

                        <td colspan="2">

                        <h:selectOneMenu rendered="#{mbRelatorio.exibeUr}" id="selectUnidades"

                            value="#{mbRelatorio.unidadeRegional}" style="width:155px;">

                            <f:selectItems value="#{mbRelatorio.unidadesRegionais}" />

                            <a4j:support event="onchange"

                                actionListener="#{mbRelatorio.reloadLocalidades}"

                                reRender="region" />

                        </h:selectOneMenu>

                        </td>

                       

                    </tr>

     

                    <tr>

                   

                        <td><h:outputText value="Localidades:" rendered="#{mbRelatorio.exibeLocalidade}"/></td>

                        <td colspan="2">

                        <h:selectOneMenu  rendered="#{mbRelatorio.exibeLocalidade}" id="selectLocalidades"

                            value="#{mbRelatorio.localidade}" style="width:155px;">

                            <f:selectItems value="#{mbRelatorio.localidades}" />

                            <f:converter converterId="localidadeConverter" />

                            <a4j:support event="onchange" ajaxSingle="true" limitToList="true"

                                actionListener="#{mbRelatorio.reloadItens}"

                                reRender="region" />

                        </h:selectOneMenu>

                        </td>

                       

                    </tr>

     

     

                    <tr>

                        <td><h:outputText value="#{mbRelatorio.labelItemModulo}"

                                    id="labelItemModulo" rendered="#{mbRelatorio.exibeItemModulo}"/></td>

                        <td colspan="2">

                            <h:selectOneMenu id="selectItensModuloOperacional"

                                rendered="#{mbRelatorio.exibeItemModulo}" value="#{mbRelatorio.entity}" style="width:96px">

                                <f:selectItems value="#{mbRelatorio.itensModulo}" />

                                <a4j:support event="onchange" ajaxSingle="true" limitToList="true"                   

                                        reRender="region" />

                            </h:selectOneMenu>

                        </td>

     

                    </tr>

     

     

                    <tr>

                        <td><h:outputText value="Referência:" rendered="#{!mbRelatorio.exibeDia}"/>

                        </td><h:outputText value="Data:" rendered="#{mbRelatorio.exibeDia}"/>

                        <td>

                       

                        <h:selectOneMenu style="width:80px;"

                            rendered="#{mbRelatorio.exibeMes}" value="#{mbRelatorio.mes}">

                            <f:selectItems value="#{mbParametros.listaMes}" />

                        </h:selectOneMenu>

                   

                        </td>

                        <td>

                           

                        <h:selectOneMenu style="width:50px"

                            rendered="#{mbRelatorio.exibeAno}" value="#{mbRelatorio.ano}">

                            <f:selectItems value="#{mbParametros.listaAnos}" />

                        </h:selectOneMenu>

                   

                        </td>

     

                        <td>

                       

                        <h:selectOneMenu style="width:50px" id="selectDias"

                            value="#{mbRelatorio.dia}" rendered="#{mbRelatorio.exibeDia}">

                            <f:selectItems value="#{mbRelatorio.listaDias}" />

                        </h:selectOneMenu>

                       

                        </td>

                    </tr>

                </table>

                <h:commandButton actionListener="#{mbRelatorio.actionGerarRelatorio}"

                    styleClass="btn" value="Gerar relatório" onclick="switchStatus();" />

                    </div>

                </a4j:outputPanel>   

     

            </h:form>

     

        </ui:define>

       

     

    </ui:composition>

     

     

    He enters the function executes the alert's but does not exhibit the modalPanel.
    Thanks for the reply friends.

  • 6. (a4j:status) and request
    Ilya Shaikovsky Master

                  document.getElementById('_viewRoot:status.start').style.display='inline';

                  document.getElementById('_viewRoot:status.stop').style.display='none';  

    will not cause onstart and onstop to be called. That code for knowledgebase was added just in order to be able to show some inline status. And in your case - just call panel show in onclick. (do not warry about closure panel will be closed because of full page request).

  • 7. (a4j:status) and request
    Leandro godoy Newbie

    I tried to use the onclick ()
    onclick = "# {rich: component ('statusPanel')}. show ();"

    but after generating the. pdf and displays the dialog for opening or saving it. pdf and
    status and not closed and he's forever on hold.
    see my method of generating reports:

     

     

     

     

        public String actionGerarRelatorio() {

            try {           

                generateReport();

                return null;

            } catch (ReportBlankException e) {

                e.printStackTrace();

            }

            return null;

        }

     

    • public void generateReport() throws ReportBlankException {
    •         try {
    •             FacesContext fc = FacesContext.getCurrentInstance();
    •             byte[] b = null;
    •            
    •             if (reportType != null && reportType == ReportType.FECHAMENTO_MENSAL) {                   
    •                 b = executarRelatorioFechamentoMensal();                   
    •             } else {
    •                 b = executarRelatorio();                       
    •             }
    •                        
    •             if (b == null) {
    •                 throw new ReportBlankException("");
    •             }
    •             HttpServletResponse res = (HttpServletResponse) fc
    •                     .getExternalContext().getResponse();
    •             res.setContentType("application/force-download");
    •             res.setHeader("Content-Disposition", "attachment;filename=\""
    •                     + "SCI-Sistema de Controle Industrial.pdf" + "\";");
    •             res.setContentLength(b.length);
    •             OutputStream out = res.getOutputStream();
    •             out.write(b);
    •             out.flush();
    •             FacesContext.getCurrentInstance().responseComplete();
    •             //FacesContext.getCurrentInstance().renderResponse();
    •         } catch (IOException e) {
    •             e.printStackTrace();
    •         } catch (ReportBlankException e) {
    •             FacesUtils.addErrorMessage("O relatório não contem dados!");
    •         } catch (Exception e) {
    •             e.printStackTrace();
    •         }
    •     }
  • 8. (a4j:status) and request
    Leandro godoy Newbie

    Anyone know any solution to this problem?

  • 9. (a4j:status) and request
    Leandro godoy Newbie

    oh my god I tried to resolve this in every way possible, including the most bizarre
    but it seems unsolvable and, save me eeeeeeee............

     


  • 10. (a4j:status) and request
    Ilya Shaikovsky Master

    got the problem.. And really for now not see the solution. Seems need some redesign. The browser itself does not provide any events for us when responce to download returned.. So we have no way to stop the status in current design.

  • 11. (a4j:status) and request
    Leandro godoy Newbie

    Ok , thaks for reply.

  • 12. (a4j:status) and request
    Daniel Ku Newbie

    Perhaps i am to confused, what the problem really is. But you use a simple h:commandButton, which calls an actionListener. The whole time the method is doing something, a modalPanel shows up. In my opinion, there is no need to use onstop. A page resfresh (which will be made, because it is a JSF and not a richfaces commandButton), hides each modalPanel automatically.

     

    Just try this: open your modal panel by onlick event in your command button. Also use an action, which leads to the same side. Effect should be, that first the modal panel popup and after action listener processing, the page should be reloaded and your modalPanel should be hidden again.

  • 13. (a4j:status) and request
    Ilya Shaikovsky Master

    in his case full page refresh is not occured as he initiates binary content download. And really there are no place to catch some event to close the popup :/

  • 14. (a4j:status) and request
    Leandro godoy Newbie

    Thanks for answers, tried as you guys explained above, but the problem and that opens the box to download. pdf and page is not refreshed, so not really as close to the modalPanel.
    Would not this like closing the modal method that generates the report in java?

1 2 Previous Next