Solved

Value getting reset for Textarea after validation

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
what is a "java.lang.System Property"   ? 20 65
Java DateChooser? 3 36
web application structure 18 76
What's wrong with this code? 4 22
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

806 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