How call a file zul into method of renderer class

asked 2022-03-01 17:55:58 +0800

Cashjon91 gravatar image Cashjon91
101 2

Hi guys, I have a renderer.java class that shows three dots in listview, when clicking on these dots, a small dialog box opens with an "add note" string. By clicking on "add note" you have to open a modal (window) that contains two buttons and one textbox. The problem is, I can't get the modal back. I am attaching the piece of code where the modal must be called.


private void renderOscartielleLockerOccupationModel(final Listcell parentCell, final ListColumn configuration, final Object object,
      final String stringEvents, final String stringProductList, final String stringOperation, final String stringAddNode)
    Box box = getBox();

    final Image btn = new Image(dots_icon);
    OscartielleLockerOccupationModel occupationModel = (OscartielleLockerOccupationModel) object;

    ContextualMenu menu = new ContextualMenu(btn, parentCell);
    OrderModel order = getOrderModel(occupationModel);

    if (order != null)
        menu.addMenuItem(stringEvents, event1 ->
    menu.addMenuItem(stringOperation, event1 ->

    if (order != null)
        menu.addMenuItem(stringProductList, event1 ->

    menu.addMenuItem(stringAddNode, event1 ->
      ....here must call the Modal wizard....

       // Window window = (Window) Executions.createComponents("addnotemodal.zul",);


    fireComponentRendered(box, parentCell, configuration, object);



<widget xmlns="http://www.zkoss.org/2005/zul"
        xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.hybris.com/schema/cockpitng/zul/zul.xsd"
        height="100%" style="overflow-y:auto; margin-left:50px;">



 <window id="window" border="normal" width="100%" height="250px" mode="modal" visible="true" >

    <div id="mainCnt" width="100%" style="position: relative;" height="100%" >
        <div height="100%" style="background: white;">
            <vlayout height="100%" spacing="none" sclass="yrb-modal-content">

                <div height="100%">
                    <textbox id="textbox" visible="true" width="150px"/>

                <hlayout sclass="yrb-modal-controls yw-wizard-navigation">
                    <button id="cancelBtn" label="${c:l('action.addnote.cancel')}" />
                    <button id="applyBtn" label="${c:l('action.addnote.apply')}" sclass="yw-btn-primary" />




public class AddNoteController extends CollectionBrowserController

{ private static final Logger LOG = LoggerFactory.getLogger(AddNoteController.class);

private Textbox textbox;

private Window window;

@SocketEvent(socketId = "inputObject")
public void onInputObject(final Object object)


@ViewEvent(componentID = "applyBtn", eventName = "onClick")
public void perform()


@ViewEvent(componentID = "cancelBtn", eventName = "onClick")
public void dispose()


delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2022-03-02 16:03:31 +0800

MDuchemin gravatar image MDuchemin
2228 1 5
ZK Team

Let's see if I got this right:

You are creating a modal window from a zul snippet at

Window window = (Window) Executions.createComponents("addnotemodal.zul",);

There is a few things missing here (arguments, page, parent, etc) but I'm assuming you cut out the end for this sample? After you have created the window component, you need to make sure it is "in the page". That will happen automatically in some of the createComponents overloads (if you pass a parent, or a page), but it's possible that the component is also created without being attached, if you are calling the most basic createComponents(snippet, argument); overload.

If your window is not attached to the page, then you will need set the page directly with window.setPage(myPage);

Now for the next possible issue. After your window has been closed, it is detached.


Detached component is essentially marked for cleanup. If you want to display "the same" component again, you have 2 options. You can either create another copy of the same snippet using execution.createComponents, or you can keep a reference to the original object, then re-attach it when it needs to be shown again.

You mentioned " I can't get the modal back. " which is not clear to me. Does it fail to show the first time? or does it show, gets detached, and then you can't open it again? Can you describe step by step until the point of failure?

If you have any error message or exception in your logs / console, it would be good to see what issue is actually happening.

link publish delete flag offensive edit


fyi, general doc for loading zul code in java is here: https://www.zkoss.org/wiki/ZKDeveloper'sReference/UIComposing/ZUML/LoadZUMLinJava

MDuchemin ( 2022-03-02 16:04:06 +0800 )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: 2022-03-01 17:55:58 +0800

Seen: 8 times

Last updated: Mar 02

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