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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Reply 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: 4422
    
    2

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: 56223
    
  13

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....




[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4422
    
    2

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: 56223
    
  13

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: 4422
    
    2

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: 56223
    
  13

 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: get/set for Date fields using Apache Beanutils
 
Similar Threads
Re: Beanutils custom converter + validation
casting list of one class object into other class objects list
How to redirect another page with value object fron ajax request
Adding 1 row to specific section of a struts table using iterate tag
BeanUtils.copyProperties