Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9140641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:32:34+00:00 2026-06-17T09:32:34+00:00

Can you please explain how to do form validations on the server side using

  • 0

Can you please explain how to do form validations on the server side using the MVVM approach. I tried it but could not do it effectively. I have done small validations on the client side using intbox etc.
But I want to do validations like:

  1. The value of an attribute should not exceed say 100.
  2. If value of attribute A is filled by the user then attribute B becomes mandatory and like that.
  3. If value of attribute A is 100 and B is 50 then value of attribute C becomes mandatory and cannot exceed 150

I am not able to figure out a way of doing it in MVVM. I am using ZK CE 6.0.0 version.

I tried the code mentioned below:

Validation.zul

<zk>
    <window title="Validation" border="normal"
        apply="org.zkoss.bind.BindComposer" id="validtionWin"
        viewModel="@id('vm') @init('com.nagarro.validator.CustomValidator')">
        <intbox
            value="@save(vm.quantity) @validator(vm.rangeValidator)" />

        <button label="Submit"></button>
    </window>
</zk>

ViewModel
CustomValidator.java

import org.zkoss.bind.ValidationContext;
import org.zkoss.bind.Validator;
import org.zkoss.bind.validator.AbstractValidator;


public class CustomValidator implements Validator{

    private Validator rangeValidator;

    private String quantity;

    /**
     * @return the quantity
     */
    public String getQuantity() {
        return quantity;
    }

    /**
     * @param quantity
     *            the quantity to set
     */
    public void setQuantity(String quantity) {
        this.quantity = quantity;
    }
    @Override
    public void validate(ValidationContext ctx) {


    }

    /**
     * @return the rangeValidator
     */
    public Validator getRangeValidator() {
        return new AbstractValidator() {
            public void validate(ValidationContext ctx) {
                Integer val = (Integer)ctx.getProperty().getValue();
                if(val<10 || val>100){
                    addInvalidMessage(ctx, "value must not < 10 or > 100, but is "+val);
                }
            }
        };
    }

    /**
     * @param rangeValidator the rangeValidator to set
     */
    public void setRangeValidator(Validator rangeValidator) {
        this.rangeValidator = rangeValidator;
    }

}

Please figure out the mistake in the above code. 🙂

I get the following WARNING when I run the above code.

Jan 16, 2013 4:58:07 PM org.zkoss.bind.validator.AbstractValidator
addInvalidMessages:84 WARNING: ValidationMessages not found on binder
org.zkoss.bind.AnnotateBinder@cf7fda, please init it

How should I set the validation Message Please Help. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:32:35+00:00Added an answer on June 17, 2026 at 9:32 am

    Check out this or use constraints for InputElements.
    If you need more details or have problems, please provide some code.

    Edit

    You are missing

    validationMessages="@id('vmsgs')
    

    at your Window.
    Please read this to understand.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please explain to me how this responsive approach works? This was done
Can anyone please explain me what delegateEvents in backbone.js does? The documentation did not
Can someone please explain this phenomenon? I am using Mojarra 2.1.6 - Glassfish 3.1.2.
Can anybody please explain how this could possibly happen? I am completely aware of
I do not know where my head is today, can somebody please explain to
Can someone please explain this to me? I have the following code: <form action=<?php
Can someone please explain this piece of code which I have tried to decipher?
Can some one please explain why this simple form doesnt work? The problem is
Can please someone explain to me or bring me on the way how to
Can someone please explain why ?___SID=U is appearing in some Magento URLs on my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.