-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I wanted to know if there is a mechanism to add a custom attribute to an existing ZUL component so that it is available in the html that gets generated. Let me give an example:
I would like to say this in my zul file:
<vbox id="scaffoldingBox">
<button id="testButton" label="Click Me" customattribute="applicationData"/>
</vbox>
And I would want this to be part of the html that gets generated : something like
<button class="z-button-os" id="z_61_5" customattribute="applicationData">Click Me</button>
Please let me know if this is possible at all using zk.
Any help in this regard would be appreciated.
Thanks,
Syd
ZK has provided something like:
The custom-attributes element
http://www.zkoss.org/doc/devguide-single/index.html
It doesn't meet your need 100%, but should solve many use scenario.
Because, even if ZK provide mechanism to add customattribute in html,
you still have to know how ZK render each component. And that varies.
If you can provide good enough use scenario, please post to feature.
Every spec is open to change, maybe we missed something to consider.
Hi Syd,
The behavior of html output of a ZK widget (button, for example) is determined by the redraw and domAttrs_ methods inherited from zk.Widget.
You can use client side programming technique to override either of them, as described here.
To see how they were originlally implemented you can read the javascript source code of zk.Widget, zul.wgt.Button and src/archive/web/js/zul/wgt/mold/button.js.
The component development tutorial can also help.
Regards,
Simon
Since ZK 5.0.3 , there exist a more convenient way to do this.
(Notice the restriction for it mush be specified before it rendered , or you need to call invalidate() . Read javadoc to know more info!)
Or using client attribute name space. Here's a example below.
<window title="My First Window" border="normal" width="200px" xmlns:d="http://www.zkoss.org/2005/zk/client/attribute"> Hello, World! <label value="hi" d:hello="hello" /> </window>
Ok. How we can retrieve that custom attribute value in the composer ?
In My case, i have multiple zul files and trying to point to one common composer. So in the common composer, for some condition, i need to know from which zul file, this composer has been called.
Asked: 2010-05-12 05:36:59 +0800
Seen: 1,724 times
Last updated: Jan 19 '13