File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Modal Panel from backing bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Modal Panel from backing bean" Watch "Modal Panel from backing bean" New topic
Author

Modal Panel from backing bean

Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
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

Joined: Jun 25, 2001
Posts: 16222
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
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

Joined: Jun 25, 2001
Posts: 16222
    
  21

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Modal Panel from backing bean