here is a quicky

class MyCoolLabel extends SimpleFormComponentLabel) {
    public MyCoolLabel(String id, FormComponent fc) {
           super(id, fc);

              //attribute modifier to add the error css class
              add(new SimpleAttributeModifier("class", "error") {
                 boolean isEnabled() {
                         //only enable if the attached formcomponent is invalid
                           return !fc.isValid();
                }
    }

     //this is not the cleanest way to do this, it would be better to use true component composition and make this label a panel instead, but i dont want to write all that out - excercise left to the reader
    onAfterRender() { getResponse().write("<span class='required'>*</span>"); }
}

then the usage should be something like this:

TextField tf=new TextField("tf").setRequired(true);
add(tf);
add(new MyCoolLabel("label", tf));

<label wicket:id="label">label</label><input type="text" wicket:id="tf"/>

hope this gets you started

-Igor

        



On 4/28/06, Börcsök József <[EMAIL PROTECTED]> wrote:
Hi

I am writing a simple web application and I'd like to

- mark the label of required fields (ie. a star before the text)
- change the style of the _label_ that belongs to invalid fields

I've found a blog entry about how to change a component's style after
validation but I don't know how to get its HTML label. Is there any
relationship between these Java objects at runtime?

Do you know a solution or best practise?

Thanks,
--
  Jozsef Borcsok




-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to