this is not the use case. collapsebehavior is set to component icon which
toggles the target component. the initial state of target has to be
collapsed. my approach is that the collapsebehavior could also set the
needed css class to the target component and not to add this manually to
the target component.

public class CollapseBehavior extends Behavior {
   private final IModel<String> targetMarkupId;

   public CollapseBehavior(Component target) {
      target.setOutputMarkupId(true);
      target.add(new CssClassAppender("collapse"));
      targetMarkupId = Model.of(target.getOutputMarkupId());
   }

   public void onBind(Component component) {
      component.add(new AttributeAppender("data-target", "#" +
targetMarkupId));
      component.add(new AttributeAppender("collapse", "toggle"));
   }
   ....
}

is there a way to let a behavior interact with two components?


2015-12-04 21:57 GMT+01:00 Sebastien <[email protected]>:

> Hi, see #bind()
>

Reply via email to