0

how to apply a controller to a component on the fly? [closed]

asked 2010-11-29 08:14:33 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6
http://www.hybris.com/

Hi all!

Quicky simple question: is there any proper way to apply a controller to a Component via Java on the fly?

Thanks in advance!
Giovanni

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by gganassin
close date 2013-05-10 14:20:14

3 Replies

Sort by ยป oldest newest

answered 2010-11-30 19:19:47 +0800

windeyu gravatar image windeyu flag of United States
288 3

I was looking for the same solution before, but I figured out a work-around to share with you. I'm happy if someone else can offer a better solution.

What I did was to wrap the component, say window in my case, into a template.zul page.

<zk>
  <zscript><![CDATA[
        Object apply = arg.get("controller");
    ]]></zscript>
    <window apply="${apply}" />
</zk>

Then I parameterize my zul with a runtime controller
    Composer controller = ....;
    Map args = new HashMap();
    args.put("controller", controller);
    Executions.createComponents("template.zul", null, args);

link publish delete flag offensive edit

answered 2010-12-02 04:58:19 +0800

RyanWu gravatar image RyanWu
533 2
about.me/flyworld

hello !

why not using composite component ?

I create a demo for you two,

http://www.zkoss.org/zkdemo/composite/composite_component

notice that you need to do the auto wire and auto forward manually. (still very easy :p)

link publish delete flag offensive edit

answered 2013-05-10 14:19:02 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6
http://www.hybris.com/

Thanks to both!

ConventionWires.wireController(comp, controller);

Made my day... but your example is quite nice Ryan... it would have saved many lines of crap code probably!

Giovanni

link publish delete flag offensive edit

Question tools

Follow

RSS

Stats

Asked: 2010-11-29 08:14:33 +0800

Seen: 484 times

Last updated: May 10 '13

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