1

MVVM Form binding Validator

asked 2013-04-25 08:10:57 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2621 3 8
http://emrpms.blogspot.in...

Hi

After reading ZK Documentation on the above subject, i could not able to find way according to my requirement. Here is my requirement.

  1. Form contains some text boxes.
  2. Form contains Save Button.
  3. For fields are mandatory and some want to do some validation based on the user input. For example, if the user enter the email id, we need to validate, it is valid or not.
  4. Now i want to show all the validation message on clicking of the save button in the modal window using grid or listbox.

Is this requirement can be possible using MVVM Form validator ?

delete flag offensive retag edit

Comments

Any help please....

Senthilchettyin ( 2013-04-25 16:35:49 +0800 )edit

GREAT WORK. Thank you benbai.

Senthilchettyin ( 2013-04-29 08:17:41 +0800 )edit

4 Answers

Sort by ยป oldest newest most voted
1

answered 2013-04-27 07:41:46 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

You can do at as below:

  1. Specify an id mapping to validationMessages in zul page.

  2. Call addInvalidMessage to add message into validationMessages with a key as needed in validator.

  3. Then you can get message by @bind(id['key'])

For more information, please refer to

Online demo: (not really need to)

MVVM Form Binding with Validator

Related Code: (these are enough)

MVVMFormBindingwith_Validator.zul

FormBindingWithValidatorTestVM.java

Person.java

and the related article at my blog (not really need to)

ZK MVVM: Form Binding with Validator

link publish delete flag offensive edit
0

answered 2013-04-29 09:05:43 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2621 3 8
http://emrpms.blogspot.in...

updated 2013-04-29 09:06:01 +0800

But how we can get the reference of validation message holders in the VM (JAVA). Your example shows how to retrieve the value from zul. Please help

link publish delete flag offensive edit
0

answered 2013-04-29 10:29:11 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

You can call

ValidationMessages vmsgs = ((BinderCtrl)ctx.getBindContext().getBinder()).getValidationMessages();

but it is not a smple map, please refer to

AbstractValidator.java#addInvalidMessages

ValidationMessagesImpl.java#addMessages

What do you want to achieve?

link publish delete flag offensive edit
0

answered 2013-04-30 07:12:53 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2621 3 8
http://emrpms.blogspot.in...

Very simple.

On Clicking submit button, i do not what to show the error message next to field using label. Instead of that, i would like to show in the modal window in the list/grid with all the messages with ok button.

It is available only ZK EE. Please check Display Multiple Messages here

link publish delete flag offensive edit

Comments

You can do it in AP level as needed (but it is recommended to buy a ZK EE License and use the official feature) , please refer to

http://ben-bai.blogspot.tw/2013/04/zk-mvvm-show-validation-message-in.html

benbai ( 2013-04-30 15:32:49 +0800 )edit

updated, remove all label and use a ListModel to provide all messages, call notify change in validator programmatically.

benbai ( 2013-05-01 03:24:16 +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
1 follower

RSS

Stats

Asked: 2013-04-25 08:10:57 +0800

Seen: 297 times

Last updated: Apr 30 '13

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