Hi,

Better use a Behavior that is attached to SimpleFormComponentLabel.
Use #beforeRender() to prepend the asterisk.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Thu, Jun 4, 2015 at 5:14 AM, msalman <[email protected]> wrote:

> Please see the following code:
>
>         private static class RequiredLabel extends SimpleFormComponentLabel
>         {
>                 private static final long serialVersionUID =
> 5132250047993256659L;
>
>                 //private boolean required;
>                 FormComponent fc;
>
>                 public RequiredLabel(String id, FormComponent fc)
>                 {
>                         super(id, fc);
>                         //this.required = fc.isRequired();
>                         this.fc = fc;
>                 }
>
>                 @Override
>                 protected void onComponentTag(ComponentTag tag)
>                 {
>                         super.onComponentTag(tag);
>                         if (fc.isRequired()) {
>                                 getResponse().write("*");
>                         }
>                         else {
>                                  // ?? how do I remove the previously
> placed
> "*"
>                         }
>                 }
>         }
>
> RequiredLabel is a label that is used with a FormComponent. It is used to
> put the red asterisk to show that input to the field is required.   But
> what
> happens is that on an ajax request the red asterisks keep on piling up.
> And
> I have a case where the field may be changed to be not required.   How do I
> remove the previosly placed red asterisk?
>
> Thanks.
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/editing-response-in-onComponentTag-tp4671062.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to