0

bug in zul with @load

asked 2014-11-06 08:03:22 +0800

chillworld gravatar image chillworld flag of Belgium
5337 4 9
https://github.com/chillw...

updated 2014-11-06 08:04:51 +0800

Hi all,

I'm working on mine new project with zk 7.0.0

Now I need to set a button disabled on 3 requirements :

  1. A specific item must be selected(selectedType).
  2. I have a list where they can drag into => list may not be empty.(dropListModel)
  3. Another list is checkmark="true" multiple="true" => must be a selection.(multipleSelectionListModel)

Note : the names are changed for simplicity.

So I created the following :

<button label="Do something" onClick="@command('commandName')" disabled="@load((vm.dropListModel.empty) || (empty vm.selectedType) || (vm.multipleSelectionListModel.selection.empty))" />

Error :

Org.zkoss.zel.impl.parser.ParseException: Encountered " "empty" "empty "" at line 1, column 24.<|Was expecting:<|    <IDENTIFIER> ...<|
at org.zkoss.zel.impl.parser.ELParser.generateParseException(ELParser.java:2215)

Changed it to :

<button label="Do something" onClick="@command('commandName')" disabled="@load(vm.dropListModel.empty)"/>

Created same error.

Created fiddle :http://zkfiddle.org/sample/3kvld74/29-parsing-error

I use a List here but List as ListModelList has the method isEmpty.

Note:

I'm not looking for a work around, I'm just reporting this issue. Possible work around is creating a method in the viewmodel or for the fiddle : disabled="@load(vm.items.size() eq 0)" or : disabled="@load(vm.items.isEmpty())"

greetz chill.

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2017-03-22 04:00:29 +0800

cor3000 gravatar image cor3000
4596 2 7
ZK Team

updated 2017-03-22 04:04:31 +0800

the EL syntax is quite particular when it comes to lists ... also 'empty' is an operator not expected as a property name.

Simply use @load(empty vm.items)

Quote from: http://docs.oracle.com/javaee/6/tutorial/doc/bnahu.html

If you are accessing an item in an array or list, you must use either a literal value that can be converted to int or the [] notation with an int and without quotes

In fact ListModelList implements the List interface so you can't access other properties directly. Unfortunately that's a limitation of EL expressions in general.

If your model implementation doesn't implement the List interface such as ListModelSet you can access the isEmpty method using: @load(myset['empty'])- still @load(empty myset) looks more consistent.

Robert

link publish delete flag offensive edit
-1

answered 2014-11-08 14:47:16 +0800

Darksu gravatar image Darksu
1991 1 4

Hello chillworld,

At the following url you can find some good example on EL Expressions:

http://books.zkoss.org/wiki/ZKDeveloper'sReference/MVVM/DataBinding/ELExpression

In your case please use the example <groupbox visible="@load(not empty vm.selected)" and modify it accordingly.

Else you could write some simple java code in order to check the variables.

Best Regards,

Darksu

link publish delete flag offensive edit

Comments

@darksu, if you read mine post you see that I use also empty vm.selected The empty at the end is cause I call the java method isEmpty() of a list. As also said in the note where I tell how you can bypass the error.

chillworld ( 2014-11-08 15:08:41 +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: 2014-11-06 08:03:22 +0800

Seen: 71 times

Last updated: Mar 22 '17

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