Solved

Value getting reset for Textarea after validation

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

705 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

13 Experts available now in Live!

Get 1:1 Help Now