Groupbox expand and collapse icons [closed]

asked 2013-02-07 14:29:07 +0800

RetoH gravatar image RetoH flag of Switzerland
44 5

updated 2013-02-07 14:30:36 +0800

Hi, I would like to find an application wide solution to get open/closed icons in all groupbox captions.

There is a proposed solution in the Demo: http://www.zkoss.org/zkdemo/layout/group_box

And another here: http://emrpms.blogspot.ch/2012/05/group-box-with-collapse-and-expand.html

But both solutions require me to copy/paste a lot of stuff all over the place. I only want to define this once.

This works (instead of setLabel I plan to use setImage later on):

  <groupbox onOpen='self.getFirstChild().setLabel(self.isOpen() ? "Open" : "Closed")' >
    <caption label="Caption" />


But when I try to define this attribute value in the language add-on, it does not work:

      <attribute-value>self.getFirstChild().setLabel(self.isOpen() ? "Open" : "Closed")</attribute-value>

Is it not possible to define event code in the language add on?

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by dennis
close date 2013-02-19 04:45:51



regardless the answer, onOpen is a event, and custom-attribute is the attribute by component.setAttribute(), they are totally different.

dennis ( 2013-02-08 04:45:52 +0800 )edit

good to know, that was just a naive assumption on my part, because in the zk demo they have zul markup like this: <attribute name="onOpen"><![CDATA[cb.setChecked(self.isOpen());]]></attribute>

RetoH ( 2013-02-08 14:45:41 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2013-02-08 04:55:08 +0800

dennis gravatar image dennis
3669 1 6

updated 2013-02-08 04:57:46 +0800

Here is my example







package simple;

import org.zkoss.zk.ui.event.OpenEvent;
import org.zkoss.zul.Caption;
import org.zkoss.zul.Groupbox;

public class GroupboxEx extends Groupbox{

    private static final long serialVersionUID = 1L;

    public void onOpen(OpenEvent evt){
        Caption cp = getCaption();



<vlayout spacing="15px">
    <hbox spacing="15px">
        <groupboxex width="300px">
            <caption label="Open"/>
link publish delete flag offensive edit


if this answer solve your question, please vote and mark the answer is correct.

dennis ( 2013-02-08 04:57:04 +0800 )edit

Thank you dennis . I learned new stuff today :)

Senthilchettyin ( 2013-02-08 05:32:38 +0800 )edit

yes this did solve my question, thanks a lot. I also had to set the 3d mold in the constructor. I figured out that I need to provide an explicit setter which delegates to the super class if I want to be able to specify a library property in the zk.xml.

RetoH ( 2013-02-08 15:07:22 +0800 )edit

Question tools




Asked: 2013-02-07 14:29:07 +0800

Seen: 64 times

Last updated: Feb 08 '13

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