Hi Martin,
thanks for reply. i used onComponentTag.


2015-12-05 13:43 GMT+01:00 Martin Grigorov <martin.grigo...@gmail.com>:

> Hi Ronny ,
>
> Your approach is OK.
> All that you need is to save target.getMarkupId() in a member variable for
> later use.
> Use Behavior#onComponentTag() instead of adding yet another behavior to
> write the attribute.
> On Dec 5, 2015 2:11 PM, "Ronny Pscheidl" <john.j.c...@googlemail.com>
> wrote:
>
> > 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 <seb...@gmail.com>:
> >
> > > Hi, see #bind()
> > >
> >
>

Reply via email to