0

Listening to XHTML Component onClick Event

asked 2015-06-26 04:31:42 +0800

kleponboy gravatar image kleponboy flag of Indonesia
54 5
http://stupidprogrammers....

updated 2015-06-26 04:34:10 +0800

Hi,from this example Im Trying to Listen onClick event from XHTML component insidel zul file .but I always getting an error.

@command('fromHtml');'' Token Parsing Error: Lexical error at line 22, column 2.    Encountered: "c" (99), after : "@": <at unknown location>

here my .zul

  <zk xmlns:n="native" xmlns:x="xhtml" xmlns:zk="zk">
     <div width="100%" apply="org.zkoss.bind.BindComposer" 
          viewModel="@id('vm') @init('com.self.PracticeVM')">

             <x:input type="button" value="Test" zk:onClick="@command('addItem')" />

     </div>
  </zk>

and here my Java VM class :

  public class PractiveVM{

      @command
      public void addItem(){

         System.out.println("From XHTML components");

      }
  }

any suggestion ?

Regards,

Klepon

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-06-26 08:53:40 +0800

Darksu gravatar image Darksu
1991 1 4

Hello Klepon,

There are two changes you have to make in your code:

  1. Zul:

Remove zk: from the command

  1. Java Code:

Update the annotation of the @command to @Command

Please find below the full code:

Zul:

<zk xmlns:n="native" xmlns:x="xhtml" xmlns:zk="zk">
     <div width="100%" apply="org.zkoss.bind.BindComposer" 
          viewModel="@id('vm') @init('com.self.PracticeVM')">

             <x:input type="button" value="Test" onClick="@command('addItem')" />

     </div>
  </zk>

Java:

package com.self;

import org.zkoss.bind.annotation.Command;

public class PracticeVM {

    @Command
    public void addItem(){

       System.out.println("From XHTML components");

    }

}

Best Regards,

Darksu

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-06-26 04:31:42 +0800

Seen: 29 times

Last updated: Jun 26 '15

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