Following example does almost what you want (if I didn;t get you wrong).

ChangeColorPanel.html

<wicket:panel> <div> <span wicket:id="colorPanel" style=" width: 10px; height: 10px; background-color: red;">
         &nbsp;&nbsp;
       </span>
       <span wicket:id="red" onclick="">
         Red
       </span>
       <span wicket:id="blue" onclick="">
         Blue
       </span>
       <span wicket:id="green" onclick="">
         Green
       </span>
   </div>
</wicket:panel>

ChangeColorPanel.java

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.AbstractReadOnlyModel;

/**
* @author EReinaldoB
*
*/
public class ChangeColorPanel extends Panel {

   private static final long serialVersionUID = 1L;

private WebMarkupContainer colorPanel;
   /**
    * @param id
    */
   public ChangeColorPanel(String id) {
       super(id);
colorPanel = new WebMarkupContainer("colorPanel");
       colorPanel.setOutputMarkupId(true);
       add(colorPanel);
WebMarkupContainer red = new WebMarkupContainer("red"); red.add(new AttributeModifier("onclick", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L;

           @Override
           public String getObject() {
               String id = colorPanel.getMarkupId();
return "document.getElementById('" + id + "').style.backgroundColor='red'";
           }
})); add(red); WebMarkupContainer blue = new WebMarkupContainer("blue"); blue.add(new AttributeModifier("onclick", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L;

           @Override
           public String getObject() {
               String id = colorPanel.getMarkupId();
return "document.getElementById('" + id + "').style.backgroundColor='blue'";
           }
})); add(blue); WebMarkupContainer green = new WebMarkupContainer("green"); green.add(new AttributeModifier("onclick", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L;

           @Override
           public String getObject() {
               String id = colorPanel.getMarkupId();
return "document.getElementById('" + id + "').style.backgroundColor='green'";
           }
})); add(green);
   }

}

if you replace the first span by a div a the the later spans by check boxes and intead of modifying the style.backgroundColor you modify the 'className' to the css name you want, I guess this is what you want? This example works (I tested before posting it ;-) )

Best

Ernesto

nickponico wrote:
Thank you for your reply.

Yes there is the Attribute Modifier, but i don't think it can help me.
I try to explain shortly the problem:

I have to modify a css class of a specific div: the DIV can't be managed by
wicket (with wicket id), but only on html.

So i created a little javascript function that change the css class, and i
would like to execute it when a user clicks on a CheckBox.

Since i can't manage function (and div) by wicket... i have some
difficulties to associate it an attributeModifier.

right?

or do i forget something?

thanks


jwcarman wrote:
Is AttributeModifier not available in 1.2.x?





*************************************************************
Este correo ha sido procesado por el antivirus del Grupo FCC.
*************************************************************

Reply via email to