Hi
This border code works in 6.21 but failed in 6.22

It is a traditional 'portlet-like' border , with a 'title' and an ajax link
( which will collapse/expand when clicked )

I lookup up the change log
http://archive.apache.org/dist/wicket/6.24.0/CHANGELOG-6.x
but didn't find anything related to Border.



import org.apache.wicket.MarkupContainer;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.border.Border;
import org.apache.wicket.model.StringResourceModel;

public class PulldownBorder extends Border {

  private final WebMarkupContainer content;

  /** is content expanded ? */
  private boolean expanded;

  /** is content visible ? */
  public boolean contentVisible() {
    return content.isVisible();
  }

  public PulldownBorder(String id, String title, boolean defaultExpanded) {
    super(id);

    setOutputMarkupPlaceholderTag(true);
    setRenderBodyOnly(false);

    Label titleLabel = new Label("title", title);
    expanded = defaultExpanded;

    content = new WebMarkupContainer("content");

    content.setOutputMarkupPlaceholderTag(true);
    content.setVisible(defaultExpanded);
    content.setRenderBodyOnly(false);
    add(content);
    //content.add(getBodyContainer());
    addToBorder(content);

    //collapse / expand , text
    final Label collapseExpandText = new Label("collapseExpandText");
    collapseExpandText.setOutputMarkupPlaceholderTag(true);
    if (content.isVisible())
      collapseExpandText.setDefaultModel(new
StringResourceModel("collapse", this, null));
    else
      collapseExpandText.setDefaultModel(new
StringResourceModel("expand", this, null));


    //this link failed in 6.22
    AjaxLink<Void> collapseExpandLink = new
AjaxLink<Void>("collapseExpandLink") {
      @Override
      public void onClick(AjaxRequestTarget target) {
        expanded = !expanded;
        content.setVisible(expanded);
        target.add(content);

        MarkupContainer mc = (MarkupContainer)
findParent(ExpandCollapseListener.class);
        if (mc != null) {
            if (mc instanceof ExpandCollapseListener) {
            ExpandCollapseListener listener = (ExpandCollapseListener) mc;
            listener.setExpanded(expanded);
          }
        }

        if (!expanded) {
            target.add(collapseExpandText.setDefaultModel(new
StringResourceModel("expand", this, null)));
        }
        else {
            target.add(collapseExpandText.setDefaultModel(new
StringResourceModel("collapse", this, null)));
        }
      }
    };
    addToBorder(collapseExpandLink);
    collapseExpandLink.add(collapseExpandText);
    collapseExpandLink.add(titleLabel);
  }
}


public interface ExpandCollapseListener {

  void setExpanded(boolean value);
}


The problem comes from *collapseExpandLink* , which works in 6.21 , but
failed in 6.22

I cannot find where goes wrong.
Can somebody give me some hint ?

Thanks.

Reply via email to