Just like with binding, it is a new root node in the YAML file:
JFrame(name=frame,title=Binding Frame,size=packed):Right now it only supports "mandatory" and "minLength", but shortly I will be adding all the validator routines supported by Apache Commons Validators:
content:
- JLabel(name=fnLbl, text="First name:",labelFor=fName)
- JTextField(name=fName)
- JLabel(name=lnLbl, text="Last name:", labelFor=lName)
- JTextField(name=lName)
- JButton(name=ok, text=OK, onAction=(validateInput,save,cancel))
- JButton(name=cancel, text=Cancel, onAction=cancel)
layout: |
[] [grow,200px]
>fnLbl fName
>lnLbl lName
>ok+*=1,cancel=1 [grow,bottom]
bind:
- firstName: fName.text
- lastName: lName.text
validate:
- fName.text: {label: First Name, mandatory: true, minLength : 5}
http://commons.apache.org/validator/apidocs/org/apache/commons/validator/routines/package-summary.html#package_description
In the above example, if the First name field is missing or less than 5 characters,
it will display a nice error dialog to inform the user:
At this point, the validation logic still needs to be called manually from the Java side:
private final BuildResult result = SwingBuilder.build(this);but I will be looking into automating this soon.
public boolean validateInput() {
return result.validate();
}
You can see the full YAML and Java here:
http://code.google.com/p/javabuilders/source/browse/trunk/org.javabuilders.swing/samples/org/javabuilders/swing/samples/binding/BindingFrame1.yaml
http://code.google.com/p/javabuilders/source/browse/trunk/org.javabuilders.swing/samples/org/javabuilders/swing/samples/binding/BindingFrame1.java
Happy building! Once this is done, an official 0.1 release will finally arrive.

5 comments:
Forgot to add: as an added touch, the validation will put the focus back into the component that generated the first error. Standard usability stuff.
When I run this example I get the following exception.
Caused by: java.util.MissingResourceException: Can't find bundle for base name org/javabuilders/Resources, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1521)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1260)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:715)
Do I need to provide a resource bundle myself or is there maybe one missing?
Yay! a milestone...my first reported bug. My Ant file was not including the resources in the jar, fixed up and uploaded new version.
Thanks for reporting this Gregg.
It is easy to control and pick up more all kinds of latale online gold and weapons or equipment which were dropped by those monsters. You will experience a wide range of attack and strikingly gorgeous combat effects with your own latale gold. You can also freely customize your character by equipping cool armors and weapons which those you must first have need to buy latale online gold and then you can have them. There is no doubt La Tale and its very cheap latale gold will attract female gamer and as well as young gamer eyeballs. You see my problem is that I do not what class is good or fun to play without any more necessary latale money.
wholesale jewelryhandmade jewelryjewelry wholesalediscount jewelryhandcrafted jewelry
Post a Comment