0

can i show the error message like the textbox's constraint style

asked 2011-10-08 04:48:59 +0800

newflypig gravatar image newflypig
61 1

if the textbox's value don't match its constriant properties
the textbox will show a errormessage right of it.

when i do something else
just like checking user's input in the database
can i show a error message like this?

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2011-10-08 04:57:55 +0800

newflypig gravatar image newflypig
61 1

sorry,i see the method setErrorMessage()

link publish delete flag offensive edit

answered 2011-10-08 05:04:19 +0800

RichardL gravatar image RichardL
768 4

You can have your own implementation of Constraint:

public class MyConstraint implements Constraint,
        java.io.Serializable {...

and override the validate method:

@Override
    public void validate(Component comp, Object value)
            throws WrongValueException {
        if (comp instanceof Textbox) {
            String enteredValue = (String) value;
            if (!enteredValue.isEmpty()) {
               //your logic here
            } else {
                throw new WrongValueException(comp, "Your wrong value label here");
            }
        }
    }

then set your Constraint to the textbox: tb.setConstraint(new MyConstraint());

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: 2011-10-08 04:48:59 +0800

Seen: 290 times

Last updated: Oct 08 '11

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