File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes struts request values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts request values" Watch "struts request values" New topic

struts request values

jaisai vijay
Ranch Hand

Joined: Dec 17, 2009
Posts: 70
Hi All,

I have a form which has Id field text boxes I had to declare them as long in my form bean because database will store values long data type but in db those are integer type. here my problem is when the id fields are empty you submit the page you will get '0' instead of null so finally database will be updated with '0' but I want to update it as null.

Can anybody help me in this scenario?

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33129

You could define them as String in the form and parse them to int/long in Java.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
jaisai vijay
Ranch Hand

Joined: Dec 17, 2009
Posts: 70

Thanks for your response. I have that in my mind I wonder is there any other way with out parsing again this would be extra work right? that is what my concern is.
jaisai vijay
Ranch Hand

Joined: Dec 17, 2009
Posts: 70
Could any one please help in this?

Actually when I declared it as string I get empty string but when I need to store it into database that perticular field declared as number.

So if try to convert the string value to Long or Integer it throws me an exception. How to handle this situation?

Please help me !!!
I agree. Here's the link:
subject: struts request values
It's not a secret anymore!