JSF:如何显示“等待”信息?
我创建了一个联系表单,但现在我想显示一条等待消息,例如“发送消息”。
这就是我到目前为止所做的:
<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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
但要使用 ypur a4j:status,我相信您要么将其放在表单之外,而不带名称和参考。并且在您的 ajax 调用中没有引用
或者保留名称和状态引用,但您必须将其放入表单中
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
Or leave the name and status reference abut you have to put it inside the form
我们使用弹出面板
,在 ajax 调用中我们使用 onbegin 和 oncomplete 来显示和隐藏它。
We use a popup panel
And in the ajax call we use onbegin and oncomplete to show and hide it.
每当我需要进程负载时我都会这样做
Richfaces.showModalPanel('pleaseWaitPanel');
这是模型面板:
whenever i need process load i do
Richfaces.showModalPanel('pleaseWaitPanel');
where this is the model panel :