Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Modal Panel from backing bean

 
Davie Lin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know how to display a modal panel using richfaces 3 from a backing bean. I can do modal window from user clicking a button but how do I display it from backing bean
On my page, I have a text field and ok button, user enter some number and send this number to backing bean, if some condition is met, than modal panel displays.
I thought about using HtmlComponentControl but no luck, here is code snippet



nothing happened

Any suggestion is greatly greatly appreciated
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18155
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A modal panel is normally not controlled by the backing bean for the simple reason that J2EE/HTTP is not asynchronous (AJAX) is only "fake-asynchronous"), so there's no way a server-side bean could just up and decide to show or hide a dialog.

So the more common case is to do that using JavaScript on the View itself, usually from an "onclick" of a button or link, as illustrated by the RichFaces Live Demo.
 
Davie Lin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank Tim for providing the reason. I have decide to do a redirect to a different page if the condition is met. However, if not using backing bean to call a pop-up directly, is it possible to call javascrip functions that creates a pop-up ( maybe a modal panel ) from the backing bean?

Thanks again
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18155
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using RichFaces, you define the dialog as part of the page View definition. It has to be in a separate form from the rest of the page, and any backing bean references in it are going to reflect the values from when the page was loaded, so if you want to do things on the page and have those changes reflected in the dialog, you should reRender the dialog before making it visible.

The RichFaces ModalPanel isn't something that JavaScript can create "on the fly", because it requires JSF resources. So it's pre-defined and shown/hidden on command.

For an actual JavaScript-defined dynamic dialog, you'd be talking a lot of delicate work, so a framework like jQuery or dojo would be advisable. RichFaces includes jQuery automatically (it uses it internally), but it's a fairly old version of jQuery.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic