jQuery in Action, 3rd edition
The moose likes JSF and the fly likes How to show Information Dialog? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "How to show Information Dialog?" Watch "How to show Information Dialog?" New topic

How to show Information Dialog?

Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

Hello Friends..

How to show Information Dialog in JSF?..
Example i want to show message dialog if the blank value occured or if the data input duplicate with data in database?..
and if the data already saved, then message dialog showed.. (like Desktop Application)..

is it possible in JSF?..

Here is my code :

Thanks in advance..

Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

The web is a very different place than the desktop. But there are ways to fake it.

First, however, the best way to vet data is to do it according to the JSF architecture. If a field must not be empty, you can indicate that with the 'required="true"' attribute on the input control. You should also link an "h:message for=" element to that control so that the "item is required" message will display. In general you shouldn't validate data on the submit processor - I can tell you from experience it's an ungraceful thing to do.

In the case of checking for duplicate data, that's something that is more suited to the action process. The simplest thing to do in that case is to put a tag similar to the following on your view:

This will provide a place where the general messages (not tied to an individual control) can be displayed.

To add a message, you have to access the JSF context. Rather than fill my managed beans with a lot of awkward JSF code, I made a JSFUtils class and defined methods like this in it:

Using that, my action bean can do stuff like this:

An IDE is no substitute for an Intelligent Developer.
Don't get me started about those stupid light bulbs.
subject: How to show Information Dialog?
It's not a secret anymore!