aspose file tools*
The moose likes Other Open Source Projects and the fly likes get/set for Date fields using Apache Beanutils Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "get/set for Date fields using Apache Beanutils" Watch "get/set for Date fields using Apache Beanutils" New topic
Author

get/set for Date fields using Apache Beanutils

Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4634
    
    5

I'm using the Apache Beanutils code to populate my Bean's fields, and it works great for String valued fields.

But I can't figure out how to use it for the Date type fields.

Google shows links to something called DateLocaleConverter
but I can't find any examples of how it is used.

My code uses Beanutils with:

rMap = ctx.getRequest().getParameterMap();
BeanUtils.populate(this, rMap);

I have no idea what to do to work with a Date field such as

private Date dueDate;
public void setDueDate(xxx);
public xxx getDueDate();

Pointers greatly appreciated.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60041
    
  65

Heh heh... adding something to FrontMan 2.0 along these lines.

Here's a sneak peek. It's a work in progress so it's still rough around the edge.

Taken from a class that will do automatic param processing....




[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4634
    
    5

Bear Bibeault wrote:Heh heh... adding something to FrontMan 2.0 along these lines


So when will 2.0 be ready for beta testing?

And until then, what do I do to debug it.

I'm getting:

java.lang.IllegalArgumentException: Cannot convert 02/13/10 12:00 AM of type class java.lang.String to class java.util.Date

which makes no sense, as it is in the display of a JSP. The date is properly converted to a String, yet Beanutils seems to be trying to re-convert it to Date
I can't see where from the stackdump
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60041
    
  65

Pat Farrell wrote:So when will 2.0 be ready for beta testing?

Front Man 2.0 is unfortunately on hold until I finish writing the 2nd edition of jQuery in Action. I'm way behind schedule -- I keep expecting the publisher to send Guido down to break my kneecaps.

java.lang.IllegalArgumentException: Cannot convert 02/13/10 12:00 AM of type class java.lang.String to class java.util.Date


Where's that coming from? All exceptions should be eaten and it'll just return null if anything boofs up. At least that's the intent... as I said, not well tested yet!

So in a sense, you are already beta testing.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4634
    
    5

Bear Bibeault wrote:I keep expecting the publisher to send Guido down to break my kneecaps

That's Uncle Guido for you.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60041
    
  65

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: get/set for Date fields using Apache Beanutils
 
Similar Threads
How to redirect another page with value object fron ajax request
casting list of one class object into other class objects list
Adding 1 row to specific section of a struts table using iterate tag
Re: Beanutils custom converter + validation
BeanUtils.copyProperties