Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts Validate problem

 
Sahil Sharma
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

We are using struts framework to build our application. We r facing 1 small problem.We are using struts validate method to perform validations.Problem here is, whenever user submits incomplete information our validate method checks that and return errors back to the same page but the data entered by the user on the form is not maintained and blank fields are displayed.My ActionForm is in request scope.

Kindly Help
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our Struts forum...
 
David Pizon
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@ page language="java" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html:html xhtml="true" locale="true">
<head>
<html:base />
<title>Sample form</title>
</head>
<body>
<html:form action="/Sample">
<%-- input field for properties --%>
<p>Sample field: <html:text property="field1" /></p>
<p>Sample field: <html:text property="field2" /></p>
<html:submit property="submit" value="submit" />
</html:form>
</body>
</html:html>
 
David Pizon
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using struts tags or generic <input> tags?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a frequently encountered problem. Read this thread and this otherthread. Hopefully they will answer your question. If you still have doubts, let us know.
 
Sahil Sharma
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we are using struts tags of (struts 1.1). I have solved the problem, but its quite unusual. We have used html:form tags for our form element.And we have used three of its attribute namely action, name and type. Now if I remove name and type from the html:form then everything works fine and values are also maintained but when I use them entered values are lost.

I will also look at those thread's.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic