Primefaces show growl with Ajax=false commandButton

时间:2018-02-01 18:34:56

标签: jsf primefaces jsf-2

I need help for my Project.

I'm using a <p:commandButton> with ajax="false" the download files. For this I'm using a way to let a growl appear as soon the download is done.

I've seen on Primefaces Showcase that they've got an example with growl and <p:commandButton>but somehow it doesn't work for me.

My View

    <h:form id="myForm">

        <p:growl id="growl" showDetail="true" life="2000"  />

        <p:dialog id="myDialog" resizable="false" modal="true" 
                  positionType="absolute" position="top"
                  draggable="true" width="1400" showHeader="true" responsive="true"> 

                  <f:facet name="header">
                    <h2 class="BigTopic">#{bundle.dialogHeader}</h2>
                  </f:facet>

                  <ui:repeat value="#{myController.files}" var="file" varStatus="myVarStatus">
                  <p:panelGrid style="border:0px !important; background:none;" columns="2">
                        <p:outputPanel>
                            <p:inputText id="filename#{myVarStatus.index}" value="#{file.filename" readonly="true"/>
                        </p:outputPanel>

                        <p:outputPanel>
                            <p:commandButton ajax="false" value="Download" actionListener="#{myController.showMessage}" onclick="PrimeFaces.monitorDownload(start, stop);">
                                <p:fileDownload value="#{file.file}" />
                            </p:commandButton>
                        </p:outputPanel>
                  </p:panelGrid>
</ui:repeat>
        </p:dialog>
    </h:form>

My Controller

@ManagedBean(name = "myController", eager = true)
@ViewScoped
public class MyController implements Serializable {

    public void showMessage(ActionEvent actionEvent) {
        FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Download Text", "");
        FacesContext.getCurrentInstance().addMessage(null, msg);
    }
}

0 个答案:

没有答案