I intended to give user a chance to confirm their action by adding JavascriptEventConfirmation as the example from this tutorial :
https://cwiki.apache.org/WICKET/getting-user-confirmation.html
However, I want to be able to check first if there is at least one checkbox (out of mulitple) is being checked before displaying the confirmation dialog.
How can I achieve this?
Note that the confirmation is implemented via a simple javascript snippet that is added to the button tag's onclick attribute.
To add the verification, just change the generated snippet to fit your needs.
Related
I am writing a Java application for digitizing a group of documents in the office that I am working in and I am wanting to check if 5 textfields are populated and 4 combobox fields as well before the save button is enabled (I have it checking if i press a button (that happily says "Check"), but i would much rather have it auto-check to see if they are populated or if they are null).
If it makes a difference i am using NetBeans for this project.
Basically I need the fields to have something in them before the document can be saved.
Any and all help will be greatly appreciated as this is the final step in creating this application... :D
Thanks,
Erik
There are two ways (I can think of):
1- Put a listener on each field, this listener will be triggered when the field is populated. Inside the listener increment a counter for example, or set a flag. If all flags are set or if the counter reaches (9 in your example) then enable the button.
2- Enable the Save button, but call a validate() method before doing the Save action. Any unpopulated field will have a red mark beside it (shown by validating) like in web applications.
I need to provide context sensitive help in my GWT application. For this every GWT view will have many help links each of which will open a dialog box with appropriate help text (different for each link). The problem is I cannot have so many ui:field elements each with unique name and click listener in my view classes as the number of help links may be very large. What I need is to have many Anchor elements in my UI binder xml file and all the anchors should have the same click listener. The click listener will decide based on some parameter which help text to display in the dialog box.
I tried to use Hyperlink element with different history tokens for all links, but it changes the history which is not desirable. I just want to show a dialog box with appropriate help message without modifying history.
Is it possible in GWT?
Thanks for your help.
You can obviously use <g:Anchor href="javascript:;"> in your UiBinder and later add handler in your code.
But, since you have a lot of this all around your app I'd use gwtQuery:
$(".help-link").click(new Function(){
public void f(Element element) {
// do something here
// `element` tells you which element triggered the event
});
then I'd just add css class .help-link to all relevant anchors.
I have a JCheckBox that should not be checked by the user when a certain other field is empty.
So now I want to have an error popup and then reset the checkbox (I've considered disabling the checkbox, but the connection to the other field is non-obvious, and a tooltip text IMO not visible enough).
What's the correct way to do that in Swing? Through a PropertyVetoException? Where do I throw it and where do I catch it? My first (probably ugly) idea would be to add a ChangeListener that itself shows the popup and resets the value.
Edit: The question is about Nikki (screenshot below), an app I am developing which geotags images and exports them to Google Earth's KMZ format. The checkbox is used to select the images to include in the export. But this requires the images to be gotagged first (which in turn requires either a timestamp, or manual assignment). I don't think this requirement can be made obvious through the UI layout.
(source: brazzy.de)
I would simply disable the check box and add a message explaining why the option is not available. A nice way to show the message is to display a mini exclamation mark next to the check box and put the message in a tooltip.
Poping up an exception often feels wrong because users don't read error messages. For most users an error message popup means that the application did something wrong, in your case it's the normal behavior.
Edit if you insist on letting the check box enabled, another way to show the user that some info is missing would be to flash the missing data. Eg. if latitude and longitude are missing and the user clicks on export, set a red background onto these fields for a just a second. This will clearly show the user what's missing.
In this screen, don't you want to put the mouse over the red circle to understand what's going on?
validation http://www.vogella.de/articles/EclipseDataBinding/images/validation10.gif
I don't think the Export JCheckBox should be disabled at all. Instead, the Export JButton itself should examine the current export list and display any anomalous entries in a way that allows navigation to a chosen photograph. If all entries are correct, Export would proceed as usual.
Addendum: It think you are right to keep the interface as non-modal as possible. My model for this would be unsaved files when exiting an editor or uncommitted changes when closing a project in an IDE.
If that's a status line at the bottom of the window, you might indicate the number of photographs currently selected for export, adding a count if any still need geocoding.
The field should simply be allowed to disable the checkbox. If the coupling is unintuitive then the GUI layout may have to be reconsidered.
EDIT: I ran it from your page, and I believe the issue here is that you actually have a third and fourth step in addition to select folder, select images. The third step is validate image, and fourth is select images for export. I think your problem is that this is not clearly conveyed in the current layout, and that reflects in your question.
I would suggest that you create a separate column containing the checkbox for each image, and that THAT checkbox is disabled until the image passes validation (step 3). Perhaps with an explanatory text in the column about why the image hasn't passed yet.
I have a requirement where clicking each errors should focus input box. I am trying different ways but could not succeed. I got some answers in the past but that did not work like i wanted.
I was using tag with onclick event but I had to do this for each input boxes which is not so relevant if I have 20 fields. So I was looking some thing dynamic .for eg: .
Its has been a long I am looking for this solution. Any kind of help or suggestions would be highly appreciated.
Can you consider this -> Instead of showing all the error messages on top, you can show the error message along with the input box which is related to this input box. The h:message have a attribute for which you can use.
Other option would be developing custom renderer which will output onclick event for each error message. The error message have the component id so you can use that id to set the focus in javascript. This will be all dynamic.
Here is some information about implementing custom renderer http://java.sun.com/javaee/javaserverfaces/reference/docs/customRenderKit.html
On an Eclipse RCP application, I'm building an Editor in which some fields are mandatory.
If the user saves the editor with theses fields not filled, what is the best way/practice to handle this ?
(my first guess is to show an error dialog if theses fields are empty in doSave() method but I'm not sure it's the "eclipse" way to deal with this kind of problem)
If you consider some dialog box like "Create a New Java Project",
you simply cannot do any action (like "Next" or "Finish" until you fill the one mandatory field ("Project name")
So it is different than checking on the doSave() event.
If that field is invalid (like if the project name already exist), a warning is displayed in the zone at the top.
If the field is correctly filled, then you can save.
(Note: I know this is not an Editor, but it can give you an idea about the mandatory fields management in eclipse)
alt text http://ds.informatik.uni-marburg.de/MAGE/gdt/images/tutorial/NewJavaProject.png
I agree with VonC and would disable the "Save" button, as long as the user has filed all the important fields.
Showig a warning which fields the user has to fill would help a lot.
EDIT:
Create a component which added himself as change listener. When someone changes the component, you can check whether the input is correct.
Create a window whith all the self-checking components and add the window as listener to all the components.
When somebody change a compounent you can directly check if the input is valid and the user can step to the next page or save the page.
In RCP (Example FieldEditorPreferencePage) a lot of components have the doSave() and isValid() methods.
In isValid() you can check all the components you can find in the window and in doSave(), you sould check the isValid() state, when it is not done automatically, and do some additional save actions.
You could use FieldDecorations to mark the mandatory fields and provide visual feedback if the content of a field is incorrect.