[Buix-commits] r948 - in lutinjaxx/trunk/jaxx-example/Validation/src/main: java/examples/Validation resources/examples/Validation
Author: tchemit Date: 2008-10-17 16:44:54 +0000 (Fri, 17 Oct 2008) New Revision: 948 Added: lutinjaxx/trunk/jaxx-example/Validation/src/main/java/examples/Validation/Identity.java lutinjaxx/trunk/jaxx-example/Validation/src/main/resources/examples/Validation/Identity-validation.xml Modified: lutinjaxx/trunk/jaxx-example/Validation/src/main/java/examples/Validation/Validation.jaxx Log: implements autoField behaviour add some checking on beans Copied: lutinjaxx/trunk/jaxx-example/Validation/src/main/java/examples/Validation/Identity.java (from rev 943, lutinjaxx/trunk/jaxx-example/Validation/src/main/java/examples/Validation/Model.java) =================================================================== --- lutinjaxx/trunk/jaxx-example/Validation/src/main/java/examples/Validation/Identity.java (rev 0) +++ lutinjaxx/trunk/jaxx-example/Validation/src/main/java/examples/Validation/Identity.java 2008-10-17 16:44:54 UTC (rev 948) @@ -0,0 +1,79 @@ +package examples.Validation; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; + +public class Identity { + + protected String firstName = ""; + + protected String lastName = ""; + + protected String email = "dummy@codelutin.com"; + + protected int age = 51; + + + PropertyChangeSupport p; + + public Identity() { + p = new PropertyChangeSupport(this); + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + p.addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + p.removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.removePropertyChangeListener(propertyName, listener); + } + + + public String getFirstName() { + return firstName; + } + + public String getLastName() { + return lastName; + } + + public String getEmail() { + return email; + } + + public int getAge() { + return age; + } + + public void setFirstName(String firstName) { + String oldFirstName = this.firstName; + this.firstName = firstName; + p.firePropertyChange("firstName", oldFirstName, firstName); + } + + public void setLastName(String lastName) { + String oldLastName = this.lastName; + this.lastName = lastName; + p.firePropertyChange("lastName", oldLastName, lastName); + } + + public void setEmail(String email) { + String oldEmail =this.email; + this.email = email; + p.firePropertyChange("email", oldEmail, email); + } + + public void setAge(int age) { + int oldAge = this.age; + this.age = age; + p.firePropertyChange("age", oldAge, age); + } +} \ No newline at end of file Modified: lutinjaxx/trunk/jaxx-example/Validation/src/main/java/examples/Validation/Validation.jaxx =================================================================== --- lutinjaxx/trunk/jaxx-example/Validation/src/main/java/examples/Validation/Validation.jaxx 2008-10-17 16:44:40 UTC (rev 947) +++ lutinjaxx/trunk/jaxx-example/Validation/src/main/java/examples/Validation/Validation.jaxx 2008-10-17 16:44:54 UTC (rev 948) @@ -1,18 +1,30 @@ <Application title="Validation.jaxx"> <style source="Validation.css"/> + + <!-- models --> <Model id='model'/> <Model id='model2'/> + <Identity id='identity'/> + + <!-- errors model --> <DefaultListModel id='errors' onIntervalAdded='ok.setEnabled(errors.size()==0)' onIntervalRemoved='ok.setEnabled(errors.size()==0)'/> - <BeanValidator id='validator' autoField='true' bean='model' errorListModel='errors'> - <field name="text" component="text"/> - <field name="text2" component="text2"/> - <field name="ratio" component="ratio"/> + + <!-- validators --> + <BeanValidator id='validator' bean='model' errorListModel='errors'> + <field name="text"/> + <field name="text2"/> + <field name="ratio"/> </BeanValidator> - <BeanValidator id='validator2' autoField='true' bean='model2' errorListModel='errors'> + <BeanValidator id='validator2' bean='model2' errorListModel='errors'> <field name="text" component="_text"/> <field name="text2" component="_text2"/> <field name="ratio" component="_ratio"/> </BeanValidator> + <BeanValidator id='validator3' autoField='true' bean='identity' errorListModel='errors'> + <field name="email" component="email2"/> + <field name="email" component="email2"/> + </BeanValidator> + <Table fill='both'> <row> <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> @@ -165,6 +177,100 @@ </cell> </row> <row> + <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> + <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}' + layout='{new GridLayout()}' width='250' height='140'> + <Table anchor='west' fill='both'> + <row> + <cell> + <JLabel text='FirstName:'/> + </cell> + <cell weightx='1'> + <org.jdesktop.jxlayer.JXLayer> + <JTextField id='firstName' text='{identity.getFirstName()}' + onKeyReleased='identity.setFirstName(firstName.getText())'/> + </org.jdesktop.jxlayer.JXLayer> + </cell> + </row> + <row> + <cell> + <JLabel text='LastName:'/> + </cell> + <cell weightx='1'> + <org.jdesktop.jxlayer.JXLayer> + <JTextField id='lastName' text='{identity.getLastName()}' + onKeyReleased='identity.setLastName(lastName.getText())'/> + </org.jdesktop.jxlayer.JXLayer> + </cell> + </row> + <row> + <cell> + <JLabel text='Email:'/> + </cell> + <cell weightx='1'> + <org.jdesktop.jxlayer.JXLayer> + <JTextField id='email2' text='{identity.getEmail()}' + onKeyReleased='identity.setEmail(email2.getText())'/> + </org.jdesktop.jxlayer.JXLayer> + </cell> + </row> + + <row> + <cell> + <JLabel text='Age:'/> + </cell> + <cell> + <org.jdesktop.jxlayer.JXLayer> + <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}' + onStateChanged='identity.setAge(age.getValue())'/> + </org.jdesktop.jxlayer.JXLayer> + </cell> + </row> + </Table> + </JPanel> + </cell> + <cell weightx='1' weighty='1' insets='6, 3, 0, 0'> + <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}' + layout='{new GridLayout()}' width='250' height='120'> + <Table anchor='west' fill='both'> + <row> + <cell> + <JLabel text='FirstName:'/> + </cell> + <cell weightx='1'> + <JLabel text='{identity.getFirstName()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text='LastName:'/> + </cell> + <cell weightx='1'> + <JLabel text='{identity.getLastName()}'/> + </cell> + </row> + <row> + <cell> + <JLabel text='Email:'/> + </cell> + <cell weightx='1'> + <JLabel text='{identity.getEmail()}'/> + </cell> + </row> + + <row> + <cell> + <JLabel text='Age:'/> + </cell> + <cell> + <JLabel text='{identity.getAge()}'/> + </cell> + </row> + </Table> + </JPanel> + </cell> + </row> + <row> <cell columns='2' fill="both"> <JPanel border='{BorderFactory.createTitledBorder("Errors")}' layout='{new GridLayout()}' height='200' width='500'> <JScrollPane> Copied: lutinjaxx/trunk/jaxx-example/Validation/src/main/resources/examples/Validation/Identity-validation.xml (from rev 943, lutinjaxx/trunk/jaxx-example/Validation/src/main/resources/examples/Validation/Model-validation.xml) =================================================================== --- lutinjaxx/trunk/jaxx-example/Validation/src/main/resources/examples/Validation/Identity-validation.xml (rev 0) +++ lutinjaxx/trunk/jaxx-example/Validation/src/main/resources/examples/Validation/Identity-validation.xml 2008-10-17 16:44:54 UTC (rev 948) @@ -0,0 +1,32 @@ +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + <field name="firstName"> + <field-validator type="requiredstring" short-circuit="true"> + <message>You must enter a firstName.</message> + </field-validator> + </field> + <field name="lastName"> + <field-validator type="requiredstring" short-circuit="true"> + <message>You must enter a lastName.</message> + </field-validator> + </field> + + <field name="email"> + <field-validator type="requiredstring" short-circuit="true"> + <message>You must enter a value for email.</message> + </field-validator> + <field-validator type="email" short-circuit="true"> + <message>Not a valid e-mail.</message> + </field-validator> + </field> + + <field name="age"> + <field-validator type="int"> + <param name="min">18</param> + <param name="max">88</param> + <message>Age needs to be between ${min} and ${max}</message> + </field-validator> + </field> +</validators> \ No newline at end of file Property changes on: lutinjaxx/trunk/jaxx-example/Validation/src/main/resources/examples/Validation/Identity-validation.xml ___________________________________________________________________ Name: svn:mergeinfo +
participants (1)
-
tchemit@users.labs.libre-entreprise.org