XHTML component with both clientside and serverside onClick handlers

asked 2014-11-25 15:34:17 +0800

gediminas gravatar image gediminas
39 3

updated 2014-11-25 15:37:30 +0800

My goal is to have a XHTML button, which would first invoke onClick widget event listener and then invoke a command on the server (I need this to implement a custom confirmation dialog in clientside).

In ZKFiddle the following snippet works perfectly (first I get a client alert and then the command is invoked):

<zk  xmlns="xhtml" xmlns:w="client" xmlns:xh="xhtml" xmlns:zk="zk">
    <xh:div apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('pkg$.TestVm')">
        <xh:button onClick='@command("com")'  w:onClick='alert("client alert");'>Click me</xh:button>

However in a ZUL file like this, the command gets called fine, but no clientside alert is displayed.

<?page complete="true" ?>
    <!DOCTYPE html>
    <html xmlns="xhtml" xmlns:w="client" xmlns:xh="xhtml" xmlns:zk="zk" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd">
        <meta charset="utf-8" />
        <xh:zkhead />
        <div apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('com.company.TestVm')">
          <xh:button id="xhbutton" onClick="@command('com')" w:onClick="alert('I\'m ignored :( )')">XHButton</xh:button>

button.getWidgetListener("onClick") does return the value from ZUL, however if I view the source of the page in question, there is only the following javascript: [1,'xhbutton',{id:'xhbutton',$onClick:true},[

Any ideas how to get this to work?

Note: I am aware of the "zk" namespace (as in here: http://books.zkoss.org/wiki/ZK_Developer%27s_Guide/Fundamental_ZK/ZK_User_Interface_Markup_Language/Component_Sets_and_XML_Namespaces/Mix_With_Another_Markup_Language (http://books.zkoss.org/wiki/ZKDeveloper%27sGuide/FundamentalZK/ZKUserInterfaceMarkupLanguage/ComponentSetsandXMLNamespaces/MixWithAnotherMarkup_Language)), however it does not seem to support Command bindings.

delete flag offensive retag edit
Be the first one to answer this question!
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

1 follower



Asked: 2014-11-25 15:34:17 +0800

Seen: 11 times

Last updated: Nov 25 '14

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