Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Thanks for a great forum. My problem was answered just by scrolling through previously solved problems. Great service!!..."

Geography

Where in the world do Tek-Tips members come from?

Help! How retain form values if it contain errors after submit buttonHelpful Member! 

jollyplay (Programmer)
18 Dec 03 8:46
Hello,

 I am new to Struts. I need to retain form values after
submitting the button, if the form contain errors. Any
need to change in struts-config.xml? or programatically i do it with session. Tell me the easy way. Please help me.
Thanks in advance.


With regards,
balachandar.
Helpful Member!  venur (MIS)
18 Dec 03 9:35
Hi,

You can do it either way. In struts-config.xml for that action mapping you can set the scope as session insted of request. So that the action mapping is stored in the session. If not you can store the form into a session in the action class and can get the form with values when ever required from the session.

Cheers,
Venu
byam (Programmer)
18 Dec 03 10:38
If you are using struts Form and struts HTML tag lib, it should automatically retains all the value for you if error validation in the Form failed.

for detail: http://jakarta.apache.org/struts/userGuide/building_vie...
jollyplay (Programmer)
19 Dec 03 1:09
Hello,

  Thank u for ur reply.

  I tried in this way, as u told and own myself.


In struts-config.xml

<form-bean name="AssignBookBean"
type="com.ui.AssignBookBean"/>

<action input="/view/AssignBook.jsp" name="AssignBookBean"
path="/view/AssignBookAtion" scope="session" type="com.ui.AssignBookAction">
<forward name="success" path="/view/BookList.jsp"/>
<forward name="BookList" path="/view/BookList.jsp"/>
</action>

In JSP
------
<html:html>
.
.

<html:form action="/view/AssignBookAction" name="assignbook" type="com.ui.AssignBookBean">
<html:text property="bookname" size="27"/>
</html:form>
'.
.
</html:html>


but, still it is not working. Can u give example source link or code regarding this?.
Thanks in advance,


With regards,
balachandar.
byam (Programmer)
19 Dec 03 3:21
The configuration looks ok.  May be something wrong in your form bean.  Can you show me the code of your com.ui.AssignBookBean?
venur (MIS)
19 Dec 03 9:13
Hi,

In struts-config.xml form-bean name="" should be equal to the name in the html:form name in jsp.

In AssignBook.jsp change the html:form tag name.

<html:form action="/view/AssignBookAction" name="AssignBookBean" type="com.ui.AssignBookBean">


Cheers,
Venu
jollyplay (Programmer)
20 Dec 03 3:52
Hello,
 
 Thank u.
 
 I did, as u told and i also including <html:form scope=request--- > and in struts-config.xml in action mapping, i changed the scope=request.

 Now it is working fine.

 if we give scope=session then what is the problem
i am facting is, all the time it retain  the values in the
form (unnecessary) whether it contain error or not. First time only it does not have values.

<html:form action="/view/AssignBookAction" scope="request" name="AssignBookBean" type="com.ui.AssignBookBean">

<form-bean name="AssignBookBean"
type="com.ui.AssignBookBean"/>

<action input="/view/AssignBook.jsp" name="AssignBookBean"
path="/view/AssignBookAtion" scope="request" type="com.ui.AssignBookAction">
<forward name="success" path="/view/BookList.jsp"/>
<forward name="BookList" path="/view/BookList.jsp"/>
</action>


  Hello all, thank u for ur support.



With regards,
balachandar.
 



Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close