Also didn't know about isTemporary. Looks very nice and simple. Guess I need
to test what isTemporary does if a subsequent Ajax request asks for a single
child to be rendered, I don't think RepeatingViews are eligible for an
AjaxTarget.
Many thanks Kent. Looks lovely shiny code.
Kent Tong wrote:
>
>
> Sam Hough wrote:
>>
>> Your still breaking my requirement that this behaviour is encapsulated
>> within MyFancyRepeatingView ;) I really do appreciate all your code and I
>> think I'm learning a lot even if I sound horribly ungrateful. I'm warming
>> to every child component having a special behaviour object. Although it
>> seems expensive does show nice encapsulation.
>>
>> How about MyFancyRepeatingView has a singleton behaviour object that it
>> checks is attached to all its children (should be quick as identity
>> operation - in childIterator). Requires only single instance for whole
>> application... I might be able to convince the HTML monkey that he only
>> needs class="first" so I don't need to iterate through all the siblings.
>>
>
> Then add the behaviors in onBeforeRender():
>
> public class MyRepeatingView extends RepeatingView {
> public MyRepeatingView(String id) {
> super(id);
> }
> protected void onBeforeRender() {
> super.onBeforeRender();
> int idx = 0;
> Iterator iter = iterator();
> while (iter.hasNext()) {
> Component child = (Component) iter.next();
> if (idx == 0 || idx == size() - 1) {
> child.add(new AttributeModifier("class", true,
> new Model(
> idx == 0 ? "first" : "last")) {
> public boolean isTemporary() {
> return true;
> }
> });
> }
> idx++;
> }
> }
> }
>
--
View this message in context:
http://www.nabble.com/Reach-into-a-component-to-change-XML-attribute-tf4527906.html#a12965606
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]