I just tried to modify the id to see if the worked, I'm sorry for the
confusion.

@Nino
I think you might be right, but I couldn't get it to work. (I changed it to
modifying the style attribute, just to quick test visually.)

My modified code:

// text
final Label text = new Label("text", resourceRecord.getText());
final Model textClassModel = new Model("color: red;");
final AttributeModifier textClass = new AttributeModifier("style", true,
textClassModel);
text.add(textClass);
add(text);

//(...)

// edit link
add(new AjaxFallbackLink("edit-link"){
   @Override
   public void onClick(AjaxRequestTarget target) {
       //(...)
       textClassModel.setObject("color: blue;");

       if (target != null) {
           // (...)
           target.addComponent(text);
       }
   }

});

2007/7/3, Alex Objelean <[EMAIL PROTECTED]>:


First of all you must setOutputMarkupId to true for the text component:
text.setOutputMarkupId(true);

Also, you are modifying the id attribute, and not the css... this is also
a
problem....
so instead of:
        text.add(new SimpleAttributeModifier("id","test"));
do this:
        text.add(new SimpleAttributeModifier("class","mySuperClass"));




yuccaplant wrote:
>
> If some link is clicked, I want to change the css-class of a label like
> this:
>
> // text
> final Label text = new Label("text", resourceRecord.getText());
> add(text)
>
> // edit link
> add(new AjaxFallbackLink("edit-link"){
>     @Override
>     public void onClick(AjaxRequestTarget target) {
>         // dome some other stuff
>         text.add(new SimpleAttributeModifier("id","test"));
>         if (target != null) {
>             // add some other components
>             target.addComponent(text);
>         }
>     }
>
> });
>
>
> Somehow this doesn't work. I guess I simply missed something?
>
> thanks,
>
> Pieter
>
> --
> Pieter Cogghe
> Ganzendries 186
> 9000 Gent
> 0487 10 14 21
>
>
-------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>

--
View this message in context:
http://www.nabble.com/add-class-onlclick-tf4017981.html#a11411738
Sent from the Wicket - User mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user




--
Pieter Cogghe
Ganzendries 186
9000 Gent
0487 10 14 21
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to