How to show a client-side message with Java JSF/Tobago?
I have a web application created with JSF and Tobago. The user types some date into a sheet and clicks a button (all within one sheet-row). Now my java class checks whether the data is correct or not. In case there are some problems, I would like to show up something like a messagebox containing the errormessage.
I cannot use something like JDialog, since this would happen only server side. Every user independently of his location 开发者_开发技巧needs to get the message. I thought about setting the error information into a databean and having my jsp show up the message after reloading. But how can I achieve this? Is there something like a tag which can be used for this? Or can I use the "confirmation" facet for this? But how would I start it without having the user to do something?
Thanks in advance!
<rich:modalPanel id="messagePanel">
<h:outputText value="#{yourValue}" />
</rich:modalPanel>
(see the richfaces demo app for how to add more features to the modal panel)
Then within your "sheet":
<a4j:support action="#{bean.yourValidationAction}"
event="onclick"
oncomplete="if(#{facesContext.maximumSeverity != null})
{#{rich:component('messagePanel')}.show()}" />
this will show a message if you add a faces error message.
(have in mind that the event
attribute can be any of the on* attributes (events) of the control, where the <a4j:support>
is nested)
精彩评论