0

dynamically change command name in macro component

asked 2015-01-16 14:34:16 +0800

BetesugScreen gravatar image BetesugScreen
1

Hello,

I'm new to zk and today i tried making some custom components, like i was doing in jsf before.

I made a custom button and it renders ok but i want to change the command on the onClick event. I have read some examples on how to change onclick event dynamically in java but since the button does not have its own view model i was thinking if it is possible to change it by passing it as a component argument.

This is my code:

component:

<zk>
<div>
    <label value="${arg.command}" />
    <button label="Test" onClick="${arg.command}" /><!-- is there a way to pass the command here??? -->
</div>

</zk>

home.zul

<?component name="testMacro" macro-uri="/custom/myMacro.zul" command="@command('test')"?>

<zk>

<testmacro/>

</zk>

Thanks for the help and excuse the dumb noob question :D

delete flag offensive retag edit

Comments

maybe make your own implementation of the button, (extends Button) then you could set an custom-attribute to the button, witch you collect in MyButton class? (just quick thinking)

chillworld ( 2015-01-16 15:04:42 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-01-19 01:29:59 +0800

cor3000 gravatar image cor3000
6280 2 7

updated 2015-01-19 01:30:28 +0800

here an example using your macro and passing in the commandName as a argument: http://zkfiddle.org/sample/2bfu6qc/1-macro-with-command-param.

Robert

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-01-16 14:34:16 +0800

Seen: 29 times

Last updated: Jan 19 '15

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