Solved

Value getting reset for Textarea after validation

Posted on 2009-07-07
5
542 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Starting to learn JAVA, 7 59
@SBGen Method 3 38
Oracle SQL syntax check  without executing 6 37
Configure a Bean in an XML file 4 12
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now