You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Eduardo Simioni <si...@gmail.com> on 2008/11/24 21:30:08 UTC

DateTimeField and java.util.Calendar

Hi all,

I'm trying to use the DateTimeField from the wicket-datetime project. But I
realized that it's stuck to java.util.Date, all my entities use
java.util.Calendar to store dates. So the question is: Is there a clean way
to work with DateTimeField and java.util.Calendar "targets"?
I tried to find something in the list archive but looks like everybody uses
java.util.Date, or I'm missing something silly.

Thanks!

Eduardo.*
*

Re: DateTimeField and java.util.Calendar

Posted by jWeekend <jw...@cabouge.com>.
Eduardo,

See org.apache.wicket.extensions.yui.calendar.DateField if you want a popup
DateTextField does not have a popup
DateTimeField has fields for time (as well as date) 

All the javadoc seems to be 
http://repo1.maven.org/maven2/org/apache/wicket/wicket/ there .
http://repo1.maven.org/maven2/org/apache/wicket/wicket/
Also see  http://wicket.apache.org/quickstart.html this .

There are a lot of good people working on this project. The documentation is
constantly improving (but  http://manning.com/dashorst/ Wicket In Action  is
a great resource) and this forum will give you more help than you can buy
for money anywhere else.

Regards - Cemal
http://www.jWeekend.co.uk http://jWeekend.co.uk 





