0

If statement

asked 2012-05-24 20:10:50 +0800

samuel5 gravatar image samuel5
51

Hi.

I want to show some columns in a grid. But I only want to show the columns that respect the following statement:
@load(vm.numCol)> 2

I've made some tests and the value of @load(vm.numCol) is 4.

But I'm trying to verify this condition this way:

<auxheader colspan="1" if="${@load(vm.numCol)>2}">

But I have this exception: org.zkoss.zel.ELException: Error Parsing: ${@load(vm.numCol)>2}

So I know that the if clause has some errors. I read this examples: http://books.zkoss.org/wiki/ZK_Developer's_Reference/UI_Composing/ZUML/EL_Expressions#Overview

But I dont understand whats wrong. I cannot put @load(vm.numCol) inside a EL?

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2012-05-24 20:38:01 +0800

Matze2 gravatar image Matze2
773 7

updated 2012-05-24 20:45:04 +0800

You cannot mix "$" with "@". $ is evaluated once at page loading time. And "if" works only with "$".
It tries to interpret it as EL expression and "@load..." isn't.
Maybe (no idea if this works) you can play with "visible" attribute instead.

link publish delete flag offensive edit

answered 2012-05-24 21:31:51 +0800

samuel5 gravatar image samuel5
51

Thank you, I'll try.
And can I create a variable in zul? If so, i would be able to create a var inicialized with the @load(vm.numCol) and in the if statement I could see if the variable was >2 or >3. Is it possible?

link publish delete flag offensive edit

answered 2012-05-25 06:25:12 +0800

Matze2 gravatar image Matze2
773 7

The solution depends on the following questions:
- is the number of columns dynamic within page lifecycle
- where is this value set

Based on the answers it means:
- you can or cannot use "if"
- how you get the value, e.g. from ${param.numColumns}, ${arg.numColumns}, etc.

To your question: Of course you can define a variable in a <zscript> section and use it in "if". A lot of ZK demo examples do that (the definition).
But keep in mind that the superior solution is to use a composer or view model.

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2012-05-24 20:10:50 +0800

Seen: 156 times

Last updated: May 25 '12

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