-
FEATURED COMPONENTS
First time here? Check out the FAQ!
asked 2013-03-20 16:19:12 +0800
This post is a wiki. Anyone with karma >100 is welcome to improve it.
Whenever I left any field black with constraint = "no empty"
in textbox it shows popup with message that this field should not be null. Now, once I click on the cross for that tag it should be disappear forever until I refresh that page. But as I click on some other component it popups again with same message, Which is very annoying. So, please suggest me how to disable that feature after closing it once.
Thanks in advance for your kind help.
answered 2013-03-22 13:09:07 +0800
This post is a wiki. Anyone with karma >100 is welcome to improve it.
Your can do as you prefere: probably the best way is the following:
public class MyNoEmptyConstraint implements Constraint {
public void validate(Component comp, Object value) throws WrongValueException {
if (value == null || value.toString().equals("")) {
throw new WrongValueException("Huston we have a problem!");
}
}
}
then in your zk.xml:
<error-page>
<exception-type>org.zkoss.zk.ui.WrongValueException</exception-type>
<location>/WEB-INF/sys/error.zul</location>
</error-page>
finally in the error.zul you can do what ever you like... for instance:
<script type="text/javascript" >
alert("Error: ${requestScope['javax.servlet.error.message']}");
</script>
Mind that the native popup error on the textbox comes when you set the constraint="something" in the zul... not if you let your custom constraint to throw the WrongValueEx.
answered 2013-03-21 09:05:49 +0800
This post is a wiki. Anyone with karma >100 is welcome to improve it.
Hi! The popup appears every time you will try to move the focus away from your constrained component. As far as i know there is now way to control this at least Java side.
You can always create your own constraint (implementing org.zkoss.zul.Constraint) and then you can decide how to inform the user that that field is mandatory.
Personally i'm using jGrowl (http://plugins.jquery.com/jgrowl/) for the messaging which is less invasive than the ZK default constraint popup for the user.
Clients.evalJavaScript("$.jGrowl(\"" + message + "\", {theme: 'notif" + level + "', life: 5000 });");
Asked: 2013-03-20 16:19:12 +0800
Seen: 120 times
Last updated: Apr 04 '13