ok real quick - I did something like this when I was exploring the *then* newly added wicket.markup.transformer.ITransformer.
But I'm not sure if this is what you are looking for.


import wicket.markup.html.form.TextField ;
import wicket.markup.transformer.AbstractTransformerBehavior;
import wicket.model.IModel;

public class MyTextField extends TextField {

    public MyTextField(String id, IModel model) {
        super(id, model);
        add(new AbstractTransformerBehavior() {

            @Override
            public CharSequence transform(Component component, String output)
                    throws Exception {
                TextField textField = (TextField) component;
                if (textField.hasErrorMessage()) {
                    return output + "<span style='color:red;'>*</span>";
                } else {
                    return output;
                }
            }

        });
    }
}


Markup -         <input type="text" wicket:id="name"/>
Java     -          add(new MyTextField("name"));

But may be you can wait for one of the Wicket commiter's to confirm if this is an *acceptable* usage of ITransformer.

thanks,
Karthik


On 10/9/06, Bondarenko, Oleg <[EMAIL PROTECTED]> wrote:
Year, thanks, but...

What I really want is to combine the border AND the component (like TextField) into my own custom component! This way I would considerably reduce the amount of HTML and Java code.

Isn't it supposed to be the main advantage of Wicket - the ability to easily create own custom components? ;-)




-----Original Message-----
From:   [EMAIL PROTECTED] on behalf of karthik Guru
Sent:   Mon 10/9/2006 2:58 PM
To:     wicket-user@lists.sourceforge.net
Cc:
Subject:        Re: [Wicket-user] wrap standard components

Personally, I think this -
wicket.markup.html.form.validation.FormComponentFeedbackBorder is nice.  So
now you just need a panel with your standard form component and this border
attached. You can ofcourse build your own Border using
FormComponentFeedbackBorder  as a starting point.

Regards,
Karthik

On 10/9/06, Bondarenko, Oleg <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I would like to have a nice way to wrap (decorate) standard form
> components. E.g. my own MyTextField will have a red border and some
> message in case if validation fails.
>
> Suppose for simplicity that MyTextField.html looks like
>
> <wicket:panel>
> <input wicket:id = "wrappedTextField" />
> <span wicket:id="unErrMsg">
>    <div class="errorMsg"><span
> wicket:id="unErrMsgLbl">unErrMsgLbl</span></div>
> </span>
> </wicket:panel>
>
> where "wrappedTextField" is a standard TextField. The new component will
> be used on some page the following way:
>
> ...
> <input wicket:id = "username" type = "text" value = " [EMAIL PROTECTED]" size =
> "30"/>
> ...
>
> The first problem I see is how to pass through all attributes from the
> parent component to the wrapped TextField component?
>
> Thanks in advance
> Oleg
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>



--
-- karthik --




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user





--
-- karthik --
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to