On Wed, Feb 22, 2012 at 12:20 PM, Daniel Stoch <daniel.st...@gmail.com> wrote:
> On Wed, Feb 22, 2012 at 12:11 PM, Martin Grigorov <mgrigo...@apache.org> 
> wrote:
>> On Wed, Feb 22, 2012 at 12:01 PM, Daniel Stoch <daniel.st...@gmail.com> 
>> wrote:
>>> No. I want to have <a>. When you use this LinkContainer from my
>>> example in HTML like:
>>> <div wicket:id="link">
>>> </div>
>>>
>>> It will be rendered as:
>>>
>>> <a wicket:id="link">...</a>
>>>
>>> So any attributes modified using behavior will disappear.
>>>
>>>
>>> But if LinkContainer will not have setRenderBodyOnly(true), the the
>>> corresponding HTML will be:
>>>
>>> <div wicket:id="link" class='my-link-style'>
>>>  <a wicket:id="link">...</a>
>>> </div>
>>
>> Now it is more clear what you do.
>> You need to add the AttributeModifier to the Link, not to the
>> LinkContainer if you want to manipulate <a>.
>>
>
> Well, I know it is possible in this way. But my question is more
> general: does using behaviors which changes a markup (like
> AttributeModifier) on components with setRenderBodyOnly(true) make
> sense?

No.

>
> To add the AttributeModifier to the Link I have to write extra method
> inside a LinkContainer which adds a behavior to enclosing component
> (Link is created inside LinkContainer and because of ecapsulation it
> should not be visible outside it). But the cleaner solution will be to
> add a behavior to LinkContainer, but then it should be "transparently"
> added to the one of its child components.

To which child exactly ? How to decide that for you ?

> Then I can use AttributeModifier (or related behaviors) the same way
> with component which has setRenderBodyOnly(true) or not. But now I
> need to know a component implementation to decide if I can use such
> modifiers with it or no.

Each behavior has a reference to the component it is bound to. So you
can assign your own Behavior to the parent class and then in
behavior's onComponentTag, renderHead(), ... you can do whatever you
need with the parent and all its children. It is a bit harder to get
the children ComponentTags but it is possible: new
MarkupStream(getMarkup()) and iterate over the elements in the
MarkupStream.

>
> --
> DS
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to