Eduardo Simioni wrote:
> 
> If you want Wicket to be competitive, you should think about better and
> centralized documentation.
> Many developer blogs is not documentation, an outdated wiki is not
> documentation, and definitely source code is not documentation.
> I'm saying all this, because, once again, I spent a lot of time to get to
> work something that should be easy and straight.
> The first problem was my mistake, I haven't had realized that the
> DatePicker
> was a separate component.
> But the second problem with the DateTimeField, as almost always, I had to
> realize myself what was happening looking at the source code of the
> component. There was no example, no documentation at all showing how to
> use
> the component.
> Wicket is the only framework I work with that is impossible to achieve
> simple tasks without opening the source code. I know that this can happen,
> and I sometimes have to open the source code of other frameworks, but with
> Wicket this happens all the time.
> Another problem is that JavaDoc doesn't come with the dist. I have to read
> it at source code as well, because on the website there is just the
> JavaDoc
> for the current release. Please, don't ask me to generate the JavaDoc
> myself.
> 
> Wicket is nice, but its doc is still very poor.
> 
> Eduardo.
> 
> On 11/26/08, Eduardo Simioni <si...@gmail.com> wrote:
>>
>> Nobody? Am I the only one having problems with these fields?
>>
>> Thanks,
>>
>> Eduardo.
>>
>> On 11/25/08, Eduardo Simioni <si...@gmail.com> wrote:
>>>
>>> Thanks for the hints.
>>>
>>> The conversion using nested models worked, although I have had to do
>>> some
>>> ugly things in the code because, unlike other fields, date fields
>>> model's
>>> don't get automatically updated when the form model is updated. Probably
>>> because of the converter model, it would definitely be better if we
>>> could
>>> work with something more "magic". But for now that's ok.
>>>
>>> The problem now is that the date fields don't show up as expected in the
>>> page. I tried the DateTextField as in the examples but the button to
>>> open
>>> the calendar pop-up is not showing in the page.
>>> The DateTimeField (my first option) has a different problem, it shows an
>>> extra field that does nothing, I could not manage to remove it. Are
>>> these
>>> known bugs? I'm using 1.4-m3.
>>>
>>> See this image: http://www.simioni.net/wicket-date-fields-problems.jpg
>>>
>>> The relevant parts of the code for the class and page are the following:
>>>
>>> Class:
>>> private class RankingForm extends EntityForm<Ranking> {
>>>
>>>         private CalendarToDateModel modelStartDate;
>>>         private CalendarToDateModel modelEndDate;
>>>
>>>         public RankingForm( IModel<Ranking> model, Component dataTable )
>>> {
>>>             super( model, dataTable );
>>>             add( new TextField<Ranking>( "name" ) );
>>>             modelStartDate = new CalendarToDateModel( new
>>> PropertyModel<Calendar>( model, "startDate" ) );
>>>             add( new DateTextField( "startDate", modelStartDate, new
>>> StyleDateConverter( "SM", false ) ) );
>>>             modelEndDate = new CalendarToDateModel( new
>>> PropertyModel<Calendar>( model, "endDate" ) );
>>>             add( new DateTimeField( "endDate", modelEndDate ) );
>>>             add( new TextField<Ranking>( "scoreRight" ) );
>>>             add( new TextField<Ranking>( "scoreWrong" ) );
>>>             add( new TextField<Ranking>( "scoreLimit" ) );
>>>         }
>>>
>>>         @Override
>>>         public MarkupContainer setDefaultModel( IModel<?> model ) {
>>>             modelStartDate.setDefaultModel( new PropertyModel<Calendar>(
>>> model, "startDate" ) );
>>>             modelEndDate.setDefaultModel( new PropertyModel<Calendar>(
>>> model, "endDate" ) );
>>>             return super.setDefaultModel( model );
>>>         }
>>> ...
>>>
>>> HTML:
>>> <form wicket:id="form">
>>>             <h2 wicket:id="createEdit">Criar/Editar Ranking</h2>
>>>             <div id="feedbackPanel" wicket:id="feedbackPanel">Feedback
>>> Panel</div>
>>>             <label for="name">Nome</label>: <input wicket:id="name"
>>> type="text" size="20"/><br />
>>>             <label for="startDate">Data/Hora Início</label>: <input
>>> type="text" wicket:id="startDate"/><br />
>>>             <label for="endDate">Data/Hora Fim</label>: <input
>>> type="text"
>>> wicket:id="endDate"/><br />
>>>             <label for="scoreRight">Pontos para Acerto</label>: <input
>>> wicket:id="scoreRight" type="text" size="10"/><br />
>>>             <label for="scoreWrong">Pontos para Erro</label>: <input
>>> wicket:id="scoreWrong" type="text" size="10"/><br />
>>>             <label for="scoreLimit">Limite de Pontos</label>: <input
>>> wicket:id="scoreLimit" type="text" size="10"/><br />
>>> ...
>>>
>>>
>>> Does anyone know a solution for these problems?
>>>
>>> Thanks!
>>>
>>> Eduardo.
>>>
>>>
>>> On 11/24/08, Jeremy Thomerson <je...@wickettraining.com> wrote:
>>>>
>>>> Yes - this would be a perfect time for a nested model - write a generic
>>>> model that implements IModel<Date> and takes an IModel<Calendar> as its
>>>> input.
>>>>
>>>> See
>>>>
>>>> http://www.jeremythomerson.com/blog/2008/11/06/wicket-the-power-of-nested-models/
>>>> for
>>>> assistance with the rest.
>>>>
>>>>
>>>> --
>>>> Jeremy Thomerson
>>>> http://www.wickettraining.com
>>>>
>>>>
>>>>
>>>>
>>>> On Mon, Nov 24, 2008 at 3:08 PM, Igor Vaynberg <igor.vaynberg@gmail.com
>>>> >wrote:
>>>>
>>>>
>>>> > write a model that converts to and from.
>>>> >
>>>> > -igor
>>>> >
>>>> > On Mon, Nov 24, 2008 at 12:30 PM, Eduardo Simioni
>>>> > <si...@gmail.com> wrote:
>>>> > > Hi all,
>>>> > >
>>>> > > I'm trying to use the DateTimeField from the wicket-datetime
>>>> project.
>>>> But
>>>> > I
>>>> > > realized that it's stuck to java.util.Date, all my entities use
>>>> > > java.util.Calendar to store dates. So the question is: Is there a
>>>> clean
>>>> > way
>>>> > > to work with DateTimeField and java.util.Calendar "targets"?
>>>> > > I tried to find something in the list archive but looks like
>>>> everybody
>>>> > uses
>>>> > > java.util.Date, or I'm missing something silly.
>>>> > >
>>>> > > Thanks!
>>>> > >
>>>> > > Eduardo.*
>>>> > > *
>>>> > >
>>>> >
>>>> > ---------------------------------------------------------------------
>>>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> > For additional commands, e-mail: users-help@wicket.apache.org
>>>> >
>>>> >
>>>>
>>>
>>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/DateTimeField-and-java.util.Calendar-tp20669154p20726929.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: DateTimeField and java.util.Calendar

Posted by Bruno Borges <br...@gmail.com>.
If you are working with Maven, you can set the Eclipse plugin to download
the source for you, then you will have the JavaDoc while developing through
this IDE.

You can also buy the Wicket in Action book (no, Martijn is not giving me any
money ... though I'd really appreciate a few dutch beers).

Anyway,  I think Wicket is well documented just like any other Web Framework
out there. If you look at the Struts documentation when that framework
completed 2 years of intensive development and community support, you would
be surprised of how poor that documentation was. By the way,  that
documentation didn't quite help too much to find out what was going on on
weird exceptions... ;-)

[]'s
Bruno Borges
blog.brunoborges.com.br
+55 21 76727099

"The glory of great men should always be
measured by the means they have used to
acquire it."
- Francois de La Rochefoucauld


On Thu, Nov 27, 2008 at 5:40 PM, Eduardo Simioni
<si...@gmail.com>wrote:

> If you want Wicket to be competitive, you should think about better and
> centralized documentation.
> Many developer blogs is not documentation, an outdated wiki is not
> documentation, and definitely source code is not documentation.
> I'm saying all this, because, once again, I spent a lot of time to get to
> work something that should be easy and straight.
> The first problem was my mistake, I haven't had realized that the
> DatePicker
> was a separate component.
> But the second problem with the DateTimeField, as almost always, I had to
> realize myself what was happening looking at the source code of the
> component. There was no example, no documentation at all showing how to use
> the component.
> Wicket is the only framework I work with that is impossible to achieve
> simple tasks without opening the source code. I know that this can happen,
> and I sometimes have to open the source code of other frameworks, but with
> Wicket this happens all the time.
> Another problem is that JavaDoc doesn't come with the dist. I have to read
> it at source code as well, because on the website there is just the JavaDoc
> for the current release. Please, don't ask me to generate the JavaDoc
> myself.
>
> Wicket is nice, but its doc is still very poor.
>
> Eduardo.
>
> On 11/26/08, Eduardo Simioni <si...@gmail.com> wrote:
> >
> > Nobody? Am I the only one having problems with these fields?
> >
> > Thanks,
> >
> > Eduardo.
> >
> > On 11/25/08, Eduardo Simioni <si...@gmail.com> wrote:
> >>
> >> Thanks for the hints.
> >>
> >> The conversion using nested models worked, although I have had to do
> some
> >> ugly things in the code because, unlike other fields, date fields
> model's
> >> don't get automatically updated when the form model is updated. Probably
> >> because of the converter model, it would definitely be better if we
> could
> >> work with something more "magic". But for now that's ok.
> >>
> >> The problem now is that the date fields don't show up as expected in the
> >> page. I tried the DateTextField as in the examples but the button to
> open
> >> the calendar pop-up is not showing in the page.
> >> The DateTimeField (my first option) has a different problem, it shows an
> >> extra field that does nothing, I could not manage to remove it. Are
> these
> >> known bugs? I'm using 1.4-m3.
> >>
> >> See this image: http://www.simioni.net/wicket-date-fields-problems.jpg
> >>
> >> The relevant parts of the code for the class and page are the following:
> >>
> >> Class:
> >> private class RankingForm extends EntityForm<Ranking> {
> >>
> >>         private CalendarToDateModel modelStartDate;
> >>         private CalendarToDateModel modelEndDate;
> >>
> >>         public RankingForm( IModel<Ranking> model, Component dataTable )
> {
> >>             super( model, dataTable );
> >>             add( new TextField<Ranking>( "name" ) );
> >>             modelStartDate = new CalendarToDateModel( new
> >> PropertyModel<Calendar>( model, "startDate" ) );
> >>             add( new DateTextField( "startDate", modelStartDate, new
> >> StyleDateConverter( "SM", false ) ) );
> >>             modelEndDate = new CalendarToDateModel( new
> >> PropertyModel<Calendar>( model, "endDate" ) );
> >>             add( new DateTimeField( "endDate", modelEndDate ) );
> >>             add( new TextField<Ranking>( "scoreRight" ) );
> >>             add( new TextField<Ranking>( "scoreWrong" ) );
> >>             add( new TextField<Ranking>( "scoreLimit" ) );
> >>         }
> >>
> >>         @Override
> >>         public MarkupContainer setDefaultModel( IModel<?> model ) {
> >>             modelStartDate.setDefaultModel( new PropertyModel<Calendar>(
> >> model, "startDate" ) );
> >>             modelEndDate.setDefaultModel( new PropertyModel<Calendar>(
> >> model, "endDate" ) );
> >>             return super.setDefaultModel( model );
> >>         }
> >> ...
> >>
> >> HTML:
> >> <form wicket:id="form">
> >>             <h2 wicket:id="createEdit">Criar/Editar Ranking</h2>
> >>             <div id="feedbackPanel" wicket:id="feedbackPanel">Feedback
> >> Panel</div>
> >>             <label for="name">Nome</label>: <input wicket:id="name"
> >> type="text" size="20"/><br />
> >>             <label for="startDate">Data/Hora Início</label>: <input
> >> type="text" wicket:id="startDate"/><br />
> >>             <label for="endDate">Data/Hora Fim</label>: <input
> type="text"
> >> wicket:id="endDate"/><br />
> >>             <label for="scoreRight">Pontos para Acerto</label>: <input
> >> wicket:id="scoreRight" type="text" size="10"/><br />
> >>             <label for="scoreWrong">Pontos para Erro</label>: <input
> >> wicket:id="scoreWrong" type="text" size="10"/><br />
> >>             <label for="scoreLimit">Limite de Pontos</label>: <input
> >> wicket:id="scoreLimit" type="text" size="10"/><br />
> >> ...
> >>
> >>
> >> Does anyone know a solution for these problems?
> >>
> >> Thanks!
> >>
> >> Eduardo.
> >>
> >>
> >> On 11/24/08, Jeremy Thomerson <je...@wickettraining.com> wrote:
> >>>
> >>> Yes - this would be a perfect time for a nested model - write a generic
> >>> model that implements IModel<Date> and takes an IModel<Calendar> as its
> >>> input.
> >>>
> >>> See
> >>>
> >>>
> http://www.jeremythomerson.com/blog/2008/11/06/wicket-the-power-of-nested-models/
> >>> for
> >>> assistance with the rest.
> >>>
> >>>
> >>> --
> >>> Jeremy Thomerson
> >>> http://www.wickettraining.com
> >>>
> >>>
> >>>
> >>>
> >>> On Mon, Nov 24, 2008 at 3:08 PM, Igor Vaynberg <
> igor.vaynberg@gmail.com
> >>> >wrote:
> >>>
> >>>
> >>> > write a model that converts to and from.
> >>> >
> >>> > -igor
> >>> >
> >>> > On Mon, Nov 24, 2008 at 12:30 PM, Eduardo Simioni
> >>> > <si...@gmail.com> wrote:
> >>> > > Hi all,
> >>> > >
> >>> > > I'm trying to use the DateTimeField from the wicket-datetime
> project.
> >>> But
> >>> > I
> >>> > > realized that it's stuck to java.util.Date, all my entities use
> >>> > > java.util.Calendar to store dates. So the question is: Is there a
> >>> clean
> >>> > way
> >>> > > to work with DateTimeField and java.util.Calendar "targets"?
> >>> > > I tried to find something in the list archive but looks like
> >>> everybody
> >>> > uses
> >>> > > java.util.Date, or I'm missing something silly.
> >>> > >
> >>> > > Thanks!
> >>> > >
> >>> > > Eduardo.*
> >>> > > *
> >>> > >
> >>> >
> >>> > ---------------------------------------------------------------------
> >>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> > For additional commands, e-mail: users-help@wicket.apache.org
> >>> >
> >>> >
> >>>
> >>
> >>
> >
>

Re: DateTimeField and java.util.Calendar

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Thu, 27 Nov 2008, Eduardo Simioni wrote:
> If you want Wicket to be competitive, you should think about better and
> centralized documentation.

Or better yet write it :) The wiki is centralised and open,
everybody is more than welcome to update and improve it.

> documentation, and definitely source code is not documentation.

Definitely source code is documentation and I find Wicket
source code mostly understandable. It can be improved though,
and here your patches are most welcome again :) In some
places, the readability has to give way to optimisation
though.

