Return-Path: Delivered-To: apmail-jakarta-struts-user-archive@apache.org Received: (qmail 92108 invoked from network); 24 Sep 2002 13:33:24 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 24 Sep 2002 13:33:24 -0000 Received: (qmail 3961 invoked by uid 97); 24 Sep 2002 13:33:43 -0000 Delivered-To: qmlist-jakarta-archive-struts-user@jakarta.apache.org Received: (qmail 3945 invoked by uid 97); 24 Sep 2002 13:33:42 -0000 Mailing-List: contact struts-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list struts-user@jakarta.apache.org Received: (qmail 3922 invoked by uid 98); 24 Sep 2002 13:33:42 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) X-Originating-IP: [193.189.219.82] From: =?iso-8859-1?B?VmFs6XJ5IEphY290?= To: struts-user@jakarta.apache.org Bcc: Subject: Form reload problem Date: Tue, 24 Sep 2002 15:33:01 +0200 Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Message-ID: X-OriginalArrivalTime: 24 Sep 2002 13:33:01.0929 (UTC) FILETIME=[E791A590:01C263CE] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi... I've the following problem: I have a form tag in a jsp page, on submit, it validate the form and then call the execute method of the action. If there is no errors in the validate method of the form, no problem. But if there is some errors, it come back to the page but don't write in the "" tags the values that were posted. This works if, in the file struts-config.xml, I set the attribute scope of the form in the action to "session". But I absolutly need to set it to request. So, what is my problem ??? Tanks... struts-config.xml code: Code of the jsp page: <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
First name
Last name
Password
 
Code of the action form: package com.eim.application.teststruts.form; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; import javax.servlet.http.HttpServletRequest; /** * Title: * Description: * Copyright: Copyright (c) 2002 * Company: * * @author * @version 1.0 */ public class LoginForm extends ActionForm { private String firstName = null; private String lastName = null; private String password = null; /** * Sets the firstName attribute of the LoginForm object * * @param firstName The new firstName value */ public void setFirstName( String firstName ) { this.firstName = firstName; } /** * Sets the lastName attribute of the LoginForm object * * @param lastName The new lastName value */ public void setLastName( String lastName ) { this.lastName = lastName; } /** * Sets the password attribute of the LoginForm object * * @param password The new password value */ public void setPassword( String password ) { this.password = password; } /** * Gets the firstName attribute of the LoginForm object * * @return The firstName value */ public String getFirstName() { return this.firstName; } /** * Gets the lastName attribute of the LoginForm object * * @return The lastName value */ public String getLastName() { return this.lastName; } /** * Gets the password attribute of the LoginForm object * * @return The password value */ public String getPassword() { return this.password; } /** * Description of the Method * * @param mapping Description of the Parameter * @param request Description of the Parameter */ public void reset( ActionMapping mapping, HttpServletRequest request ) { this.password = null; this.firstName = null; this.lastName = null; } /** * Description of the Method * * @param mapping Description of the Parameter * @param request Description of the Parameter * @return Description of the Return Value */ public ActionErrors validate( ActionMapping mapping, HttpServletRequest request ) { ActionErrors errors = new ActionErrors(); if ( ( firstName == null ) || ( firstName.length() < 1 ) ) { errors.add( "firstName", new ActionError( "error.firstName.required" ) ); } if ( ( lastName == null ) || ( lastName.length() < 1 ) ) { errors.add( "lastName", new ActionError( "error.lastName.required" ) ); } if ( ( password == null ) || ( password.length() < 1 ) ) { errors.add( "password", new ActionError( "error.password.required" ) ); } return errors; } } code of my action: package com.eim.application.teststruts.action; import java.util.Locale; import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.action.Action; import org.apache.struts.action.Action; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.util.AppException; import org.apache.struts.util.MessageResources; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import com.eim.application.teststruts.model.User; /** * Title: * Description: * Copyright: Copyright (c) 2002 * Company: * * @author * @version 1.0 */ public class ActionLogin extends Action { /** * Gets the user attribute of the LoginAction object * * @param form Description of the Parameter * @return The user value * @exception Exception Description of the Exception */ public User getUser( ActionForm form ) throws Exception { String firstName = (String) PropertyUtils.getSimpleProperty( form, "firstName" ); String lastName = (String) PropertyUtils.getSimpleProperty( form, "lastName" ); String password = (String) PropertyUtils.getSimpleProperty( form, "password" ); return new User( firstName, lastName, password ); } /** * Description of the Method * * @param mapping Description of the Parameter * @param form Description of the Parameter * @param request Description of the Parameter * @param response Description of the Parameter * @return Description of the Return Value * @exception Exception Description of the Exception */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response ) throws Exception { User currentUser = this.getUser( form ); HttpSession session = request.getSession(); session.setAttribute( "currentUser", currentUser ); // Forward control to the specified success URI return ( mapping.findForward( "success" ) ); } } Thanks... See you Val�ry Jacot PS: Sorry for my english, I'm a frenchy... _________________________________________________________________ Affichez, modifiez et partagez gratuitement vos photos en ligne: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: For additional commands, e-mail: