You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Michał Szwaczko <mi...@wirelabs.net> on 2016/08/27 19:10:54 UTC

Accessing tags with repeaters

Hello 

I have a simple repeater that dynamically assemblies a row of a table from default  components (labels, panels, buttons etc) The row is part of the dataview.


	RepeatingView row = new RepeatingView("row");

	[in Dataview's populateItem I set components]
	row.add(some_component);
	row.add(some_other_component);
	[..]



Markup is this: 

<tr wicket:id="dataview">
	<td wicket:id="row"></td>
<tr>

Now, in the dataview's onPopulateItem, i'd like to set attribute to the <td> tag based on some property of the populated object.

Sadly there's no markup id for the <td>, nor any accessible component in that tag that I could handle with AttributeAppender.
Is there any other way to do that? Can I somehow get the <td> handle? 

Regards
Michal





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


Re: Accessing tags with repeaters

Posted by Martin Grigorov <mg...@apache.org>.
I'm glad you figured it out!

In my example 'td' should really be named 'tr' because it is a row, not a
cell.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Sun, Aug 28, 2016 at 12:21 PM, Michał Szwaczko <mi...@wirelabs.net>
wrote:

> On Sun, 28 Aug 2016 09:15:29 +0200
> Martin Grigorov <mg...@apache.org> wrote:
>
> > Actually here you need something like:
> > WebMarkupContainer td = new WebMarkupContainer(row.newChildId());
> > td.add(some_component);
> > ...
> >
> > So you can do: td.add(AttributeModifier.append(...));
> > or even override its #onComponentTag()
>
> Hi Martin,
>
> Thanks, I got that already :)
> I seem to fire questions before deeping into the matter carefully.
>
> At first I tried overriding onComponentTag on the repeater object, but
> then realized that in this case it's only the
> container (just as your WebMarkupContainer), so the attributes should be
> added to the child components. No it works ok :)
> All in all I got it just as you propose, thanks for the idea and sorry for
> firing questions early :)
>
> Regards
> Michal
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Accessing tags with repeaters

Posted by Michał Szwaczko <mi...@wirelabs.net>.
On Sun, 28 Aug 2016 09:15:29 +0200
Martin Grigorov <mg...@apache.org> wrote:

> Actually here you need something like:
> WebMarkupContainer td = new WebMarkupContainer(row.newChildId());
> td.add(some_component);
> ...
> 
> So you can do: td.add(AttributeModifier.append(...));
> or even override its #onComponentTag()

Hi Martin,

Thanks, I got that already :) 
I seem to fire questions before deeping into the matter carefully.

At first I tried overriding onComponentTag on the repeater object, but then realized that in this case it's only the 
container (just as your WebMarkupContainer), so the attributes should be added to the child components. No it works ok :)
All in all I got it just as you propose, thanks for the idea and sorry for firing questions early :)

Regards
Michal

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


Re: Accessing tags with repeaters

Posted by Martin Grigorov <mg...@apache.org>.
Hi,


On Sat, Aug 27, 2016 at 9:10 PM, Michał Szwaczko <mi...@wirelabs.net> wrote:

> Hello
>
> I have a simple repeater that dynamically assemblies a row of a table from
> default  components (labels, panels, buttons etc) The row is part of the
> dataview.
>
>
>         RepeatingView row = new RepeatingView("row");
>
>         [in Dataview's populateItem I set components]
>         row.add(some_component);
>

Actually here you need something like:
WebMarkupContainer td = new WebMarkupContainer(row.newChildId());
td.add(some_component);
...

So you can do: td.add(AttributeModifier.append(...));
or even override its #onComponentTag()


>         row.add(some_other_component);
>         [..]
>
>
>
> Markup is this:
>
> <tr wicket:id="dataview">
>         <td wicket:id="row"></td>
> <tr>
>
> Now, in the dataview's onPopulateItem, i'd like to set attribute to the
> <td> tag based on some property of the populated object.
>
> Sadly there's no markup id for the <td>, nor any accessible component in
> that tag that I could handle with AttributeAppender.
> Is there any other way to do that? Can I somehow get the <td> handle?
>
> Regards
> Michal
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>