-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi:
I have a index page like this....
<?xml version="1.0" encoding="UTF-8"?>
<zk>
<borderlayout id="index1">
<north size="115px">
<borderlayout>
<north size="90px">
</north>
<south size="25px">
<menubar id="menuIndex">
<menu label="Iniciar-Proceso" src="/img/computer1_16x16.gif">
<menupopup>
<menuitem label="ADD-ET" src="/img/computer2_16x16.gif" onClick="cargar.src = "equipoTecnologico.zul"" />
<menuseparator />
<menuitem label="ADD-Rol" src="/img/group.gif" onClick="cargar.src = "rol.zul""/>
<menuseparator />
<menuitem label="ADD-Componente" src="/img/computer2_16x16.gif" onClick="cargar.src = "View-Componente.zul""/>
<menuseparator />
<menuitem label="ADD-Dato" src="/img/computer2_16x16.gif" onClick="cargar.src = "View-Dato.zul""/>
<menuseparator />
<menuitem label="ADD-Función" src="/img/computer2_16x16.gif" onClick="cargar.src = "View-Funcion.zul""/>
</menupopup>
</menu>
</menubar>
</south>
</borderlayout>
</north>
<center>
<include id="cargar" src="" />
</center>
<south size="18px">
</south>
</borderlayout>
</zk>
When I load page "rol.zul" first time it work correctly, but if I load another one (anyone)
and try to load "rol.zul" again using the menu option I will get the following error:
org.zkoss.zk.ui.UiException - You cannot access components belong to other desktop
rol.zul is using a controller named rolviewcontroller that is created
on the SessionInit listener class.
Here is the code...
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="./winRol"?>
<?page title="Roles" contentType="text/html;charset=UTF-8"?>
<zk>
<window id="winRol" width="100%" height="100%" apply="${sessionScope.rolController}">
<borderlayout>
<north size="0px">
</north>
<west size="640px" splittable="true" flex="true">
<borderlayout id="beanSummary"><!-- ******************** Extra Control ******************** -->
<north border="none" >
<div>
<hbox>
<button id="rolCreate" label="Nuevo" image="/img/file_16x16.gif"/>
<button id="rolUpdate" label="Editar" image="/img/edit_16x16.gif"/>
<button id="rolDelete" label="Eliminar" image="/img/delete_16x16.gif"/>
<separator/>
<separator/>
Filtro:
<combobox id="filt" >
<comboitem label=""/>
<comboitem label=""/>
</combobox>
</hbox>
<paging id="rolPaging"/>
</div>
</north>
<!-- ******************** List View of Table ******************** -->
<center border="none" flex="true">
<listbox id="listbRol" fixedLayout="true" multiple="true" checkmark="true" style="border:none"
mold="paging">
<!-- ******************** Generated By Bean Field Def ******************** -->
<listhead sizable="true">
<listheader id="descrip" label="Descripcion" />
</listhead>
<!-- ******************** Generated By Bean Field Def ******************** -->
<listitem>
</listitem>
</listbox>
</center>
</borderlayout>
</west>
<center>
<div id="rolDetail">
<!-- ******************** view mode ******************** -->
<div id="beanView" width="100%">
<grid width="100%" >
<columns>
<column align="right" width="90px"/>
<column align="left"/>
</columns>
<rows>
<row >Descripcion :<label id="lbDescRol" /></row>
</rows>
</grid>
<separator/>
</div>
<!-- ******************** edit mode ********************
<div id="rolEdit" >
<grid width="100%" fixedLayout="true">
<columns>
<column align="right" width="90px"/>
<column align="left"/>
</columns>
<rows>
<row>Descripcion :<textbox id="Descripcion" /></row>
</rows>
</grid>
<separator/>
<div align="right">
<hbox>
<button id="rolSave" label="Guardar" image="/img/save_16x16.gif"/>
<button id="rolCancel" label="Cancelar" image="/img/cancel.png"/>
</hbox>
</div>
</div> -->
</div>
</center>
</borderlayout>
</window>
</zk>
this is the class...
public class RolViewController extends ViewController
{
protected Listbox listbRol;
protected Combobox filt;
protected Button rolCreate, rolUpdate, rolDelete;
protected ListModelList listModelList;
protected Label lbDescRol;
@Override
public void doAfterCompose(Component window) throws Exception {
super.doAfterCompose(window);
baseListBean = new RolListBean("descRol");
baseListBean.setServiceLocator(Main.getServiceLocatorBean());
baseListBean.fillBeanList();
listModelList = new ListModelList();
listModelList.addAll(baseListBean.getBeanList());
listbRol.setModel(listModelList);
listbRol.setItemRenderer(this);
listbRol.addEventListener("onSelect", new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
int index = listbRol.getSelectedIndex();
RolViewBean rolViewBean = (RolViewBean) listModelList.get(index);
lbDescRol.setValue(rolViewBean.getDescRol());
}
});
}
@Override
public void render(Listitem listItem, Object data) throws Exception {
RolViewBean rol = (RolViewBean ) data;
(new Listcell(rol.getDescRol())).setParent(listItem);
}
@Override
public void render(Comboitem arg0, Object arg1) throws Exception {
}
/**
}
this is the listener class...
public class CetSessionInit implements SessionInit {
@Override
public void init(Session session, Object request) throws Exception {
CompoViewController compoControler = new CompoViewController();
session.setAttribute("compoControler", compoControler);
RolViewController rolController = new RolViewController();
session.setAttribute("rolController", rolController);
return;
}
}
this is the zul.xml
<zk>
<listener>
<description>MyController Session Initialiser</description>
<listener-class>cet.controller.CetSessionInit</listener-class>
</listener>
</zk>
Did anyone knows what this happen and how can be avoid?
RolviewController is share controller (another zul page use it) so I need it to be a singleton.
Regards, Reynaldo.
You cannot share a controller. It has to be a different one for each page. This is probably what your problem is.
Hi:
The share controller is not the problem, this class is shared by rol.zul and a popup window that shows when I press the "Nuevo" button, that part works fine but if I move to another page (with another controller) and try to go back using the menu option I get the error. Maybe is there a way to reload the same page in the desktop??
Hi!!.... I've solved my problem :D
I had my controller definition like the following:
<window id="win" width="1845px" apply="${sessionScope.myBean}">
and I changed it by:
<zscript> <![CDATA[ import com.domain.bean.MyBean; MyBean myBean = new MtBean(); ]]> </zscript> <window id="win" width="1845px" apply="${myBean}">
Because at session initialization
apply="${sessionScope.myBean}"
This error message you got is expected behavior. Basically, after you open the second tab in the same browser, a new desktop is created and the old desktop (first tab) is removed and all the view components it contains are made invalid. Therefore, when you go back to the first tab and click on something. This event will no longer belongs to the new desktop.
Asked: 2009-08-07 17:17:36 +0800
Seen: 2,103 times
Last updated: Sep 16 '16