This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Strange struts behavior  RSS feed

 
N Nanda
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 37382
531
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!