Create a new zul component that is just a regular one with a defined style

asked 2016-01-27 09:50:40 +0800

DMH gravatar image DMH
35 6

I've got a zul page which has a lots of buttons on a grid (hey the boss upstairs decided they should all be buttons) and the thing is I have lot of boilerplate code for those buttons.

Is there a way for me to simply create a standardized version of the button the way I want and just pass it some parameters like it's label value and its sclass? Yes I know this is possible in java but I'm asking more in terms of zul.

I've considered using templates but it seems like it might be too much for using templates and I'm unsure regarding the style and the label value.


delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-01-27 10:11:12 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9

As you know it's possible in Java. The best thing you can do :

Extend the button class and add all those boilerplate code there.

Now you have 2 options in the zul.

First one is using use attribute in the zul :

<button use="my.path.ClassName" />

This will use your class in stead of the normal button class.
This you need of course to type everywhere where you use button.

So next could be adding this in top :

<?component name="mybutton" class="my.path.ClassName"?>

Like this you only need to use it like this :

<mybutton   />

Greetz chill.

link publish delete flag offensive edit


Thanks, this sounds great, can I pass any arguments?

DMH ( 2016-01-27 10:20:51 +0800 )edit

how you mean? It extends textbox so you can use properties like before ex label="@load()"

chillworld ( 2016-01-27 10:38:10 +0800 )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

1 follower



Asked: 2016-01-27 09:50:40 +0800

Seen: 12 times

Last updated: Jan 27 '16

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