-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Good Day,
I have a zul file as below
<?page title="new page title" contentType="text/html;charset=UTF-8"?> <zk> <window title="new page title" border="normal"> New Content Here! <menubar id="menubar" apply="com.test.MenubarCtrl" ></menubar> </window> </zk>
and MenubarCtrl.java as below :
public class MenubarCtrl extends GenericForwardComposer { /** * */ private static final long serialVersionUID = 1L; private Menubar menubar; private Menuitem item; @Override public void doAfterCompose(Component comp) throws Exception { // TODO Auto-generated method stub super.doAfterCompose(comp); item = new Menuitem(); menubar = new Menubar(); item.setParent(menubar); } public Menubar getMenubar() { return menubar; } public void setMenubar(Menubar menubar) { this.menubar = menubar; } }
but I can't see menubar component when I run my project,
how to render menubar component in Java as controller.
thanks for advice;
Please use apply attribute in Window Component Something like this..
[code<window title="new page title" border="normal"apply="com.test.MenubarCtrl" >
And if you are using apply attribute you have to wire the Component from its id ,In Your case your MenuBar id is <b >id="menubar"</b> So in Java File you have to Wire this Component like this..
Andnow with this MenuBar do anhythind you want
Just quoting... ;)
Please use apply attribute in Window Component Something like this..
<window title="new page title" border="normal"apply="com.test.MenubarCtrl" >
@Wire("menubar") Menubar menuBar;
The GenericForwardComposer has the AutoWireing in it.
.. extends GenericForwardComposer {
private Menubar menubar; // autowired
is enough for getting access to the components by component ID.
Yes, correct!
Thanks @Steva77, and @terrytornado
ok thank All,
now I can generate menubar with menupopup and menuitem, but I have a problem with menuitem generated.
<menubar id="menubar" apply="com.trio.test.MenubarCtrl" autodrop="true" /> <borderlayout height="100%"> <north height="99%" splittable="true" collapsible="true" flex="true" border="normal"> <iframe id="iframe" src=""> </iframe> </north> </borderlayout>
*.java
for (Mstmenu mt : listMenu){ if (mt.getVparent().equalsIgnoreCase("MASTERMENU")){ item = new Menuitem(); item.setLabel(mt.getVtitle()); item.setParent(menupopupPMT); item.setImage(mt.getVimage()); //item.setHref(mt.getVlocation()); iframe = new Iframe(); iframe.setSrc(mt.getVlocation()); menupopupPMT.setParent(menuPMT); menuPMT.setParent(menubar); } }
How to add event to item ( menuitem object ), with mt.getVlocation. (mt.getVlocation = path_to_zul_file.zul), the event will target to iframe ( Iframe object ).
Thanks.
I modified that above code :
if (mt.getVparent().equalsIgnoreCase("MASTERMENU")){ item = new Menuitem(); item.setLabel(mt.getVtitle()); item.setParent(menupopupPMT); item.setImage(mt.getVimage()); item.addEventListener(Events.ON_CLICK, new EventListener() { @Override public void onEvent(Event arg0) throws Exception { iframe = new Iframe(); iframe.setSrc("mypage.zul"); } }); menupopupPMT.setParent(menuPMT); menuPMT.setParent(menubar); }
but iframe doesnt render the "mypage.zul" ,, why ?
thanks
I got it ,, with setParent for iframe additional.
if (mt.getVparent().equalsIgnoreCase("MASTERMENU")){ item = new Menuitem(); item.setLabel(mt.getVtitle()); item.setParent(menupopupPMT); item.setImage(mt.getVimage()); item.addEventListener(Events.ON_CLICK, new EventListener() { @Override public void onEvent(Event arg0) throws Exception { iframe.setSrc(mt.getVlocation()); <b >iframe.setParent(win);</b> } }); menupopupPMT.setParent(menuPMT); menuPMT.setParent(menubar); }
Thank all.
Asked: 2012-10-27 03:10:04 +0800
Seen: 182 times
Last updated: Nov 03 '12