aspose file tools*
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 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Strange struts behavior" Watch "Strange struts behavior" New topic
Author

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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

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


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Strange struts behavior
 
Similar Threads
Primary Key Class - error
database error handling
insert new parent/child row. How to handle new primary/foreign key inserts
Validation
"null is requred" validation message