macro with templates

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

johnc gravatar image johnc

hey guys, I got a macro component like this

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

then I just use the macro

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

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

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


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

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

chillworld gravatar image chillworld flag of Belgium
5322 4 9

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



link publish delete flag offensive edit

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 {
    public void compose() {

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

1 follower



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

Seen: 9 times

Last updated: Mar 02

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