-
FEATURED COMPONENTS
First time here? Check out the FAQ!
if i create a macro component,how can i use it in java file.
(the java file i create component dynamiclly)
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?
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); } }
Asked: 2009-04-10 06:11:58 +0800
Seen: 143 times
Last updated: Apr 10 '09