English 中文(简体)
如何在p:dialog中显示信息?
原标题:How to show messages in p:dialog?

我需要你帮助在方言中显示错误信息。 通过点击指挥Button,方言中没有显示任何信息。

尽管我试图用方言来显示这一信息,但没有发现任何错误。

因此,我如何用方言而不是主要形式来传递信息。

The following is the JSF page Code:

<h:form id="Requests">
    <p:messages id="messages" showDetail="true" autoUpdate="true" closable="true"/>

    <p:dialog id="c1" header="C1" widgetVar="c1">
        <p:message id="messagePDFSTAR"
                   for=":Requests:DownloadPDFSTAR"
                   showDetail="true" />
        <p:commandButton id="DownloadPDFSTAR"
                         value="Download"
                         ajax="false"
                         actionListener="#{hrd.PDFSTAR}"
                         update=":Requests:messagePDFSTAR" >

            <p:fileDownload value="#{hrd.fileSTAR}" />
        </p:commandButton>
    </p:dialog>
</h:form>

这里是一部 j子法典:

public void PDFSTAR() {

    try {
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Ref is Null", "Ref is Null");
        RequestContext.getCurrentInstance().showMessageInDialog(message);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Fatal!", "System Error"));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
问题回答

It s because you have ajax=false at the commandButton, so, the attribute update::Requests:messagePDFSTAR isn t going to work. You can t combine ajax=false and update="...", update attribute is only for ajax actions.

我理解你需要<条码>。 由于<代码>p:fileDownload与这一条相符合,但或许可以尝试另一种方式显示你想要的信息。

我一度处理这一情况,在<代码>p:dialog 上进行工作。 页: 1

<h:form id="Requests">
    <p:messages id="messages" showDetail="true" autoUpdate="true" closable="true"/>

    <p:dialog id="c1" header="C1" widgetVar="c1">
        <p:messages id="messagesPDFSTAR"
                    autoUpdate="true"
                   showDetail="true" />
        <p:commandButton id="DownloadPDFSTAR"
                         value="Download"
                         ajax="false"
                         actionListener="#{hrd.PDFSTAR}" >

            <p:fileDownload value="#{hrd.fileSTAR}" />
        </p:commandButton>
    </p:dialog>
</h:form>

我希望这将有助于你。

<><>Edit>:

RequestContext.getCurrentInstance().showMessageInDialog(message);

它用新的方言显示这一信息,但我认为它不是你想要的。 请在<代码>commandButton <>/code>和上显示这一信息。

Ajax和增编没有正确操作





相关问题
JSF a4j:support with h:selectManyCheckbox

I m having trouble with a JSF selectManyCheckbox and A4J support. The purpose is to run some action when a checkbox is selected. This works perfectly in Firefox. Yet, when testing in any IE (ie6 / ie7 ...

Mojarra for JSF Encoding

Can anyone teach me how to use mojarra to encode my JSF files. I downloaded mojarra and expected some kind of jar but what i had downloaded was a folder of files i don t know what to do with

如何拦截要求终止?

在共同基金中,如果用户要求终止,就需要采取一些行动。 我需要某种拦截器,但我不知道如何这样做。 我需要帮助。 增 编

ICEFaces inputFile getting the file content without upload

Is there any way of just getting the content of the browsed file without any upload/file transfer operations? I currently use ICEFaces inputFile component but I do not need the default uploading ...

Weird behaviour of h:commandLink action (MethodExpression)

I have two JSPs where I am displaying some info from database in a h:dataTable. One of them is showing all the info, and one of them user specifically. I have showXML.jsp that shows the "XML" column ...

How to correctly use ResultSet with h:dataTable

The problem is, that after displaying the ResultSet with <h:dataTable>, the connection is left open. If I close it, it closes the ResultSet too. I m thinking about copying the ResultSet data ...