0

macro with templates

asked 2018-02-26 14:47:08 +0800

johnc gravatar image johnc
1

hey guys, I got a macro component like this

<div>
    <div id="aContainer"></div>
</div>

then I just use the macro

<?component name="mymacro" macroURI="/macros/mymacro.zul" class="a.b.c.MyMacro"?>

<mymacro>
  <template name="model" var="myvar">
    <label value="${myvar.name}"/>
  </template>
</mymacro>

the question is , how can I get the template in "a.b.c.MyMacro", when I call getTemplateNames() or getParent().getTemplateNames(), they all returned an empty array. Need yall help, thanks.

delete flag offensive retag edit

Comments

John, Can you explain what you are trying to achieve? You can pass an object to the macro also, in other words having the label in your macro.

chillworld ( 2018-02-26 15:06:02 +0800 )edit

I just want to customize the macro's content, consider the macro is a common page.The content decided by the template.

johnc ( 2018-02-26 15:18:47 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2018-02-26 15:41:28 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

If you don't use CE (for the @ref), you maybe have it simpler with the apply tag?

http://zkfiddle.org/sample/3bns4am/1-apply-tag

Chill.

link publish delete flag offensive edit
0

answered 2018-03-02 15:12:26 +0800

cor3000 gravatar image cor3000
4293 1 7
ZK Team

hmm when I do what you describe I get the list of template names:

import org.zkoss.zk.ui.HtmlMacroComponent;
public class MyMacro extends HtmlMacroComponent {
    @Override
    public void compose() {
        super.compose();
        System.out.println(this.getTemplateNames());
    }
}

Does this work on your side? did you try something different?

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: 2018-02-26 14:47:08 +0800

Seen: 9 times

Last updated: Mar 02

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