Wow! your code give me a big hint: there is a method: setBorderBodyVisible()
With this method, it's quite simple to solve this problem!

AjaxBox.java-
public abstract class AjaxBox extends Border {

    public AjaxBox(String id) {
        super(id);
        setOutputMarkupId(true);
    }
    @Override
    protected final void onAttach() {
        setBorderBodyVisible(isBodyVisible());
    }
    @Override
    public final boolean isVisible() {
        return true;
    }
    //subclass to implement to change body visibility:
    protected abstract boolean isBodyVisible();

}

AjaxBox.html - nonthing  :-)
<wicket:border><wicket:body/></wicket:border>


Now I can write my template as:

<a wicket:id="toggle" >toggle visiblity</a>
<div wicket:id="ajaxBox" >
      actual content here....
      <a wicket:id="foo" >...
      <span wicket:id="bar">.....
</div>

with source code:

        final AjaxBox ajaxBox = new AjaxBox("ajaxBox") {
            @Override
            protected boolean isBodyVisible() {
                return toggleStatus;
        };
        add(ajaxBox);

        add(new AjaxLink("toggle") {
            @Override
            public void onClick(AjaxRequestTarget target) {
                toggleStatus = !toggleStatus;
                target.addComponent(ajaxBox);
            }
        });

The java code now is much simpler!

On 8/31/06, ChuckDeal <[EMAIL PROTECTED]> wrote:


Ingram Chen wrote:
>
>      As I tried more Ajax in my new project, I frequently encounter one
> feature:
> use ajax to toggle specific block of tag visible/invisible. To do this,
> one
> may use:
>

I was attempting a similar action.  Attached is my first cut of the
solution.  It is a Border that shows a row of text that can be cliked to
show/hide the body.  It is not finished, but it should work reasonably well.

http://www.nabble.com/user-files/235819/collapsableBorder.jar
collapsableBorder.jar
--
View this message in context: http://www.nabble.com/Ajax-to-toggle-visibility-require-two-WebMarkupContainers-tf2195506.html#a6077669
Sent from the Wicket - User forum at Nabble.com.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user



--
Ingram Chen
Java [EMAIL PROTECTED]
Institue of BioMedical Sciences Academia Sinica Taiwan
blog: http://www.javaworld.com.tw/roller/page/ingramchen
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to