> Another problem is that JavaDoc doesn't come with the dist. I have to read
> it at source code as well, because on the website there is just the JavaDoc
> for the current release. Please, don't ask me to generate the JavaDoc
> myself.

Nope, with Wicket (and any open source framework) you should
just bundle the sources in your IDE, then the IDE will show
javadocs as well. And javadocs always make more sense to read
with the actual source code.

E.g.

  mvn -DdownloadSources eclipse:eclipse

Best wishes,
Timo


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


Re: DateTimeField and java.util.Calendar

Posted by Eduardo Simioni <si...@gmail.com>.
If you want Wicket to be competitive, you should think about better and
centralized documentation.
Many developer blogs is not documentation, an outdated wiki is not
documentation, and definitely source code is not documentation.
I'm saying all this, because, once again, I spent a lot of time to get to
work something that should be easy and straight.
The first problem was my mistake, I haven't had realized that the DatePicker
was a separate component.
But the second problem with the DateTimeField, as almost always, I had to
realize myself what was happening looking at the source code of the
component. There was no example, no documentation at all showing how to use
the component.
Wicket is the only framework I work with that is impossible to achieve
simple tasks without opening the source code. I know that this can happen,
and I sometimes have to open the source code of other frameworks, but with
Wicket this happens all the time.
Another problem is that JavaDoc doesn't come with the dist. I have to read
it at source code as well, because on the website there is just the JavaDoc
for the current release. Please, don't ask me to generate the JavaDoc
myself.

