0

What's wrong with my el expression?

asked 2014-12-01 02:33:57 +0800

bkstorm gravatar image bkstorm
38 3

updated 2014-12-01 09:42:56 +0800

                <listitem>
                <listcell label="${forEachStatus.index+1}" />
                <listcell label="${each.deptName}" />
                <listcell label="${each.posName}" />
                <listcell label="${each.userName}" />
                <listcell>
                    <label
                        value="${$composer.loadLabelProcessType(each.processType)}" />
                    <image src="/Share/img/icon/user.gif"
                        width="20px" height="20px" tooltiptext="Đổi vai trò">
                        <attribute name="onClick">
                            self.previousSibling.setValue($composer.onChangeProcessType(each.processType));
                        </attribute>
                    </image>
                </listcell>
            </listitem>

self.previousSibling.setValue($composer.onChangeProcessType(each.processType));
When the image receives a click event, it will change label's value. But I can't use "each" in el expression, zk show an error: "each cannot be resolved to a variable". What's wrong? I tried many way but not solve the problem:
- self.previousSibling.setValue($composer.onChangeProcessType(${each.processType}));
- self.previousSibling.setValue(${$composer.onChangeProcessType(each.processType)});
- ${self.previousSibling.setValue($composer.onChangeProcessType(each.processType))};

delete flag offensive retag edit

3 Answers

Sort by » oldest newest most voted
0

answered 2014-12-01 20:28:37 +0800

windeyu gravatar image windeyu flag of United States
288 3

I may be wrong, but my understanding is that the EL expression is evaluated when the page is being composed. The onClick callback is executed after the page has been rendered. The EL variable "each" is already no longer available during the onClick event.

What I've done in a similar case of my own is to save the "each" value inside a custom attribute at the time when the page is composed. In the callback method, you can get the custom attribute value back. Something like below but you have to try and modify it:

<image>
    <custom-attributes myELvalue="${each.processType}"/>
    <attribute name="onClick">
        var value = self.getAttribute("myELvalue");
        self.previousSibling.setValue($composer.onChangeProcessType(value));
    </attribute>
</image>
link publish delete flag offensive edit
0

answered 2014-12-01 10:46:20 +0800

mirekciul gravatar image mirekciul
1

that's really strange, ill look closer to this

link publish delete flag offensive edit
0

answered 2014-12-02 13:29:30 +0800

bkstorm gravatar image bkstorm
38 3

Windeyu, you're right, it works. Thank you very much.

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: 2014-12-01 02:33:57 +0800

Seen: 30 times

Last updated: Dec 02 '14

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