0

Injecting a ViewModel using spring in a Listbox

asked 2012-03-15 16:00:15 +0800

pverhoye gravatar image pverhoye
6

Hi,

I'm new to zk so please be kind :-)

I have the following in a zul file:

<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<div apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('com.company.viewModels.UsersListViewModel')">
    <listbox id="usersListbox" model="@load(vm.users)" selectedItem="@bind(vm.selectedItem)">
        <listhead sizable="true">
            <listheader label="Firstname" />
            <listheader label="Lastname" />
        </listhead>
        <template name="model" var="umdbUser">
            <listitem>
                <listcell label="@load(umdbUser.firstName)" />
                <listcell label="@load(umdbUser.lastName)" />
            </listitem>
        </template>
    </listbox>
</div>

The problem is that I am using spring in my UsersListViewModel to inject service that perform the calls to load the list of users. Obviously the code above does not work since the VM bean is not spring loaded. In an other zul file I just use the following notation ${usersListViewModel} and it works, but not here.

Does someone have any help for me? Thanks

BB
Peter

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2012-03-16 11:10:37 +0800

pverhoye gravatar image pverhoye
6

Found the solution myself!

The correct syntax is:
@init(usersListViewModel)
where 'usersListViewModel' is the name of the spring component.

BB
Peter

link publish delete flag offensive edit

answered 2012-03-19 01:14:32 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

http://books.zkoss.org/wiki/Small%20Talks/2011/November/MVVM%20in%20ZK%206%20-%20Design%20your%20first%20MVVM%20page#Syntax_review

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-03-15 16:00:15 +0800

Seen: 206 times

Last updated: Mar 19 '12

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