0

MVVM WrongValueException

asked 2016-11-07 01:25:45 +0800

psinalberth gravatar image psinalberth
52 6

I can use getBinder().getView() as argument for WrongValueException(Component c, String message) to show validation messages on a zul by throwing WrongValuesException. Does MVVM approach have something like that using no wire components? I've seen some examples using modal window and vmsgs, pointing each "property" on zul but I'd like to show validation messages just like default MVC: top-left-corner, appending all messages.

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-11-07 09:17:27 +0800

Darksu gravatar image Darksu
1991 1 4

Hello psinalberth,

This may work for you in order to create a custom message:

https://www.zkoss.org/wiki/ZKDeveloper'sReference/UIPatterns/UsefulJava_Utilities#showNotification

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2020-10-31 01:58:03 +0800

Arsen gravatar image Arsen
382 5

You may use Clients.wrongValue method like this

public abstract class NotificationValidator implements Validator {

  @Override
  public void validate(ValidationContext ctx) {
    Component component = ctx.getBindContext().getComponent();
    String message = getValidationMessage(ctx);
    if (StringUtils.isNotEmpty(message)) {
      ctx.setInvalid();
      Clients.wrongValue(component, message);
    } else {
      Clients.clearWrongValue(component);
    }
  }

  protected abstract String getValidationMessage(ValidationContext ctx);

it show validation message the same way as WrongValueException

link publish delete flag offensive 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
1 follower

RSS

Stats

Asked: 2016-11-07 01:25:45 +0800

Seen: 26 times

Last updated: Oct 31

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