1

How to disable error popup when constraint = "no empty" have been used in the Textbox?

asked 2013-03-20 16:19:12 +0800

this post is marked as community wiki

This post is a wiki. Anyone with karma >100 is welcome to improve it.

updated 2013-04-04 07:08:13 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

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.
delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-03-22 13:09:07 +0800

this post is marked as community wiki

This post is a wiki. Anyone with karma >100 is welcome to improve it.

updated 2013-03-22 13:10:01 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6
http://www.hybris.com/

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.

link publish delete flag offensive edit
0

answered 2013-03-21 09:05:49 +0800

this post is marked as community wiki

This post is a wiki. Anyone with karma >100 is welcome to improve it.

updated 2013-03-21 09:05:49 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6
http://www.hybris.com/

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 });");
link publish delete flag offensive edit

Comments

Wow seems a cool feature..you mean you use this instead of WrongValuesException in your custom constraint class?

azli ( 2013-03-21 15:08:56 +0800 )edit
Your answer
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
2 followers

RSS

Stats

Asked: 2013-03-20 16:19:12 +0800

Seen: 120 times

Last updated: Apr 04 '13

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