Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Value getting reset for Textarea after validation

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Spring Framework HTTPSession management 1 45
spring jars download 1 35
Running JavaFX on JDeveloper 12C 1 54
Java 8 to Java 6 8 20
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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.

856 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