Form Binding questions

asked 2021-04-15 00:50:47 +0800

aUser gravatar image aUser
123 4


I don't understand very well how form binding works. I have a few questions. I red form binding and it was pretty clean i'd say. I then red form binding validation which was something i needed for my application. My questions are:

A zul page uses a form like this:

<window form="@id('proxy') @load(vm.indexExtraction) @save(vm.indexExtraction, before='saveIndex') 
        @validator('myValidator', proxyIndex=proxy) "
    viewModel="@id('vm') @init('myVM')">

myVM has a init method which inizialites the object indexExtraction received like this:

    public void init(@ExecutionArgParam("indexExtraction") IndexExtraction indexExtraction) {
       // operations on indexExtraction..

Is the proxy object built after the init function? So that the proxy objects has the correct settings once the zul page is set up?

I don't really understand the validation context.. How to know the "main property" when it comes to validation? In the last link above, it says:

Shipping date is the main property to be validated. The way to retrieve other properties is different than the main one

But there are two different validators for two different dateboxes, how is the main property set there?

Last question is: say i have to validate objects that are managed with comboboxes, maybe i have a collection of complex objects and the combobox that manages them is something like this:

<combobox readonly="true" onChange="@command('updateIndexNames', proxyIndex=proxy)"
model="@load(vm.categories) @template('categories')" selectedItem="@bind(proxy.categoryDecode)">
    <template name="categories" var="category">
        <comboitem value="@load(category.id)" label="@load(category.description)" />

The updateIndexNames command simply updates another combobox below based on the selected value here. When i select a new category here, the combobox below becomes blank (which is fine). Now in the validator (form binding) how am i supposed to check if the value of the combobox below is not null? I've tried

if (proxyIndex.getIndexNameDecode().getId() == null) {
    addInvalidMessage(ctx, "indexName", "gedIndexExtractionError");

Here indexNameDecode is the selected item of the combobox below the one that manages categories, but something strange happens.. proxyIndex.getIndexNameDecode() shows from debug view:

Decode { id = null, description = null }

But proxyIndex.getIndexNameDecode().getId():

id = 5;  // as an example, 5 here is most likely an older value

I don't understand how can this be different.

Any help?

delete flag offensive retag edit


such long (multiple) questions are not really suitable to be answered in a forum like this. Please consider splitting them up into multiple questions and please provide runnable code e.g. on https://zkfiddle.org so anyone trying to help can have a quick look and to provide a change efficiently.

cor3000 ( 2021-04-28 11:55:19 +0800 )edit

if that's too much work, you may consider contacting our support to get dedicated help or even some kind of ZOOM coaching session

cor3000 ( 2021-04-28 11:57:28 +0800 )edit
Be the first one to answer this question!
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

1 follower



Asked: 2021-04-15 00:50:47 +0800

Seen: 3 times

Last updated: Apr 15

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