Solved

Value getting reset for Textarea after validation

Posted on 2009-07-07
5
548 Views
Last Modified: 2012-05-07
Hello Experts. This is the first time i have encountered this problem. I have a form where i have couple of textarea and some Text fields with submit button. I am using SimpleFormController with Spring validator.

Everytime a user clicks Submit button i am validating to see if all the required fields have been filled out or not. If not then display the message to the user. Everything is working fine but unfortunately if a user types something in the Textarea and forgot to enter data in one of the textbox and he clicks submit then my value from the textarea is getting reset.

Has anyone else encountered this issue for the Textarea ?. If not then could you point out what am i doing wrong ?
<tr>	
<td align = "left">Enter Notes</td>
<td colspan="3" align = "left">
<spring:bind path="user.notes">
	<TEXTAREA rows="3" cols="30" size="30"
	name='<c:out value="${status.expression}"/>'
	value='<c:out value="${status.value}"/>'>
</TEXTAREA>
	<span><font color="red"><c:out
	value="${status.errorMessage}" />
	</font>
	</span>
</spring:bind>
</td>
</tr>

Open in new window

0
Comment
Question by:Micheal_Male
  • 3
  • 2
5 Comments
 
LVL 13

Accepted Solution

by:
Murali Murugesan earned 125 total points
ID: 24799912
Textarea doesn't have value attribute.

 <TEXTAREA rows="3" cols="30" size="30"
        name='<c:out value="${status.expression}"/>'>
<c:out value="${status.value}"/>
</TEXTAREA>


try this.

-Murali*
0
 

Author Comment

by:Micheal_Male
ID: 24799997
Murali. Thanks for your reply. This works when i am retrieving the value from the DB. Unfortunately with the statement you posted neither the validator works for it nor the value comes.
0
 
LVL 13

Assisted Solution

by:Murali Murugesan
Murali Murugesan earned 125 total points
ID: 24800021
you cannot have spring bind for errors.

<spring:bind path="user.notes">
        <TEXTAREA rows="3" cols="30" size="30"
        name='<c:out value="${status.expression}"/>'>
<c:out value="${status.value}"/>
</TEXTAREA>
</spring:bind>
 <form:errors path="user.notes" cssClass="errorBox" />

this is how i used to write. You can also move ur error message next to </spring:bind> inplace of <form:errors>

-Murali*



0
 

Author Comment

by:Micheal_Male
ID: 24800125
Not trying to be mean but Thats very strange. It works all the time for everything else other than the Textarea. I imported spring form tag library :-
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

web.xml :-
<taglib-uri>/spring</taglib-uri>
      <taglib-location>/WEB-INF/tld/spring-form.tld</taglib-location>
      </taglib>

And the validator is still not getting invoked.

<spring:bind path="user.notes">
        <TEXTAREA rows="3" cols="30" size="30"
        name='<c:out value="${status.expression}"/>'>
<c:out value="${status.value}"/>
</TEXTAREA>
</spring:bind>
 <form:errors path="user.notes" cssClass="errorBox" />
0
 

Author Closing Comment

by:Micheal_Male
ID: 31600906
I tried the way the expert asked and still got the same issues.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java string replace 11 63
jboss wildfly 10.1 10 437
Eclipse Help Java EE 5,6,7 Documentation, why not Java EE 8 8 46
web project error add remove 1 55
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question