0

Handling the constraint error for datebox

asked 2009-08-03 14:26:48 +0800

rajivbandi gravatar image rajivbandi flag of India
207

Hi,
I have a datebox with some constraint. When I use lenient="false", it shows a error message box beside the datebox. How can I catch this error and handle it without the default errorbox? (Please give some Java code if possible).
Thanks in Advance

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2009-08-04 15:03:52 +0800

sly3 gravatar image sly3
99 1

I do something this

<zscript>

void reset(){
username.setValue("");
password.setValue("");
con_password.setValue("");
}

void register(){
String errorMsg = "";
if(username.getValue()==null || username.getValue().trim().equals("")){
errorMsg += "Username cannot be empty!\n";
}

/*if(password.getValue()==null || password.getValue().trim().equals("")){
errorMsg += "Password cannot be empty!\n";
}else*/ if(!password.getValue().equals(con_password.getValue())){
errorMsg += "Passwords do not match!\n";
}

if(!errorMsg.equals("")){
Messagebox.show(errorMsg,"Error",Messagebox.OK,Messagebox.ERROR);
}else {
registerWnd.onRegister();
}
}
</zscript>
<grid>
<zscript><![CDATA[
Constraint ctt = new Constraint() {
public void validate(Component comp, Object value) throws WrongValueException {
org.zkoss.zul.Calendar oggi=new Calendar();
if (oggi.getValue().getYear()-value.getYear()<18)
throw new WrongValueException(comp, "Devi essere maggiorenne");
}


}
]]>
</zscript>
<rows>
<row>Username: <textbox id="username" constraint="no empty"/>*,a-zA-Z,0-9</row>
<row>Password: <textbox id="password" constraint="no empty" type="password"/>*</row>
<row>Confirm Password: <textbox id="con_password" constraint="no empty" type="password"/>*</row>
<row>email: <textbox id="email" width="150px"
constraint="/.+@.+\.+/: Please enter an e-mail address" />*</row>
<row>Birthday: <datebox id="bdate" width="150px" constraint="${ctt}"/>*</row>
<row>
<button label="Reset" onClick="reset()"/>
<button label="Register" onClick="register()"/>
<!-- <button label="Back to Login" onClick="registerWnd.back()"/> -->
</row>
</rows>
</grid>
</window>

link publish delete flag offensive edit

answered 2009-08-06 11:08:38 +0800

rajivbandi gravatar image rajivbandi flag of India
207

Thank you sly3. I implemented a nearly similar solution. Found it in Developer Guide.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-08-03 14:26:48 +0800

Seen: 228 times

Last updated: Aug 06 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More