You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by smallufo <sm...@gmail.com> on 2008/01/11 17:59:11 UTC
FormComponentPanel and setConvertedInput()
Hi , I am evaluating FormComponentPanel .
I looked into the document , it seems setConvertedInput() is the proper way
.
I use another method , which skips the setConvertedInput() , I don't know if
it is suggested :
Here is the code :
public class TimePanel extends FormComponentPanel
{
private Time time;
public TimePanel(String id , Time time )
{
super(id);
this.time = time;
add(new CheckBox("beforeChrist" , new PropertyModel(time ,
"beforeChrist")));
add(new TextField("year" , new PropertyModel(time , "year")));
add(new TextField("month" , new PropertyModel(time , "month")));
add(new TextField("day" , new PropertyModel(time , "day")));
add(new TextField("hour" , new PropertyModel(time , "hour")));
add(new TextField("minute" , new PropertyModel(time , "minute")));
add(new TextField("second" , new PropertyModel(time , "second")));
}
}
I embed this TimePanel to a form :
Time time = new Time(); //my custom Time class
add(new TimePanel("timePanel" , time));
add(new Button("button")
{
@Override
public void onSubmit()
{
System.out.println("time = " + time);
}
});
It works .
It seems by this way , I can skip implementing setConvertedInput() , right ?
Is there any drawback ?
Is this a suggested way ?
Re: FormComponentPanel and setConvertedInput()
Posted by Michael Sparer <mi...@gmx.at>.
Yep that's right, in your case (if the class stays like that) you can skip
convertInput. I happened to have a similar situation today. But I also had
the situation where one value gets passed to the form component and there it
gets splitted to two textfields and concatinated afterwards. as igor said,
there it really is very important to override convertInput to split the
values (and onbeforerender to concatinate them again), if you also add
Validators. by the way also be sure check that the value you pass to
setConvertedInput inside of convertInput isn't null as that'd be same as
omitting convertInput ;-)
smallufo wrote:
>
> 2008/1/12, Igor Vaynberg <ig...@gmail.com>:
>>
>> first you should implement convertintput() not setconvertedinput().
>> inside your impl of convertinput() you should call setconvertedinput()
>> with the right value.
>
>
> Sorry , it's my typo , I meant convertInput() as you mentioned.
>
> this is indeed important as the converted input is what is passed into
>> validators. so if you need your panel to support validators you will
>> need to implement the method.
>>
>> -igor
>>
>
> Thank you.
> But I still can add validators as following :
> add(new TextField("year" , new PropertyModel(time , "year")).add(
> NumberValidator.POSITIVE));
>
> And it still works (including the validator)....
>
>
-----
Michael Sparer
http://talk-on-tech.blogspot.com
--
View this message in context: http://www.nabble.com/FormComponentPanel-and-setConvertedInput%28%29-tp14760809p14762773.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: FormComponentPanel and setConvertedInput()
Posted by smallufo <sm...@gmail.com>.
2008/1/12, Igor Vaynberg <ig...@gmail.com>:
>
> first you should implement convertintput() not setconvertedinput().
> inside your impl of convertinput() you should call setconvertedinput()
> with the right value.
Sorry , it's my typo , I meant convertInput() as you mentioned.
this is indeed important as the converted input is what is passed into
> validators. so if you need your panel to support validators you will
> need to implement the method.
>
> -igor
>
Thank you.
But I still can add validators as following :
add(new TextField("year" , new PropertyModel(time , "year")).add(
NumberValidator.POSITIVE));
And it still works (including the validator)....
Re: FormComponentPanel and setConvertedInput()
Posted by Igor Vaynberg <ig...@gmail.com>.
first you should implement convertintput() not setconvertedinput().
inside your impl of convertinput() you should call setconvertedinput()
with the right value.
this is indeed important as the converted input is what is passed into
validators. so if you need your panel to support validators you will
need to implement the method.
-igor
On Jan 11, 2008 8:59 AM, smallufo <sm...@gmail.com> wrote:
> Hi , I am evaluating FormComponentPanel .
> I looked into the document , it seems setConvertedInput() is the proper way
> .
> I use another method , which skips the setConvertedInput() , I don't know if
> it is suggested :
> Here is the code :
>
> public class TimePanel extends FormComponentPanel
> {
> private Time time;
>
> public TimePanel(String id , Time time )
> {
> super(id);
> this.time = time;
> add(new CheckBox("beforeChrist" , new PropertyModel(time ,
> "beforeChrist")));
> add(new TextField("year" , new PropertyModel(time , "year")));
> add(new TextField("month" , new PropertyModel(time , "month")));
> add(new TextField("day" , new PropertyModel(time , "day")));
>
> add(new TextField("hour" , new PropertyModel(time , "hour")));
> add(new TextField("minute" , new PropertyModel(time , "minute")));
> add(new TextField("second" , new PropertyModel(time , "second")));
> }
>
> }
>
> I embed this TimePanel to a form :
>
> Time time = new Time(); //my custom Time class
> add(new TimePanel("timePanel" , time));
> add(new Button("button")
> {
> @Override
> public void onSubmit()
> {
> System.out.println("time = " + time);
> }
> });
>
> It works .
> It seems by this way , I can skip implementing setConvertedInput() , right ?
> Is there any drawback ?
> Is this a suggested way ?
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org