0

Macro components: dynamic properties

asked 2018-05-03 06:50:49 +0800

psinalberth gravatar image psinalberth
52 6

Hi. I'm trying to create a macro component like a wizard. Just like a tutorial from ZK page, my Wizard extends HtmlMacroComponent. In zul, I'm doing something like

<wizard foo="bar" wizardModel="@init(vm.wizard)"/>

I can get foo value by using ${arg.foo} on wizard.zul but wizardModel is always null. I intend to use it to be wizard's viewmodel.

That's how I've coded wizard.zul:

<zk>
  <div viewModel="@id('wizard') @init(wizardModel)">
    ...
  </div>
</zk>
delete flag offensive retag edit

Comments

did you try just changing the wizardModel to the real declaration of the viewmodel there?

chillworld ( 2018-05-04 15:03:29 +0800 )edit

Hi! I was trying to use viewModel and my custom attribute, but I forgot to put @Init on VM. After fixing it, I could access all properties. Thanks!

psinalberth ( 2018-05-08 19:18:36 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-05-08 18:56:25 +0800

cor3000 gravatar image cor3000
4158 1 7
ZK Team

@init executes after the component was created. The wizard example was designed to demonstrate how shadow elements improve certain limitations in older approaches in ZK such as macro or the <include> component.

If you were planning to use @init() then a static EL should work as it evaluates before the component is created.

<wizard foo="bar" wizardModel="${vm.wizard}"/>
link publish delete flag offensive edit

Comments

Thanks! I'll try later. ATM I'm using @Init and using viewModel attribute instead that custom one, like chillworld said. ViewModel was always null because I forgot @Init on my VM class. My bad =(. Thanks!

psinalberth ( 2018-05-08 19:16:14 +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
2 followers

RSS

Stats

Asked: 2018-05-03 06:50:49 +0800

Seen: 6 times

Last updated: May 08

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