Re: Handle feedback-Messages with a custom validation framework

2012-11-04 Thread delta458
I already got it working... with the following code:

/...
//Textfields or Form Components GO HERE...

@Override
public void onValidateModelObjects() {
ValidationProcess vp = new ValidationProcess();
vp.validate("Rules.js", r);
msg = "";
if (vp.getConstraintViolations().size() > 0) {

for (String s : vp.getConstraintViolations()) {
if (s.contains(";")) {
String[] splitted = s.split(";");
String elementname = splitted[0];
String errorMessage = splitted[1];

if (elementname.equals("price")) {
//SET Error of Component, will be automatically
display by FeedbackPanel...
price.error(elementname + " " + errorMessage +
". ");
  } else if (elementname.equals("recipient")) {
recipient.error(elementname + " " +
errorMessage);
}
}
}
}
}

//Rest of the Code/



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Handle-feedback-Messages-with-a-custom-validation-framework-tp4653599p4653605.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Handle feedback-Messages with a custom validation framework

2012-11-03 Thread delta458
Hi all,

I am using my own validation, but the view of the form (e.g. if a component
is invalid) should be highlighted or customized within wicket...

So e.g. I have my Wicket Form

/
 
 Recipient
 
 
 
 Details
 
 
/

Then I have my Form.java: Here I set the values of my Java Object "Invoice"
and use *onValidateModelObjects* to override the wicket validation and use
my own validation... This method just calls a simple own created
ValidatorObject that takes care of the validation...
/
public InvoiceForm() {
...

Form form = new Form("inputForm", formModel) {
/*
 * Validation takes place here
 */
@Override
public void onValidateModelObjects() {
ValidationProcess vp = new ValidationProcess();
vp.validate("Rules.js", r);
msg = "";
if (vp.getConstraintViolations().size() > 0) {

for (String s : vp.getConstraintViolations()) {
msg = msg + s;
}
} else {
msg = "no errors.";
}
}
};

//adding Textfields to the Form etc...

...
}/

What I need: Above you can see that my errorMessages will be saved into the
msg String! Now what I want is Wicket to take this String and apply it to
the Wicket FeedBackMessage System or however...

*1. I need to get the component that will be rendered at the moment...
2. I have to set the error Message of this component to my component...

how can I do that?*

I guess I need to override some methods, but I dont know which ones and
where...




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Handle-feedback-Messages-with-a-custom-validation-framework-tp4653599.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org