JSF:如何显示“等待”信息?

发布于 2024-11-28 19:00:30 字数 2045 浏览 0 评论 0原文

我创建了一个联系表单,但现在我想显示一条等待消息,例如“发送消息”。

这就是我到目前为止所做的:

<h:form styleClass="contact">
    <h:inputText id="name" value="#{contact.client.name}" styleClass="text-input" >
        <f:ajax event="blur" render="nameMessage" />
    </h:inputText>
    Name (Required)
    <br />
    //..

    <a4j:commandButton value="Do something" action="#{contact.sendMessage}" status="ajaxStatus" />


    <!-- warning messages -->
    <h:messages globalOnly="true" errorClass="errorMessage" infoClass="infoMessage" showSummary="true" showDetail="true" />
    <h:message id="nameMessage" for="name" errorClass="error" /><br />
</h:form>

<a4j:status id="ajaxStatus" name="ajaxStatus">
    <f:facet name="start">
        <h:graphicImage name="loader.gif" library="images" />
        <h:outputText value="Your message" />
    </f:facet>
</a4j:status>

解决方案: 基于@roel提示:

    <h:form styleClass="contact">
        <h:inputText id="name" value="#{contact.client.name}" styleClass="text-input" >
            <f:ajax event="blur" render="nameMessage" />
        </h:inputText>
        Nome (Obrigatório)
        //..        
        <a4j:commandButton value="Enviar" action="#{contact.sendMessage}" styleClass="button" status="ajaxStatus" />


        <!-- warning messages -->
<!--         <h:messages globalOnly="true" errorClass="errorMessage" infoClass="infoMessage" showSummary="true" showDetail="true" /> -->
        <h:message id="nameMessage"    for="name"    errorClass="error" /><br />
        //..
    </h:form>

    <a4j:status name="ajaxStatus">
        <f:facet name="start">
            <h:graphicImage name="loader.gif" library="images" />
            <h:outputText value="Aguarde um momento ..." />
        </f:facet>
    </a4j:status>

但我不知道为什么不起作用。 有什么想法吗?

i create a contact form, but now i want to show a wait message like 'sending message' for example.

this is what i have done so far:

<h:form styleClass="contact">
    <h:inputText id="name" value="#{contact.client.name}" styleClass="text-input" >
        <f:ajax event="blur" render="nameMessage" />
    </h:inputText>
    Name (Required)
    <br />
    //..

    <a4j:commandButton value="Do something" action="#{contact.sendMessage}" status="ajaxStatus" />


    <!-- warning messages -->
    <h:messages globalOnly="true" errorClass="errorMessage" infoClass="infoMessage" showSummary="true" showDetail="true" />
    <h:message id="nameMessage" for="name" errorClass="error" /><br />
</h:form>

<a4j:status id="ajaxStatus" name="ajaxStatus">
    <f:facet name="start">
        <h:graphicImage name="loader.gif" library="images" />
        <h:outputText value="Your message" />
    </f:facet>
</a4j:status>

Solution:
Based in @roel tip:

    <h:form styleClass="contact">
        <h:inputText id="name" value="#{contact.client.name}" styleClass="text-input" >
            <f:ajax event="blur" render="nameMessage" />
        </h:inputText>
        Nome (Obrigatório)
        //..        
        <a4j:commandButton value="Enviar" action="#{contact.sendMessage}" styleClass="button" status="ajaxStatus" />


        <!-- warning messages -->
<!--         <h:messages globalOnly="true" errorClass="errorMessage" infoClass="infoMessage" showSummary="true" showDetail="true" /> -->
        <h:message id="nameMessage"    for="name"    errorClass="error" /><br />
        //..
    </h:form>

    <a4j:status name="ajaxStatus">
        <f:facet name="start">
            <h:graphicImage name="loader.gif" library="images" />
            <h:outputText value="Aguarde um momento ..." />
        </f:facet>
    </a4j:status>

But i don't know why is not working.
Any idea ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

悲凉≈ 2024-12-05 19:00:30

但要使用 ypur a4j:status,我相信您要么将其放在表单之外,而不带名称和参考。并且在您的 ajax 调用中没有引用

<a4j:commandButton value="Do something" action="#{contact.sendMessage}"  />

或者保留名称和状态引用,但您必须将其放入表单中

But to use ypur a4j:status, I believe you either put it outside your form without the name and reference. And no reference in your ajax call

<a4j:commandButton value="Do something" action="#{contact.sendMessage}"  />

Or leave the name and status reference abut you have to put it inside the form

神也荒唐 2024-12-05 19:00:30

我们使用弹出面板

<rich:popupPanel modal="true" id="busy" width="300" height="150" zindex="10"
        moveable="false" resizeable="false">
<h:outputText value="#{msg.busy_please_wait}" />
</rich:popupPanel>

,在 ajax 调用中我们使用 onbegin 和 oncomplete 来显示和隐藏它。

<a4j:ajax id="postalCode" event="change" listener="#{myclass.retrievePostalCode}" render="cityGroup address " execute="country houseNumber address city"  oncomplete="#{rich:component('busy')}.hide();" onbegin="#{rich:component('busy')}.show()"/>

We use a popup panel

<rich:popupPanel modal="true" id="busy" width="300" height="150" zindex="10"
        moveable="false" resizeable="false">
<h:outputText value="#{msg.busy_please_wait}" />
</rich:popupPanel>

And in the ajax call we use onbegin and oncomplete to show and hide it.

<a4j:ajax id="postalCode" event="change" listener="#{myclass.retrievePostalCode}" render="cityGroup address " execute="country houseNumber address city"  oncomplete="#{rich:component('busy')}.hide();" onbegin="#{rich:component('busy')}.show()"/>
兲鉂ぱ嘚淚 2024-12-05 19:00:30

每当我需要进程负载时我都会这样做
Richfaces.showModalPanel('pleaseWaitPanel');

这是模型面板:

<rich:modalPanel id="pleaseWaitpanel" width="yourChoice" height="yourChoice" autosized="true">
<t:panelGrid columns="1" style="width:100%;" >

        <t:div style="width:100%;text-align:center;">
            <t:graphicImage url="look in google for processloading.gif"/>
        </t:div>
    </t:panelGrid>
</rich:modalPanel >

whenever i need process load i do
Richfaces.showModalPanel('pleaseWaitPanel');

where this is the model panel :

<rich:modalPanel id="pleaseWaitpanel" width="yourChoice" height="yourChoice" autosized="true">
<t:panelGrid columns="1" style="width:100%;" >

        <t:div style="width:100%;text-align:center;">
            <t:graphicImage url="look in google for processloading.gif"/>
        </t:div>
    </t:panelGrid>
</rich:modalPanel >
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文