[Wicket-user] How to set a date on backing model obj from contents of drop down lists?

2007-07-31 Thread Justin Morgan (Logic Sector)
Hi all,

Sorry for the potentially noobish question, but I'm not sure how to  
go about this in Wicket...

I need to set a Date on a form's model object by way of three drop  
down lists.  The drop downs look something like this:

Drop down 1 contents:  Month, January, February, ..., December
Drop down 2 contents:  Day, 1, 2, ..., 31
Drop down 3 contents:  Year, 2007, 2006, ..., 1907

Clicking the Submit button on the form will save a single  
java.util.Date object on the form's backing model object based on the  
aggregate values of the three lists' selections.

Thanks for any suggestions,

Justin

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
IMPORTANT NOTICE:

This mailing list is shutting down. Please subscribe to the Apache Wicket user 
list. Send a message to: users-subscribe at wicket.apache.org and follow the 
instructions.
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] How to set a date on backing model obj from contents of drop down lists?

2007-07-31 Thread Igor Vaynberg
if you really want something that binds to the Date then create 3 models,
each adjusting the specific portion of the date, for example:

class YearModel implements IModel {
 private final IModel date;

  Object getObject() {return date.getObject().getYear();}
  void setObject(Object o) { date.getObject().setYear((Integer)o); }
   void detach() { date.detach(); }
}

-igor



On 7/31/07, David Leangen [EMAIL PROTECTED] wrote:


 One suggestion: what about having a date pojo like:

 public class MyDate
 {
   get/setMonth()
   get/setDay()
   get/setYear()

   public Date getDate()
   {
  // translate object state into a Date object
   }
 }


 Then use PropertyModel to get/set the individual fields:

 Component myComponent = new WhateverComponent( id, new
 PropertyModel( myDate, fieldOfDate );


 That should work.


 Maybe more experienced people know of a more elegant way, though this
 way's not so bad.


 Cheers,
 Dave




 On Mon, 2007-07-30 at 23:45 -0700, Justin Morgan (Logic Sector) wrote:
  Hi all,
 
  Sorry for the potentially noobish question, but I'm not sure how to
  go about this in Wicket...
 
  I need to set a Date on a form's model object by way of three drop
  down lists.  The drop downs look something like this:
 
  Drop down 1 contents:  Month, January, February, ..., December
  Drop down 2 contents:  Day, 1, 2, ..., 31
  Drop down 3 contents:  Year, 2007, 2006, ..., 1907
 
  Clicking the Submit button on the form will save a single
  java.util.Date object on the form's backing model object based on the
  aggregate values of the three lists' selections.
 
  Thanks for any suggestions,
 
  Justin
 
 
 -
  This SF.net email is sponsored by: Splunk Inc.
  Still grepping through log files to find problems?  Stop.
  Now Search log events and configuration files using AJAX and a browser.
  Download your FREE copy of Splunk now   http://get.splunk.com/
  ___
  IMPORTANT NOTICE:
 
  This mailing list is shutting down. Please subscribe to the Apache
 Wicket user list. Send a message to: users-subscribe at wicket.apache.org
 and follow the instructions.
  ___
  Wicket-user mailing list
  Wicket-user@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/wicket-user


 -
 This SF.net email is sponsored by: Splunk Inc.
 Still grepping through log files to find problems?  Stop.
 Now Search log events and configuration files using AJAX and a browser.
 Download your FREE copy of Splunk now   http://get.splunk.com/
 ___
 IMPORTANT NOTICE:

 This mailing list is shutting down. Please subscribe to the Apache Wicket
 user list. Send a message to: users-subscribe at wicket.apache.org and
 follow the instructions.
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
IMPORTANT NOTICE:

This mailing list is shutting down. Please subscribe to the Apache Wicket user 
list. Send a message to: users-subscribe at wicket.apache.org and follow the 
instructions.
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] How to set a date on backing model obj from contents of drop down lists?

2007-07-31 Thread David Rosenstrauch
David Leangen wrote:
 One suggestion: what about having a date pojo like:
 
 public class MyDate
 {
   get/setMonth()
   get/setDay()
   get/setYear()
 
   public Date getDate()
   {
  // translate object state into a Date object
   }
 }
 
 
 Then use PropertyModel to get/set the individual fields:
 
 Component myComponent = new WhateverComponent( id, new
 PropertyModel( myDate, fieldOfDate );
 
 
 That should work.
 
 
 Maybe more experienced people know of a more elegant way, though this
 way's not so bad.
 
 
 Cheers,
 Dave

That's how I would do it.

DR

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
IMPORTANT NOTICE:

This mailing list is shutting down. Please subscribe to the Apache Wicket user 
list. Send a message to: users-subscribe at wicket.apache.org and follow the 
instructions.
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user