0

Binding Custom Attribute

asked 2009-09-10 18:35:29 +0800

samyem gravatar image samyem
30 1

When I try to do binding on custom attribute, like:
<button id="button" ..>
<custom-attribute item="@{item}"/>
</button>

and when I try to retrieve the value, like
button.getAttribute("item")

I get the string literal "@{item}" instead of the bounded expression's value. What am I missing here?

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2010-05-09 15:41:39 +0800

vinhvo gravatar image vinhvo
369 3

Hi, did you find the solution yet ?

link publish delete flag offensive edit

answered 2010-12-13 15:13:58 +0800

farmacia gravatar image farmacia
105

I'm also interested in your solution !

link publish delete flag offensive edit

answered 2010-12-13 15:29:25 +0800

robertpic71 gravatar image robertpic71
1275 1

Databinding for customattributes is working since ZK Version 5.

Post your code (zul) if you have any troubles.

/Robert

link publish delete flag offensive edit

answered 2011-02-21 12:44:53 +0800

acirasa gravatar image acirasa
48 1

I have the same problem

<button id="deleteAddressBtn" label="-" >
<custom-attributes deleteAddress="@{address}" />
</button>

and in Composer

...
public void onClick$deleteAddressBtn(Event e) throws InterruptedException{

Address addr=(Address)deleteAddressBtn.getAttribute("deleteAddress");
Messagebox(addr.street);
}

address in view is valorized but the attribute is null

can anyone help me?

Thanks

link publish delete flag offensive edit

answered 2011-02-21 16:57:28 +0800

robertpic71 gravatar image robertpic71
1275 1

You have to retrieve the "fired button" first.

onClick$delteAdressBtn(Event e) {..

Component comp = event.getTarget()); // retrieve the target component --> clicked(!) button
Address addr=(Address)comp.getAttribute("deleteAddress");


Note 1: with getParent() you could retrieve Row/Listitem and you don't have to bind data for all buttons.
Note 2: @databinding for custom-attributes works since ZK 5.x

/Robert

link publish delete flag offensive edit

answered 2011-02-22 10:56:22 +0800

acirasa gravatar image acirasa
48 1

updated 2011-02-22 11:21:26 +0800

Component comp = event.getTarget()); // retrieve the target component --> clicked(!) button
Address addr=(Address)comp.getAttribute("deleteAddress");

not run!

I don't know why but in debugging the comp contain a window that contain grid with button in row, not the button

PS: I have a 5.0.x

link publish delete flag offensive edit

answered 2011-02-22 11:33:59 +0800

acirasa gravatar image acirasa
48 1

I resolved with

public void onClick$deleteAddressBtn(ForwardEvent e) throws InterruptedException{
		
		Component comp=e.getOrigin().getTarget();
		Address addr=(Address)comp.getAttribute("value");
		
	}

I hope this is usefull for others

Thanks for help

link publish delete flag offensive edit
Your reply
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

Follow

RSS

Stats

Asked: 2009-09-10 18:35:29 +0800

Seen: 789 times

Last updated: Feb 22 '11

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