0

Combobox constraint after binding phase

asked 2021-09-08 16:09:16 +0800

ivtu gravatar image ivtu
11 2

updated 2021-09-09 11:14:00 +0800

hawk gravatar image hawk
2849 1 5
http://hawkphoenix.blogsp... ZK Team

Hi,

I am using MVVM and have use case where custom constraint should be loaded later. It seems combobox does not check 'strict' constraint on server side, but on client side only, so when I use with @load, strict constraint check is skipped..

Here is an example

delete flag offensive retag edit

4 Answers

Sort by ยป oldest newest most voted
0

answered 2021-09-08 17:54:21 +0800

ivtu gravatar image ivtu
11 2

updated 2021-09-09 11:14:56 +0800

hawk gravatar image hawk
2849 1 5
http://hawkphoenix.blogsp... ZK Team

I did one workaround and it works now. Can someone confirm is this good approach?

link publish delete flag offensive edit
0

answered 2021-09-09 11:45:40 +0800

hawk gravatar image hawk
2849 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2021-09-09 13:48:18 +0800

Is there any special reason you have to set a constraint with data binding instead of EL? Since, you usually need to set it once without changing it at run-time. If so , EL works.

When you use data binding, if you don't specify a ViewModel, you have to apply BindComposer, or data binding doesn't work. I don't see it in your zkfiddle. So @load() doesn't work.

<window border="normal" title="Combobox Constraint" apply="org.zkoss.bind.BindComposer"/>

Combobox has an issue that users might enter a non-existed value, you can set it readOnly="true" to avoid this issue. Or use <searchbox> alternatively.

link publish delete flag offensive edit
0

answered 2021-09-14 20:39:27 +0800

ivtu gravatar image ivtu
11 2

Hi, sorry for late answer, I was sick.

I have to use data binding and @load instead of EL. I am re-using templates (UI Template Injection with applying template name and not path of zul). In those templates I cannot use EL, because constraint is calculated later.

So, have I to use apply="org.zkoss.bind.BindComposer" never-mind do I use MVC or not?

Regarding searchbox

That component does not have constraint at all?? How that helps me?

link publish delete flag offensive edit
0

answered 2021-09-15 18:40:05 +0800

hawk gravatar image hawk
2849 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2021-09-17 11:56:23 +0800

why @load(cct) doesn't work in your zkfiddle

I update your case https://zkfiddle.org/sample/3l1o9r9/5-Combobox-Load-Constrain (add BindComposer), the constraint, @load(cct), is set as expected. Since in your original fiddle case, you don't use a ViewModel, you have to apply BindComposer to make data binding work.

In your real application, if the page is injected by <apply>, and you already apply its parent page with BindComposer then the data binding will work. By default, if you use a viewmodel with viewModel="@id(vm)@init(...)", zk will apply a BindComposer implicitly.

why searchbox

As I understand, the reason you put the custom constraint is to make user input can only be one of the combobox items. That's the common problem of combobox: it allows user to enter a value that doesn't exist in comboitem. You can make combobox read-only to avoid users from entering arbitrary values. Or using Searchbox.

Searchbox only allows an end-user to enter a value in its value list, so it doesn't need a custom constraint to validate user input.

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: 2021-09-08 16:09:16 +0800

Seen: 15 times

Last updated: 17 hours ago

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