0

Adding Custom attributes to the zk generated html code [closed]

asked 2010-05-12 05:36:59 +0800

siddharth gravatar image siddharth
3 1

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

delete flag offensive retag edit

The question has been closed for the following reason "too localized" by sjoshi
close date 2013-02-08 07:24:44

4 Replies

Sort by ยป oldest newest

answered 2010-05-12 20:17:29 +0800

PeterKuo gravatar image PeterKuo
481 2

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.

link publish delete flag offensive edit

answered 2010-05-12 20:32:52 +0800

SimonPai gravatar image SimonPai
1696 1

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

link publish delete flag offensive edit

answered 2011-01-31 15:27:22 +0800

TonyQ gravatar image TonyQ
642
https://www.masterbranch....

Since ZK 5.0.3 , there exist a more convenient way to do this.

http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/Component.html#setWidgetAttribute%28java.lang.String,%20java.lang.String%29

(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>

link publish delete flag offensive edit

answered 2013-01-19 13:17:08 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

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.

link publish delete flag offensive edit

Question tools

Follow

RSS

Stats

Asked: 2010-05-12 05:36:59 +0800

Seen: 1,724 times

Last updated: Jan 19 '13

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