2

Groupbox open and close

asked 2014-01-22 22:33:08 +0800

paula gravatar image paula
74 2

updated 2014-01-23 18:15:32 +0800

hswain gravatar image hswain flag of India
1763 3 10
http://corejavaexample.bl...

Hi, I have a Groupbox, which has a checkbox, some labels and an icon in caption. I want to make the Groupbox open/close only when user clicks the icon in the cation. The icon works fine.

However, whenever I check/uncheck the checkbox, the groupbox is also open/close. I have no idea how this happens. Can somebody help?

Following is my code:

<groupbox id="testGB" open="@{data.panelOpen}">     
   <caption>
   <checkbox onCheck="controller.checkMember(self);" checked="@{data.selected}" />
   <label value="test" />   
   <image src="collapse_plus.png" onClick="controller.togglePanel(self);" />
   </caption>
   <div id="gbPanel">
    ...
    </div>
</groupbox>

In my controller:

public void togglePanel(final Component tbtn) {     
        Groupbox gb = getParentComponent(tbtn, Groupbox.class);
        data.setPanelOpen(!data.getPanelOpen());        
        gb.invalidate();
        binder.loadComponent(gb);
    }

public void checkMember(final Component tbtn) {   
    //do something else
}

bellow my code sample:

public class Data{

private Boolean panelOpen = false;

public Boolean getPanelOpen() { return panelOpen; }

public void setPanelOpen(Boolean panelOpen) { this.panelOpen = panelOpen; } }

I actually tried to remove all code from checkMember() method and the Groupbox still gets open/close when the checkbox is checked/unchecked.

Please help!!!

Thank You!

delete flag offensive retag edit

Comments

can you provide the "data" class to?

chillworld ( 2014-01-23 07:15:42 +0800 )edit

public class Data{

private Boolean panelOpen = false;

public Boolean getPanelOpen() { return panelOpen; }

paula ( 2014-01-23 16:22:19 +0800 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2014-01-23 18:34:11 +0800

hswain gravatar image hswain flag of India
1763 3 10
http://corejavaexample.bl...

updated 2014-01-23 18:36:21 +0800

why this method you use.

public void togglePanel(final Component tbtn) {     
        Groupbox gb = getParentComponent(tbtn, Groupbox.class);
        data.setPanelOpen(!data.getPanelOpen());        
        gb.invalidate();
        binder.loadComponent(gb);
    }

if you want to open close groupbox on click caption and image no need to write any new code by default it will work.

you just remove this method and remove this code also.

open="@{data.panelOpen}"

try this code

<groupbox id="testGB">
        <caption>
            <checkbox />
            <label value="test" />
            <image src="1.jpeg" />
        </caption>
        <div id="gbPanel">...</div>
    </groupbox>
link publish delete flag offensive edit

Comments

HI, hswain:

I tried your test code and it works same way.

When I check/uncheck the checkbox, the panel gets open/closed. When I click the label or the image, nothing happens.

I am using ZK 5.0.1. Could it be the reason?

Please help!

paula ( 2014-01-23 19:15:56 +0800 )edit

can you provide your complete code.

hswain ( 2014-01-24 18:42:37 +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

Follow
1 follower

RSS

Stats

Asked: 2014-01-22 22:33:08 +0800

Seen: 35 times

Last updated: Jan 23 '14

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