Solved

JSF-Prompt for user input in a popup, display entry in textarea.

Posted on 2009-04-14
1
1,542 Views
Last Modified: 2013-11-24
I have a JSF form that contains among other things, an <h: inputTextarea>.  

That text area contains a running history of comments.  Basically, this form can be viewed and edited any number of times, and the purpose of the comments section is to keep a log of changes.

My goal is to make that textarea disabled when the form is displayed, but pop a dialog up when the form is saved in which the user can enter their comments.  Then, using basic DOM stuff, updating the textarea when the user hits OK on the dialog. This forces the user to enter a comment before the form is submitted.  

How can I create a pop-up window, or prompt with a textarea, in which the user can enter their comments and then, after clicking OK and closing the popup, have the form go on with it's normal behavior?  Or if CANCEL is clicked, have the user returned to the form.

Normal textarea validation won't work, since there may already text in that field.  The user is simply adding on to it each time he submits/saves the form.

I've done similar things with javascript in non JSF projects, but the problem I'm running into with JSF is that even if I pop up a javascript window using onclick="someFunctionToCollectComments()" the javascript window pops up, but it doesn't prevent the default behavior of the commandButton from kicking in.

Ex: <h:commandButton value="Save" onclick="getComment();" action="#{OrderBean.save}" disabled="#{!OrderBean.editable}" rendered="#{OrderBean.approverType}"/>

I get the window created by getComment, but in just a couple seconds, action OrderBean.save kicks in and wipes it all out.

Any ideas would be greatly appreciated.
0
Comment
Question by:krussell222
1 Comment
 
LVL 2

Accepted Solution

by:
knrrjohle earned 500 total points
ID: 24212985
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now