Hello I have a big question around validation.
First I want to start with my example: http://demo.qooxdoo.org/1.3/playground/#%7B%22code%22%3A%20%22qx.Class.define%28%2522demobrowser.demo.data.FormController%2522%252C%250A%257B%250A%2520%2520extend%2520%253A%2520qx.application.Standalone%252C%250A%250A%2520%2520members%2520%253A%250A%2520%2520%257B%250A%2520%2520%2520%2520main%253A%2520function%28%29%250A%2520%2520%2520%2520%257B%250A%2520%2520%2520%2520%2520%2520this.base%28arguments%29%253B%250A%250A%2520%2520%2520%2520%2520%2520%252F%252F%2520create%2520the%2520UI%2520%252F%252F%252F%252F%252F%252F%252F%252F%252F%252F%252F%252F%252F%252F%252F%252F%252F%252F%252F%250A%250A%2520%2520%2520%2520%2520%2520%252F%252F%2520groupbox%250A%2520%2520%2520%2520%2520%2520var%2520groupBox%2520%253D%2520new%2520qx.ui.groupbox.GroupBox%28%2522Simple%2520Form%2522%29%253B%250A%2520%2520%2520%2520%2520%2520groupBox.setLayout%28new%2520qx.ui.layout.Canvas%28%29%29%253B%250A%2520%2520%2520%2520%2520%2520this.getRoot%28%29.add%28groupBox%252C%2520%257Bleft%253A%252010%252C%2520top%253A%252010%257D%29%253B%250A%250A%2520%2520%2520%2520%2520%2520%252F%252F%2520form%250A%2520%2520%2520%2520%2520%2520var%2520form%2520%253D%2520new%2520qx.ui.form.Form%28%29%253B%250A%250A%2520%2520%2520%2520%2520%2520%252F%252F%2520add%2520the%2520form%2520items%250A%2520%2520%2520%2520%2520%2520var%2520titleTextfield%2520%253D%2520new%2520qx.ui.form.TextField%28%29%253B%250A%2520%2520%2520%2520%2520%2520titleTextfield.setRequired%28true%29%253B%250A%2520%2520%2520%2520%2520%2520titleTextfield.setWidth%28200%29%253B%250A%2520%2520%2520%2520%2520%2520form.add%28titleTextfield%252C%2520%2522Title%2522%252C%2520null%252C%2520%2522title%2522%29%253B%250A%2520%2520%2520%2520%2520%2520%250A%2520%2520%2520%2520%2520%2520%252F*var%2520subtitleTextfield%2520%253D%2520new%2520qx.ui.form.TextField%28%29%253B%250A%2520%2520%2520%2520%2520%2520subtitleTextfield.setRequired%28true%29%253B%250A%2520%2520%2520%2520%2520%2520subtitleTextfield.setWidth%28200%29%253B%250A%2520%2520%2520%2520%2520%2520form.add%28subtitleTextfield%252C%2520%2522Subtitle%2522%252C%2520null%252C%2520%2522subtitle%2522%29%253B*%252F%250A%250A%2520%2520%2520%2520%2520%2520%252F%252F%2520buttons%250A%2520%2520%2520%2520%2520%2520var%2520saveButton%2520%253D%2520new%2520qx.ui.form.Button%28%2522Save%2522%29%253B%250A%2520%2520%2520%2520%2520%2520saveButton.setWidth%2870%29%253B%250A%2520%2520%2520%2520%2520%2520form.addButton%28saveButton%29%253B%250A%2520%2520%2520%2520%2520%2520var%2520cancelButton%2520%253D%2520new%2520qx.ui.form.Button%28%2522Cancel%2522%29%253B%250A%2520%2520%2520%2520%2520%2520cancelButton.setWidth%2870%29%253B%250A%2520%2520%2520%2520%2520%2520form.addButton%28cancelButton%29%253B%250A%250A%2520%2520%2520%2520%2520%2520groupBox.add%28new%2520qx.ui.form.renderer.Single%28form%29%29%253B%250A%2520%2520%2520%2520%2520%2520%250A%2520%2520%2520%2520%2520%2520%252F%252Fcase1%253A%2520ok%250A%2520%2520%2520%2520%2520%2520%252F%252Fvar%2520controller%2520%253D%2520new%2520qx.data.controller.Form%28new%2520model.Article%28%29.set%28%257Btitle%253A%2522foobar%2522%257D%29%252C%2520form%252C%2520true%29%253B%250A%2520%2520%2520%2520%2520%2520%252F%252Fvar%2520controller%2520%253D%2520new%2520qx.data.controller.Form%28null%252C%2520form%252C%2520true%29%253B%250A%2520%2520%2520%2520%2520%2520var%2520controller%2520%253D%2520new%2520qx.data.controller.Form%28new%2520model.Article%252C%2520form%252C%2520true%29%253B%250A%250A%2520%2520%2520%2520%2520%2520saveButton.addListener%28%2522execute%2522%252C%2520function%28%29%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520if%2520%28form.validate%28%29%29%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520try%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520this.debug%28%2522form%2520validated%2522%29%253B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520controller.updateModel%28%29%253B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520this.debug%28%2522model%2520updated%2522%29%253B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520alert%28%2522Validated%253A%2520%2522%2520%252B%2520controller.getModel%28%29%29%253B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%257D%2520catch%2520%28ex%29%2520%257B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520this.debug%28ex%29%253B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520this.debug%28ex.getComment%28%29%29%253B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520this.debug%28ex.message%29%253B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520form.getItems%28%29%255Bex.message%255D.setValid%28false%29%253B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520form.getItems%28%29%255Bex.message%255D.setInvalidMessage%28ex.getComment%28%29%29%253B%250A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%2520%2520%2520%2520%257D%250A%2520%2520%2520%2520%2520%2520%257D%252C%2520this%29%253B%250A%2520%2520%2520%2520%2520%2520cancelButton.addListener%28%2522execute%2522%252C%2520form.reset%252C%2520form%29%253B%250A%2520%2520%2520%2520%257D%250A%2520%2520%257D%250A%257D%29%253B%250A%250Aqx.Class.define%28%2522model.Article%2522%252C%2520%257B%250A%2509extend%253A%2520qx.core.Object%252C%250A%2509%250A%250A%2509construct%253A%2520function%28%29%257B%250A%2509%2520%2520%2520%2520this.base%28arguments%29%253B%250A%2509%257D%252C%250A%250A%2509properties%253A%2520%257B%250A%2509%2520%2520%250A%2509%2520%2520%2520%2520title%253A%2520%257B%250A%2509%2520%2520%2520%2520%2520%2520%2520%2520init%253A%2520%2522%2522%252C%250A%2509%2520%2520%2520%2520%2520%2520%2520%2520nullable%253A%2520false%252C%250A%2509%2520%2520%2520%2520%2520%2520%2520%2520check%253A%2520%2522String%2522%252C%250A%2509%2520%2520%2520%2520%2520%2520%2520%2520event%253A%2520%2522changeTitle%2522%252C%250A%2509%2520%2520%2520%2520%2520%2520%2520%2520validate%253A%2520%2522__validateTitle%2522%250A%2509%2520%2520%2520%2520%257D%252C%250A%2509%2520%2520%2520%2520%250A%2509%2520%2520%2520%2520subtitle%253A%2520%257B%250A%2509%2520%2520%2520%2520%2520%2520%2520%2520init%253A%2520%2522%2522%252C%250A%2509%2520%2520%2520%2520%2520%2520%2520%2520nullable%253A%2520false%252C%250A%2509%2520%2520%2520%2520%2520%2520%2520%2520check%253A%2520%2522String%2522%252C%250A%2509%2520%2520%2520%2520%2520%2520%2520%2520event%253A%2520%2522changeSubTitle%2522%252C%250A%2509%2520%2520%2520%2520%2520%2520%2520%2520validate%253A%2520%2522__validateSubTitle%2522%250A%2509%2520%2520%2520%2520%257D%250A%2509%257D%252C%250A%2509%250A%2509members%253A%2520%257B%250A%2509%2520toString%2520%253A%2520function%28%29%2520%257B%2520return%2520this.getTitle%28%29%253B%2520%257D%252C%250A%2509%2520__validateTitle%2520%253A%2520function%28value%29%2520%257B%250A%2509%2520%2520%2520%2520%2520%252F%252F%2520if%2520the%2520length%2520is%2520lower%2520than%25202%250A%2509%2520%2520%2520%2520%2520if%2520%28value.length%2520%253C%25202%29%2520%257B%250A%2509%2520%2520%2520%2520%2520%2520%2520%2520%2520throw%2520new%2520qx.core.ValidationError%28%2522Title%2520must%2520be%2520longer%2520than%2520one%2520character.%2522%252C%2522title%2522%29%253B%250A%2509%2520%2520%2520%2520%2520%257D%250A%2509%2520%257D%252C%250A%2509%2520__validateSubTitle%2520%253A%2520function%28value%29%2520%257B%250A%2509%2520%2520%2520%2520%2520%252F%252F%2520if%2520the%2520length%2520is%2520lower%2520than%25202%250A%2509%2520%2520%2520%2520%2520if%2520%28value.length%2520%253C%25203%29%2520%257B%250A%2509%2520%2520%2520%2520%2520%2520%2520%2520%2520throw%2520new%2520qx.core.ValidationError%28%2522Subtitle%2520must%2520be%2520longer%2520than%2520two%2520characters.%2522%252C%2522subtitle%2522%29%253B%250A%2509%2520%2520%2520%2520%2520%257D%250A%2509%2520%257D%250A%2509%257D%2509%2520%2520%250A%257D%29%253B%22%7D Validation example As you can see I have a model with 2 properties. Each property has its own validation. When I initialize the model with the empty constructor it is in an invalid state. CouchDB for example does not check the data sent, so I can with this model send invalid data to the server. How can I validate (or force the validation) of my model? (Problem 1) The second problem is, that I don't want to write the validation twice. I have once the validation in the model and in the gui (required), but how do I connect them? (Problem 2) Whats the best way in qooxdoo to solve this issue. /Kind regards Christian -- View this message in context: http://qooxdoo.678.n2.nabble.com/Model-Validation-tp5988970p5988970.html Sent from the qooxdoo mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ qooxdoo-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