Wicket is nice, but its doc is still very poor.

Eduardo.

On 11/26/08, Eduardo Simioni <si...@gmail.com> wrote:
>
> Nobody? Am I the only one having problems with these fields?
>
> Thanks,
>
> Eduardo.
>
> On 11/25/08, Eduardo Simioni <si...@gmail.com> wrote:
>>
>> Thanks for the hints.
>>
>> The conversion using nested models worked, although I have had to do some
>> ugly things in the code because, unlike other fields, date fields model's
>> don't get automatically updated when the form model is updated. Probably
>> because of the converter model, it would definitely be better if we could
>> work with something more "magic". But for now that's ok.
>>
>> The problem now is that the date fields don't show up as expected in the
>> page. I tried the DateTextField as in the examples but the button to open
>> the calendar pop-up is not showing in the page.
>> The DateTimeField (my first option) has a different problem, it shows an
>> extra field that does nothing, I could not manage to remove it. Are these
>> known bugs? I'm using 1.4-m3.
>>
>> See this image: http://www.simioni.net/wicket-date-fields-problems.jpg
>>
>> The relevant parts of the code for the class and page are the following:
>>
>> Class:
>> private class RankingForm extends EntityForm<Ranking> {
>>
>>         private CalendarToDateModel modelStartDate;
>>         private CalendarToDateModel modelEndDate;
>>
>>         public RankingForm( IModel<Ranking> model, Component dataTable ) {
>>             super( model, dataTable );
>>             add( new TextField<Ranking>( "name" ) );
>>             modelStartDate = new CalendarToDateModel( new
>> PropertyModel<Calendar>( model, "startDate" ) );
>>             add( new DateTextField( "startDate", modelStartDate, new
>> StyleDateConverter( "SM", false ) ) );
>>             modelEndDate = new CalendarToDateModel( new
>> PropertyModel<Calendar>( model, "endDate" ) );
>>             add( new DateTimeField( "endDate", modelEndDate ) );
>>             add( new TextField<Ranking>( "scoreRight" ) );
>>             add( new TextField<Ranking>( "scoreWrong" ) );
>>             add( new TextField<Ranking>( "scoreLimit" ) );
>>         }
>>
>>         @Override
>>         public MarkupContainer setDefaultModel( IModel<?> model ) {
>>             modelStartDate.setDefaultModel( new PropertyModel<Calendar>(
>> model, "startDate" ) );
>>             modelEndDate.setDefaultModel( new PropertyModel<Calendar>(
>> model, "endDate" ) );
>>             return super.setDefaultModel( model );
>>         }
>> ...
>>
>> HTML:
>> <form wicket:id="form">
>>             <h2 wicket:id="createEdit">Criar/Editar Ranking</h2>
>>             <div id="feedbackPanel" wicket:id="feedbackPanel">Feedback
>> Panel</div>
>>             <label for="name">Nome</label>: <input wicket:id="name"
>> type="text" size="20"/><br />
>>             <label for="startDate">Data/Hora Início</label>: <input
>> type="text" wicket:id="startDate"/><br />
>>             <label for="endDate">Data/Hora Fim</label>: <input type="text"
>> wicket:id="endDate"/><br />
>>             <label for="scoreRight">Pontos para Acerto</label>: <input
>> wicket:id="scoreRight" type="text" size="10"/><br />
>>             <label for="scoreWrong">Pontos para Erro</label>: <input
>> wicket:id="scoreWrong" type="text" size="10"/><br />
>>             <label for="scoreLimit">Limite de Pontos</label>: <input
>> wicket:id="scoreLimit" type="text" size="10"/><br />
>> ...
>>
>>
>> Does anyone know a solution for these problems?
>>
>> Thanks!
>>
>> Eduardo.
>>
>>
>> On 11/24/08, Jeremy Thomerson <je...@wickettraining.com> wrote:
>>>
>>> Yes - this would be a perfect time for a nested model - write a generic
>>> model that implements IModel<Date> and takes an IModel<Calendar> as its
>>> input.
>>>
>>> See
>>>
>>> http://www.jeremythomerson.com/blog/2008/11/06/wicket-the-power-of-nested-models/
>>> for
>>> assistance with the rest.
>>>
>>>
>>> --
>>> Jeremy Thomerson
>>> http://www.wickettraining.com
>>>
>>>
>>>
>>>
>>> On Mon, Nov 24, 2008 at 3:08 PM, Igor Vaynberg <igor.vaynberg@gmail.com
>>> >wrote:
>>>
>>>
>>> > write a model that converts to and from.
>>> >
>>> > -igor
>>> >
>>> > On Mon, Nov 24, 2008 at 12:30 PM, Eduardo Simioni
>>> > <si...@gmail.com> wrote:
>>> > > Hi all,
>>> > >
>>> > > I'm trying to use the DateTimeField from the wicket-datetime project.
>>> But
>>> > I
>>> > > realized that it's stuck to java.util.Date, all my entities use
>>> > > java.util.Calendar to store dates. So the question is: Is there a
>>> clean
>>> > way
>>> > > to work with DateTimeField and java.util.Calendar "targets"?
>>> > > I tried to find something in the list archive but looks like
>>> everybody
>>> > uses
>>> > > java.util.Date, or I'm missing something silly.
>>> > >
>>> > > Thanks!
>>> > >
>>> > > Eduardo.*
>>> > > *
>>> > >
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > For additional commands, e-mail: users-help@wicket.apache.org
>>> >
>>> >
>>>
>>
>>
>

Re: DateTimeField and java.util.Calendar

Posted by Eduardo Simioni <si...@gmail.com>.
Nobody? Am I the only one having problems with these fields?

Thanks,

Eduardo.

On 11/25/08, Eduardo Simioni <si...@gmail.com> wrote:
>
> Thanks for the hints.
>
> The conversion using nested models worked, although I have had to do some
> ugly things in the code because, unlike other fields, date fields model's
> don't get automatically updated when the form model is updated. Probably
> because of the converter model, it would definitely be better if we could
> work with something more "magic". But for now that's ok.
>
> The problem now is that the date fields don't show up as expected in the
> page. I tried the DateTextField as in the examples but the button to open
> the calendar pop-up is not showing in the page.
> The DateTimeField (my first option) has a different problem, it shows an
> extra field that does nothing, I could not manage to remove it. Are these
> known bugs? I'm using 1.4-m3.
>
> See this image: http://www.simioni.net/wicket-date-fields-problems.jpg
>
> The relevant parts of the code for the class and page are the following:
>
> Class:
> private class RankingForm extends EntityForm<Ranking> {
>
>         private CalendarToDateModel modelStartDate;
>         private CalendarToDateModel modelEndDate;
>
>         public RankingForm( IModel<Ranking> model, Component dataTable ) {
>             super( model, dataTable );
>             add( new TextField<Ranking>( "name" ) );
>             modelStartDate = new CalendarToDateModel( new
> PropertyModel<Calendar>( model, "startDate" ) );
>             add( new DateTextField( "startDate", modelStartDate, new
> StyleDateConverter( "SM", false ) ) );
>             modelEndDate = new CalendarToDateModel( new
> PropertyModel<Calendar>( model, "endDate" ) );
>             add( new DateTimeField( "endDate", modelEndDate ) );
>             add( new TextField<Ranking>( "scoreRight" ) );
>             add( new TextField<Ranking>( "scoreWrong" ) );
>             add( new TextField<Ranking>( "scoreLimit" ) );
>         }
>
>         @Override
>         public MarkupContainer setDefaultModel( IModel<?> model ) {
>             modelStartDate.setDefaultModel( new PropertyModel<Calendar>(
> model, "startDate" ) );
>             modelEndDate.setDefaultModel( new PropertyModel<Calendar>(
> model, "endDate" ) );
>             return super.setDefaultModel( model );
>         }
> ...
>
> HTML:
> <form wicket:id="form">
>             <h2 wicket:id="createEdit">Criar/Editar Ranking</h2>
>             <div id="feedbackPanel" wicket:id="feedbackPanel">Feedback
> Panel</div>
>             <label for="name">Nome</label>: <input wicket:id="name"
> type="text" size="20"/><br />
>             <label for="startDate">Data/Hora Início</label>: <input
> type="text" wicket:id="startDate"/><br />
>             <label for="endDate">Data/Hora Fim</label>: <input type="text"
> wicket:id="endDate"/><br />
>             <label for="scoreRight">Pontos para Acerto</label>: <input
> wicket:id="scoreRight" type="text" size="10"/><br />
>             <label for="scoreWrong">Pontos para Erro</label>: <input
> wicket:id="scoreWrong" type="text" size="10"/><br />
>             <label for="scoreLimit">Limite de Pontos</label>: <input
> wicket:id="scoreLimit" type="text" size="10"/><br />
> ...
>
>
> Does anyone know a solution for these problems?
>
> Thanks!
>
> Eduardo.
>
>
> On 11/24/08, Jeremy Thomerson <je...@wickettraining.com> wrote:
>>
>> Yes - this would be a perfect time for a nested model - write a generic
>> model that implements IModel<Date> and takes an IModel<Calendar> as its
>> input.
>>
>> See
>>
>> http://www.jeremythomerson.com/blog/2008/11/06/wicket-the-power-of-nested-models/
>> for
>> assistance with the rest.
>>
>>
>> --
>> Jeremy Thomerson
>> http://www.wickettraining.com
>>
>>
>>
>>
>> On Mon, Nov 24, 2008 at 3:08 PM, Igor Vaynberg <igor.vaynberg@gmail.com
>> >wrote:
>>
>>
>> > write a model that converts to and from.
>> >
>> > -igor
>> >
>> > On Mon, Nov 24, 2008 at 12:30 PM, Eduardo Simioni
>> > <si...@gmail.com> wrote:
>> > > Hi all,
>> > >
>> > > I'm trying to use the DateTimeField from the wicket-datetime project.
>> But
>> > I
>> > > realized that it's stuck to java.util.Date, all my entities use
>> > > java.util.Calendar to store dates. So the question is: Is there a
>> clean
>> > way
>> > > to work with DateTimeField and java.util.Calendar "targets"?
>> > > I tried to find something in the list archive but looks like everybody
>> > uses
>> > > java.util.Date, or I'm missing something silly.
>> > >
>> > > Thanks!
>> > >
>> > > Eduardo.*
>> > > *
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>>
>
>

Re: DateTimeField and java.util.Calendar

Posted by Eduardo Simioni <ed...@simioni.net>.
Thanks for the hints.

The conversion using nested models worked, although I have had to do some
ugly things in the code because, unlike other fields, date fields model's
don't get automatically updated when the form model is updated. Probably
because of the converter model, it would definitely be better if we could
work with something more "magic". But for now that's ok.

The problem now is that the date fields don't show up as expected in the
page. I tried the DateTextField as in the examples but the button to open
the calendar pop-up is not showing in the page.
The DateTimeField (my first option) has a different problem, it shows an
extra field that does nothing, I could not manage to remove it. Are these
known bugs? I'm using 1.4-m3.

See this image: http://www.simioni.net/wicket-date-fields-problems.jpg

The relevant parts of the code for the class and page are the following:

Class:
private class RankingForm extends EntityForm<Ranking> {

        private CalendarToDateModel modelStartDate;
        private CalendarToDateModel modelEndDate;

        public RankingForm( IModel<Ranking> model, Component dataTable ) {
            super( model, dataTable );
            add( new TextField<Ranking>( "name" ) );
            modelStartDate = new CalendarToDateModel( new
PropertyModel<Calendar>( model, "startDate" ) );
            add( new DateTextField( "startDate", modelStartDate, new
StyleDateConverter( "SM", false ) ) );
            modelEndDate = new CalendarToDateModel( new
PropertyModel<Calendar>( model, "endDate" ) );
            add( new DateTimeField( "endDate", modelEndDate ) );
            add( new TextField<Ranking>( "scoreRight" ) );
            add( new TextField<Ranking>( "scoreWrong" ) );
            add( new TextField<Ranking>( "scoreLimit" ) );
        }

        @Override
        public MarkupContainer setDefaultModel( IModel<?> model ) {
            modelStartDate.setDefaultModel( new PropertyModel<Calendar>(
model, "startDate" ) );
            modelEndDate.setDefaultModel( new PropertyModel<Calendar>(
model, "endDate" ) );
            return super.setDefaultModel( model );
        }
...

HTML:
<form wicket:id="form">
            <h2 wicket:id="createEdit">Criar/Editar Ranking</h2>
            <div id="feedbackPanel" wicket:id="feedbackPanel">Feedback
Panel</div>
            <label for="name">Nome</label>: <input wicket:id="name"
type="text" size="20"/><br />
            <label for="startDate">Data/Hora Início</label>: <input
type="text" wicket:id="startDate"/><br />
            <label for="endDate">Data/Hora Fim</label>: <input type="text"
wicket:id="endDate"/><br />
            <label for="scoreRight">Pontos para Acerto</label>: <input
wicket:id="scoreRight" type="text" size="10"/><br />
            <label for="scoreWrong">Pontos para Erro</label>: <input
wicket:id="scoreWrong" type="text" size="10"/><br />
            <label for="scoreLimit">Limite de Pontos</label>: <input
wicket:id="scoreLimit" type="text" size="10"/><br />
...


Does anyone know a solution for these problems?

Thanks!

Eduardo.


On 11/24/08, Jeremy Thomerson <je...@wickettraining.com> wrote:
>
> Yes - this would be a perfect time for a nested model - write a generic
> model that implements IModel<Date> and takes an IModel<Calendar> as its
> input.
>
> See
>
> http://www.jeremythomerson.com/blog/2008/11/06/wicket-the-power-of-nested-models/
> for
> assistance with the rest.
>
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
>
> On Mon, Nov 24, 2008 at 3:08 PM, Igor Vaynberg <igor.vaynberg@gmail.com
> >wrote:
>
>
> > write a model that converts to and from.
> >
> > -igor
> >
> > On Mon, Nov 24, 2008 at 12:30 PM, Eduardo Simioni
> > <si...@gmail.com> wrote:
> > > Hi all,
> > >
> > > I'm trying to use the DateTimeField from the wicket-datetime project.
> But
> > I
> > > realized that it's stuck to java.util.Date, all my entities use
> > > java.util.Calendar to store dates. So the question is: Is there a clean
> > way
> > > to work with DateTimeField and java.util.Calendar "targets"?
> > > I tried to find something in the list archive but looks like everybody
> > uses
> > > java.util.Date, or I'm missing something silly.
> > >
> > > Thanks!
> > >
> > > Eduardo.*
> > > *
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>

Re: DateTimeField and java.util.Calendar

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Yes - this would be a perfect time for a nested model - write a generic
model that implements IModel<Date> and takes an IModel<Calendar> as its
input.

See
http://www.jeremythomerson.com/blog/2008/11/06/wicket-the-power-of-nested-models/
for
assistance with the rest.

-- 
Jeremy Thomerson
http://www.wickettraining.com




On Mon, Nov 24, 2008 at 3:08 PM, Igor Vaynberg <ig...@gmail.com>wrote:

> write a model that converts to and from.
>
> -igor
>
> On Mon, Nov 24, 2008 at 12:30 PM, Eduardo Simioni
> <si...@gmail.com> wrote:
> > Hi all,
> >
> > I'm trying to use the DateTimeField from the wicket-datetime project. But
> I
> > realized that it's stuck to java.util.Date, all my entities use
> > java.util.Calendar to store dates. So the question is: Is there a clean
> way
> > to work with DateTimeField and java.util.Calendar "targets"?
> > I tried to find something in the list archive but looks like everybody
> uses
> > java.util.Date, or I'm missing something silly.
> >
> > Thanks!
> >
> > Eduardo.*
> > *
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: DateTimeField and java.util.Calendar

Posted by Igor Vaynberg <ig...@gmail.com>.
write a model that converts to and from.

-igor

On Mon, Nov 24, 2008 at 12:30 PM, Eduardo Simioni
<si...@gmail.com> wrote:
> Hi all,
>
> I'm trying to use the DateTimeField from the wicket-datetime project. But I
> realized that it's stuck to java.util.Date, all my entities use
> java.util.Calendar to store dates. So the question is: Is there a clean way
> to work with DateTimeField and java.util.Calendar "targets"?
> I tried to find something in the list archive but looks like everybody uses
> java.util.Date, or I'm missing something silly.
>
> Thanks!
>
> Eduardo.*
> *
>

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