views:

432

answers:

1

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!

A: 
<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)

Bozho
Hm, it's a good idea and the demo app shows that this would be exactly what I need, but I forgot about the renderer problem... Tobago does not support different renderers :/ Seems as if I must use alert boxes and hidden fields...
Marcus
you don't need different renderers. The reRender just indicates which components it should 'reload'
Bozho
"JSF only supports one renderkit (renderkitId) per page (f:view). Because Tobago has it's own renderkitId you cannot use any non-Tobago components that need a renderer." <-- Just found this info within the MyFaces/Tobago FAQ. And as far as I know RichFaces components uses their own renderers.
Marcus
pff, if that's true, then my advice is to drop Tobago completely and go for some more reasonable component framework.
Bozho
It's a pitty, that I'm not the one to decide this :/ Customers... But thanks a lot for the idea nevertheless!
Marcus
anyway, give the above code a try, we might be misunderstanding the statement in the docs.
Bozho