You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Kurt Heston <kh...@hestonsystems.com> on 2009/04/21 00:57:11 UTC

setConvertedInput

I'm building a StartAndEndDateTime form component based on Eelco's 
DateTimeField.  It is essentially the same as his with the time fields 
repeated.

The goal is to get my new custom component to update two date fields in 
the parent form's model.  Here is what the end of my convertInput() 
method look like:
<pre>
        Object mdlObj = getForm().getModelObject();
        new PropertyModel(mdlObj, "svcDate").setObject(new Date(date
            .getMillis()));
        new PropertyModel(mdlObj, "endSvcDate").setObject(new Date(endDate
            .getMillis()));

        setConvertedInput(<tried a number of things here>);
</pre>

I'm doing something wrong with setConvertedInput:

<pre>
ERROR org.apache.wicket.RequestCycle  - Error calling method: public 
void MyClass.setSvcDate(java.util.Date) on object: MyClass@e56328
</pre>

If I'm setting two fields in the Model, what should I pass to 
setConvertedInput?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setConvertedInput - one form component, two fields in the model?

Posted by Kurt Heston <kh...@hestonsystems.com>.
Very helpful, thank you.  I'm up and running now.

John Krasnay wrote:
> Since you're dealing with setConvertedInput I presume you're
> implementing FormComponentPanel. In that case, you need a single model
> object to encapsulate the idea of a date range. For example, you could
> implement your own DateRange class. Pass your panel a model that returns
> and accepts instances of DateRange, and set your converted input to an
> instance of DateRange.
>
> An alternate way is to use a regular Panel instead of a
> FormComponentPanel and pass it two models, one for the start date and
> one for the end date. You'll probably want to pass in the encapsulating
> Form object too, so you can add a FormValidator to ensure end > start.
>
> jk
>
> On Mon, Apr 20, 2009 at 09:38:46PM -0700, Kurt Heston wrote:
>   
>> I guess I also need to ask an even simpler question: can I manage two 
>> fields in the same IModel within a single form component?
>>
>> Kurt Heston wrote:
>>     
>>> I'm building a StartAndEndDateTime form component based on Eelco's 
>>> DateTimeField.  It is essentially the same as his with the time fields 
>>> repeated.
>>>
>>> The goal is to get my new custom component to update two date fields 
>>> in the parent form's model.  Here is what the end of my convertInput() 
>>> method look like:
>>> <pre>
>>>       Object mdlObj = getForm().getModelObject();
>>>       new PropertyModel(mdlObj, "svcDate").setObject(new Date(date
>>>           .getMillis()));
>>>       new PropertyModel(mdlObj, "endSvcDate").setObject(new Date(endDate
>>>           .getMillis()));
>>>
>>>       setConvertedInput(<tried a number of things here>);
>>> </pre>
>>>
>>> I'm doing something wrong with setConvertedInput:
>>>
>>> <pre>
>>> ERROR org.apache.wicket.RequestCycle  - Error calling method: public 
>>> void MyClass.setSvcDate(java.util.Date) on object: MyClass@e56328
>>> </pre>
>>>
>>> If I'm setting two fields in the Model, what should I pass to 
>>> setConvertedInput?
>>>
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setConvertedInput - one form component, two fields in the model?

Posted by John Krasnay <jo...@krasnay.ca>.
Since you're dealing with setConvertedInput I presume you're
implementing FormComponentPanel. In that case, you need a single model
object to encapsulate the idea of a date range. For example, you could
implement your own DateRange class. Pass your panel a model that returns
and accepts instances of DateRange, and set your converted input to an
instance of DateRange.

An alternate way is to use a regular Panel instead of a
FormComponentPanel and pass it two models, one for the start date and
one for the end date. You'll probably want to pass in the encapsulating
Form object too, so you can add a FormValidator to ensure end > start.

jk

On Mon, Apr 20, 2009 at 09:38:46PM -0700, Kurt Heston wrote:
> I guess I also need to ask an even simpler question: can I manage two 
> fields in the same IModel within a single form component?
> 
> Kurt Heston wrote:
> >I'm building a StartAndEndDateTime form component based on Eelco's 
> >DateTimeField.  It is essentially the same as his with the time fields 
> >repeated.
> >
> >The goal is to get my new custom component to update two date fields 
> >in the parent form's model.  Here is what the end of my convertInput() 
> >method look like:
> ><pre>
> >       Object mdlObj = getForm().getModelObject();
> >       new PropertyModel(mdlObj, "svcDate").setObject(new Date(date
> >           .getMillis()));
> >       new PropertyModel(mdlObj, "endSvcDate").setObject(new Date(endDate
> >           .getMillis()));
> >
> >       setConvertedInput(<tried a number of things here>);
> ></pre>
> >
> >I'm doing something wrong with setConvertedInput:
> >
> ><pre>
> >ERROR org.apache.wicket.RequestCycle  - Error calling method: public 
> >void MyClass.setSvcDate(java.util.Date) on object: MyClass@e56328
> ></pre>
> >
> >If I'm setting two fields in the Model, what should I pass to 
> >setConvertedInput?
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


setConvertedInput - one form component, two fields in the model?

Posted by Kurt Heston <kh...@hestonsystems.com>.
I guess I also need to ask an even simpler question: can I manage two 
fields in the same IModel within a single form component?

Kurt Heston wrote:
> I'm building a StartAndEndDateTime form component based on Eelco's 
> DateTimeField.  It is essentially the same as his with the time fields 
> repeated.
>
> The goal is to get my new custom component to update two date fields 
> in the parent form's model.  Here is what the end of my convertInput() 
> method look like:
> <pre>
>        Object mdlObj = getForm().getModelObject();
>        new PropertyModel(mdlObj, "svcDate").setObject(new Date(date
>            .getMillis()));
>        new PropertyModel(mdlObj, "endSvcDate").setObject(new Date(endDate
>            .getMillis()));
>
>        setConvertedInput(<tried a number of things here>);
> </pre>
>
> I'm doing something wrong with setConvertedInput:
>
> <pre>
> ERROR org.apache.wicket.RequestCycle  - Error calling method: public 
> void MyClass.setSvcDate(java.util.Date) on object: MyClass@e56328
> </pre>
>
> If I'm setting two fields in the Model, what should I pass to 
> setConvertedInput?
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org