0

MVVM : How to use listbox.selectedIndex directly into zul ?

asked 2013-07-18 13:34:53 +0800

Mychal gravatar image Mychal
151 3

Hi,

my problem is simple. I have a listbox defined like this :

                        <listbox id="refTypeL" 
                            model="@load(vm.referenceTypes)"
                            selectedItem="@bind(vm.refTypeSelected)"
                            mold="select"
                            disabled="@load(not empty vm.id)"
                            width="150px"
                            sclass="h3Field" >
                            <template name="model" var="itemRefT">
                                <listitem label="@load(itemRefT.typeTranslated)" />
                            </template>
                        </listbox>

And i would like to show a div depending on selection in listbox... I try this :

<div sclass="h3" visible="${refTypeL}.selectedIndex eq 2">

But selectedIndex is not refreshed.

Any idea ? Thank you

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-07-19 06:08:30 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

updated 2013-07-19 06:09:08 +0800

What i can suggest you,

1-First create a class variable in View Model.

2-Create a new method and Notify This Variable when any item selected and inside this method you can write the logic to get selectedindex and update your class variable and bind this variable your zul page .

3- Now in zul the above bind variable will be use in div's visible attribute .

link publish delete flag offensive edit

Comments

yeah, by viewmodel no pb exactly as i expected. With the same example, no need to create a variable we already had it, here the solution: visible="@load(vm.refTypeSelected.type eq 'test')"

Mychal ( 2013-07-29 15:25:57 +0800 )edit
2

answered 2013-07-19 11:16:55 +0800

nsharma gravatar image nsharma flag of India
917 1 11

Hi mychal,

do it like :

<div sclass="h3" visible="${refTypeL.selectedIndex eq 2}">

reply if this works.Otherwise do as @sjoshi suggests,that's also a good idea to have flexibility in your code.

link publish delete flag offensive edit

Comments

i have tried ${refTypeL.selectedIndex} eq 2 and ${refTypeL.selectedIndex eq 2}. Nothing is working. The pb is that selectedIndex is not refreshed. yeah the solution in viewmodel is easy to apply, but i was thinking that EL expression were there to gain time and reduce code :p Thank you anyway ;-)

Mychal ( 2013-07-29 15:16:56 +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: 2013-07-18 13:34:53 +0800

Seen: 39 times

Last updated: Jul 19 '13

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