This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JSF and the fly likes trouble with saving drafts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "trouble with saving drafts" Watch "trouble with saving drafts" New topic

trouble with saving drafts

Juliano Sott

Joined: Jul 13, 2009
Posts: 3
I need to save a draft of a document which name is give by the user, but before I save the draft I need to check if a draft with the same name already exists. If it exists, I need to ask the user if he want to override the draft.
I want to go by this way: I call a managedBean method to check if a draft with the same name already exists, then I show a alert to the user using javascript and finally I need to save the draft calling another method on the managedBean. Someone have an Idea how I do that? Or have another approach to do that?

Thanks for listening
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17421

If you want to show an alert via JavaScript, you might as well just go whole hog and do your check using AJAX.

Since this can be pretty messy in JSF (not that I think that raw AJAX is all that pretty anyway), I recommend you consider using one of the AJAX-supportive component packages such as RichFaces. It can handle that sort of problem with a few tag options and probably less than 10 lines of user-written JavaScript code.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: trouble with saving drafts
It's not a secret anymore!