Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically add composer while creating a component

Tags:

zk

I need to create a window component from a ZUML using different composers. But i cant figure out how to do this programmatically. It works fine when I apply the composer to the window within the ZUML file.

This works

dataTemplate.zul

<window id="dataTemplateWindow"
apply="dk.dataproces.cpraap.controllers.DataTemplateWindowController">
          ....

Controller

dataTemplateWindow = (Window) Executions.createComponents(
                "dataTemplate.zul", homeWindow, null);

I would like to do something like this

No composer is attached within the ZUML, and it is instead added programmatically.

Map data = new HashMap();
data.put("composer","dk.dataproces.cpraap.controllers.DataTemplateWindowController");
dataTemplateWindow = (Window) Executions.createComponents("dataTemplate.zul", homeWindow, data);

The reason is I need to attach different controllers to the same ZUML.

like image 632
Jens Henrik Avatar asked Jun 28 '26 03:06

Jens Henrik


1 Answers

Your almost there.

You just need to declare in the second zul that the composer comes from the arg map.

You do this in the zul by :

apply="${arg.composer}"

Here is a test fiddle where I did it.

like image 147
chillworld Avatar answered Jul 01 '26 13:07

chillworld



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!