The Facebook Platform   
    Home  |   Learn AJAX  |   Forum  |    Register  |    Submit Resource  |   Submit Article   |   Contact Us
 

ZK Framework

Home Frameworks ZK Framework

ZK-Framework - Creating the Pages

Category: ZK Framework   |   Comments (0)

Validations

Page 5 of 8


The field id is extended with two validations. The first validation is done while the user inserts some input into the field. For that we provided some code for the onChanging handler. If the user types only white spaces there is the warning not valid on the right side. Otherwise the green note valid is presented.

Sponsored Links
 

 

{qbacode language=XML} if (event.getValue().trim().length() > 0) { idstatus.setValue("valid"); idstatus.setStyle("color:green"); } else { idstatus.setValue("not valid"); idstatus.setStyle("color:red"); } {/qbacode}


The next validation is done in the onChange handler.


{qbacode language=XML} if (self.value != null && self.value.trim().length() == 0) { self.value = ""; throw new WrongValueException(self, "The id shouldn't be the empty string."); } {/qbacode}


We use the possibility to throw a org.zkoss.zk.ui.WrongValueException. If this exception occurs the framework shows an error message linked to the concerned field. The following figure shows such an error message.



 

Sponsored Links
 

 

NOTE: It's important to say that the code in an event handler or a zscript must bevalid XML, because a ZUL page is an XML page. Here, we are confronted with the problem of using some special characters (e.g. & or <). We have two possibilities to use such characters. The first is to use valid XML entities (e.g. &amp;&amp; for &&) or we can embed the code in a CDATA block (<![CDATA[ ? ]]>). For more readable code it's recommended to use the CDATA block variant.




Next Page: Complete Implementation


Read Next: ZK-Framework - Online Media Library
 
Post Your Comment
Members - Please Click here Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification:
 
 Subscribe    

Post Your Comment via FaceBook

Connect with Facebook



 
Comments
 
 
 
 

Sponsored Links

 

Copyright © 2005 - 2010 AjaxWith.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape