I ended up doing it in bind of the behavior and it works fine. I just have to 
remember to add the behavior to the page after all the other components. Thanks
 
 
 
I assume you were trying this in beforeRender of your behaviour, which
as you say is too late.
If you really need to use a behaviour encapsulate all this, try
something like the following, but some may feel its a little
politically incorrect to do this in bind.
 class MyBehaviour extends AbstractBehavior{
  @Override
  public void bind(Component component) {  
   if(!(component instanceof MarkupContainer)){
    throw new RuntimeException("conta─▒ners only please");
   }
   visitChildren(new IVisitor<Component>(){
    @Override
    public Object component(Component component) {
     component.add(new SimpleAttributeModifier("class","goodChild"));
     return IVisitor.CONTINUE_TRAVERSAL;
    }
   });
  }
 }
 
Regards - Cemal
jWeekend
OO & Java Technologies, Wicket
Consulting, Development, Training
http://jWeekend.com
 

On 15 April 2010 20:17, Warren Bell <warrenbe...@gmail.com> wrote:
> > I have that figured out, I just don't know how to add the attribute to each
> > component. I can't add a behavior, since "Cannot modify component hierarchy
> > after render phase has started (page version cant change then anymore)" Can
> > I even do this in a behavior?
> >
> > Cemal Bayramoglu wrote:
>> >>
>> >> Warren,
>> >>
>> >> See MarkupContainer#visitChildren
>> >>
>> >> Regards - Cemal
>> >> jWeekend
>> >> OO & Java Technologies, Wicket
>> >> Consulting, Development, Training
>> >> http://jWeekend.com
>> >>
>> >> On 15 April 2010 18:44, Warren Bell <warr...@clarksnutrition.com> wrote:
>> >>
>>> >>>
>>> >>> Is there a way to add attributes to child components in a behavior that
>>> >>> is added to a page? I want to create a behavior that is added to a page
>>> >>> that adds some js to the header and then adds some js in an onfocus
>>> >>> attribute of each child form component on the page. I have the list of
>>> >>> child form components, but can't figure out how to add the attribute to
>>> >>> the components.
>>> >>>
>>> >>> Warren
>>> >>>
>>> >>>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> >> For additional commands, e-mail: users-h...@wicket.apache.org
>> >>
>> >>
> >
> >
> > --
> > Thanks,
> >
> > Warren Bell
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
 
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
 
 

Reply via email to