jQuery in Action, 3rd edition
The moose likes Struts and the fly likes Strange struts behavior Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Strange struts behavior" Watch "Strange struts behavior" New topic

Strange struts behavior

N Nanda
Ranch Hand

Joined: Feb 09, 2004
Posts: 62
Hi to all... I am using struts to develop a web application. I am using mySQL as my backend database. I have a form namely "testForm" which has 2 fields (1 primary key field). When I am saving something into that database from my form with primary key field as blank, it is saved. But logically it should throw an exception (may be SQLException). In database that blank field value is entered as "". Kindly help me to resolve this problem if anybody has a good explanation.

Thanks all in advance.

Niranjan Nanda
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

In the validate() method of your form, check that the primary key is not an empty string. If it is, you return an ActionError and the original form is redisplayed.

[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
It is sorta covered in the JavaRanch Style Guide.
subject: Strange struts behavior
jQuery in Action, 3rd edition