1

Adding zk script event to label from Java?

asked 2015-05-18 09:50:19 +0800

Tegomena gravatar image Tegomena
33 4

Hello,

I have a ZUL page with some labels:

<label id="myID" onClick='addFacet("structure", self.id)'>Something</label>

where "addFacet" in the onClick event is a z script:

<zscript>
void addFacet(type, s){
.....

Now, during runtime, I need to add some more labels with exactly the same onCLick event. Is it possible to do that from Java? I read about adding an event listener, but how can I call z script from there?

Thanks a lot!

delete flag offensive retag edit

Comments

did you try with Clients.evaljavascript()?

chillworld ( 2015-05-18 11:02:37 +0800 )edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2015-05-18 12:31:53 +0800

chillworld gravatar image chillworld flag of Belgium
5337 4 9
https://github.com/chillw...

updated 2015-05-18 12:40:18 +0800

Zscript is indeed by default Java.

Look at this example of cor3000(JavaScript) : http://zkfiddle.org/sample/1vkkv0d/2-Bind-custom-event-to-command-in-MVVM#source-2

He execute a zscript function from Java. The only thing what you need to do is add an eventListener to your labels who listens to the onClick event.

If the zscript is Java, put it in a Java class.
zscript is for prototyping and everything what's inside zscript can be translated to Java classes.

If the method can be made static and you want also to acces it from the zul you can use xel-method.

Greetz chill.

link publish delete flag offensive edit
0

answered 2015-05-18 11:23:26 +0800

Tegomena gravatar image Tegomena
33 4

Thanks, but my zscript is a Java function (or?). And eval.javascript is just executing any JavaScript, I need to attach the zscript function to the onClick event ...?

Thanks for any hints :-)

link publish delete flag offensive edit
0

answered 2015-05-18 13:11:04 +0800

Tegomena gravatar image Tegomena
33 4

Thanks Chill, I got it! It works :-) !

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2015-05-18 09:50:19 +0800

Seen: 26 times

Last updated: May 18 '15

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