0

Help!!!about a macro component

asked 2009-04-10 06:11:58 +0800

zkusername gravatar image zkusername
9

if i create a macro component,how can i use it in java file.
(the java file i create component dynamiclly)

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2009-04-10 06:37:27 +0800

hideokidd gravatar image hideokidd
750 1 2

updated 2009-04-10 06:38:57 +0800

hi,

I'm not sure about your condition,

1.The macro component you created in zul page, and you want to access it in java file.
2.The macro component you created in java file,

which one?

link publish delete flag offensive edit

answered 2009-04-10 06:47:00 +0800

zkusername gravatar image zkusername
9

2

link publish delete flag offensive edit

answered 2009-04-10 07:57:17 +0800

hideokidd gravatar image hideokidd
750 1 2

hi,

ok, now I make an example to pass the macro component to a java file.
But I create the component as a zul page, which doesn't influence how you pass the component to a java file.

first, the macro page (test2.zul)

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
<window id="win" title="new page title" border="normal">
New Content Here!
</window>
</zk>

The main page (test.zul)

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<?component name="newWindow" macroURI="test2.zul"?>
<zk>
	<newWindow id="newWindow"></newWindow>
<zscript>
<![CDATA[  //@IMPORT
import test.TestMacro;
]]>
	
	TestMacro tm = new TestMacro(newWindow);
	tm.setWindowTitle("new title");
</zscript>
</zk>

The java class to access macro(TestMacro.java)

public class TestMacro {
        HtmlMacroComponent htmlMacroComponent = new HtmlMacroComponent();

	public TestMacro(HtmlMacroComponent htmlMacroComponent){
		this.htmlMacroComponent = htmlMacroComponent;
	}
	
	public void setWindowTitle(String title){
		Window win = (Window) htmlMacroComponent.getFellow("win");
		win.setTitle(title);
	}
}

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: 2009-04-10 06:11:58 +0800

Seen: 143 times

Last updated: Apr 10 '09

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