This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I'm sure this is a very simple question, but I can't find an obvious solution.
I have a command button that on clicking "Clear List" clears a list of uploaded filenames displayed on the screen, but at the moment it does not delete the files in the folder that have been uploaded. I can make the changes for this, but I want to warn the user that his files will be deleted from the server when he clicks the button, and give him the option of aborting the process.
The xhtml code is here:
and on clicking "Clear List" a dialog box appears asking him if he is sure. The idea is that if he clicks "OK", the files are deleted and the display is reset, otherwise nothing happens. However, the display is always reset regardless of the reply, and thus the files will be deleted once I have written the code for that.
Without changing any of the Java code in the bean, how do I arrange for the button only to work when onclick returns true? I'm usinmg JFS 2.
There must be an easy way to do this and would most apprecaite some advice.
Joined: Dec 12, 2007
I made a few changes on got this to work, but there is a "page flip".
The code in the xhtml file is now:
The only change was to replace onclick="confirm('Are you sure?')" by onclick="uploadClear()" in the command button, with uploadClear() being in a separate js file as follows:
In my previous post I had not included the data table, which is displayed on the screen. This is part of a form containing much more information.
The idea is eventually to get files in an uploaded folder cleared, but it would be nice to get the display fixed first.