You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by jp...@mchsi.com on 2009/07/06 22:38:18 UTC

Model Question

I have the following code to allow the user to select the date that a report is to be generated for. For some reason, though, whatever date is selected from the textfield, the previous date is being used. For example, if the user inputs 07/06/2009 into the dateTextField, 07/05/2009 is being used. I'm assuming this is because I'm using the wrong model, so any assistance would be greatly appreciated.

public class AccountingDashboardPage extends EzdecBaseWebPage {
    private Date date;

    public AccountingDashboardPage(Date date) {
        if (date == null) {
            this.date = new Date();
        }

        Form form = new Form("accountingDashboardForm", new PropertyModel(this, "date")) {
            @Override
            protected void onSubmit() {
                Date d = (Date)getModelObject();
                setResponsePage(new AccountingDashboardPage(d));
            }
        };

        add(form);
        
        EzdecDateTextField reportDate = new EzdecDateTextField("stampDate", form.getModel());
        reportDate.setModelValue(new String[]{new SimpleDateFormat("MM/dd/yyyy").format(date).toString()});
        form.add(reportDate);

        
        
    }
}


Re: Model Question

Posted by Linda van der Pal <lv...@heritageagenturen.nl>.
Is there a Calendar object under the covers somewhere? Cause it looks 
like a conversion error, seeing how the months start counting from zero 
in the Calendar object.

Regards,
Linda

jpalmer1026@mchsi.com wrote:
> I have the following code to allow the user to select the date that a 
> report is to be generated for. For some reason, though, whatever date 
> is selected from the textfield, the previous date is being used. For 
> example, if the user inputs 07/06/2009 into the dateTextField, 
> 07/05/2009 is being used. I'm assuming this is because I'm using the 
> wrong model, so any assistance would be greatly appreciated.
>
> public class AccountingDashboardPage extends EzdecBaseWebPage {
>     private Date date;
>
>     public AccountingDashboardPage(Date date) {
>         if (date == null) {
>             this.date = new Date();
>         }
>
>         Form form = new Form("accountingDashboardForm", new 
> PropertyModel(this, "date")) {
>             @Override
>             protected void onSubmit() {
>                 Date d = (Date)getModelObject();
>                 setResponsePage(new AccountingDashboardPage(d));
>             }
>         };
>
>         add(form);
>         
>         EzdecDateTextField reportDate = new 
> EzdecDateTextField("stampDate", form.getModel());
>         reportDate.setModelValue(new String[]{new 
> SimpleDateFormat("MM/dd/yyyy").format(date).toString()});
>         form.add(reportDate);
>
>        
>         
>     }
> }
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com 
> Version: 8.5.375 / Virus Database: 270.13.5/2220 - Release Date: 07/05/09 17:54:00
>
>   


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