0

Call ZK code from javascript/JSP - My code not working any more on zk 3.5.0

asked 2008-09-26 10:24:20 +0800

Ale gravatar image Ale
24

Hello,
I'm working on a regular JSP that I would like to integrate with a zul component.
I added a zk button using JSP tags, but what I need is to call the handler of that button from javascript.
i.e.: The zk script called when I click that button should also be called when the user click a legacy html button.

The technique I used untile before zk 3.5.0 was to enclose the zk button inside a custom div with an ID I know, so to get it via javascript, get the button inside it and then simulate the click creating the event.

But now, with zk 3.5.0 the html code generated for the button is completely different (and much more complitaded) than before, so: is there another, more clean, technique to reach this goal?

Thanks for any hints,
Alex

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2008-09-29 01:44:29 +0800

tomyeh gravatar image tomyeh
610 1 3
http://blog.zkoss.org ZK Team

The new button actually embedded a HTML button inside. If the button's UUID is "z_123", the the embedded HTML button is "z_123!real".

In addition to enclosing a custom div, you might consider to generate a map of ID to UUID in JavaScript:
//foo.jsp
<script language="javascript">
uuidmap = {};
uuidmap['${btn.id}'] = uuidmap['${btn.uuid}'];
</script>

Then, in JavaScript, you can get the element by use of $e(uuidmap + "!real").

It might not be better than your custom-div approach. Just to give you 2nd opinion.

Tom

link publish delete flag offensive edit

answered 2008-09-29 08:32:15 +0800

Ale gravatar image Ale
24

Hello Tom, and thanks for your reply.

Unfortunately I'm unable to understand your suggestion: the problem being that I'm unable to know the id of the zk button in advance.
For example, in my case, in the zk code it has id "myButton", but in HTML is ID is "z_c3_1", and each time I refresh the page the id changes.

Having the option to know in advance the ID name of the html button or, better, leave it with the name I assigned it, would be a very welcome thing!

Thanks,
Alex

link publish delete flag offensive edit

answered 2008-10-02 04:18:26 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

btn.getUuid() is the id show on the browser HTML. And the inner HTML button's id on the browser would be btn.uuid()+"!real".
e.g. the "z_c3_1" is the uuid of the button and the inner HTML button's id would be "z_c3_1!real" on browser.

You can check the Browser source code to find it.

And theoretically, you can use EL to "remember" the btn's uuid and so on.

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: 2008-09-26 10:24:20 +0800

Seen: 845 times

Last updated: Oct 02 '08

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