<jsp:useBean id="subscription" scope="session" class="com.borneo.beans.SubscriptionForm" />
This creates a new SubscriptionForm object because no object exists in session scope(or any scope) referenced by the name "subcription". Struts uses a different id. I think it depends on the version of Struts you're using as to what this id is... something like org.apache.struts.action[s].ActionForm[s] - I'm not real sure. Anyways, based on your code below, it should be using the same formBean. But, you'll have to try a little different approach if you want to prove it.
-Ben
From: "rob rowntree" <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Subject: duplicate form object Date: Thu, 5 Feb 2004 04:40:20 -0800
im new, i have 2 "subscriptionForm" objects instead of a single OID.
The trace below involves these activities:
1. subscription.jsp is submitted and handled by subscriptionForm whose configuration includes: name="subscriptionForm" scope="session"
2. a forward occurs on name "success" and the config codes for the action <action path="/saveSubscription" to forward to path="/Welcome.do"/>
3. the forward action for path="/Welcome" has attribute name="subscriptionForm" and attribute parameter="/Welcome.jsp"
---- The Problem -----
There should only be 1 subscription object but there are 2 different ones :
- one at step 1 - another one at step 3
Why the duplication?
In step 3, in Welcome.jsp, when i say:
<p>HavObj: <%=subscription.toString()%>
why don't i reference the same Form object created in the subscription.jsp at step 1?
--------- Gorey Details 1. webapps\struts-blank\subscription.jsp
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
...
<jsp:useBean id="subscription" scope="session" class="com.borneo.beans.SubscriptionForm" />
2. struts-config.xml
<action path="/saveSubscription"
type="com.borneo.beans.SaveSubscriptionAction" name="subscriptionForm" scope="session" validate="true" input="subscription"> <forward name="success" path="/Welcome.do"/> <forward name="subscription" path="/subscription.jsp"/> <!-- <forward name="success" path="/Welcome"/> --> </action>
<action
path="/Welcome" name="subscriptionForm" type="org.apache.struts.actions.ForwardAction" parameter="/Welcome.jsp" />
3. Welcome.jsp
<%@ taglib uri="/tags/struts-bean" prefix="bean" %> <%@ taglib uri="/tags/struts-html" prefix="html" %> <%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<html:html locale="true"> <head> <title><bean:message key="welcome.title"/></title> <html:base/> </head> <body bgcolor="white"> <!--<jsp:useBean id="subscription" scope="session" class="com.borneo.beans.SubscriptionForm" />--> <logic:notPresent name="org.apache.struts.action.MESSAGE" scope="application"> <font color="red"> ERROR: Application resources not loaded -- check servlet container logs for error messages. </font> </logic:notPresent>
<h3><bean:message key="welcome.heading"/></h3> <p><bean:message key="welcome.message"/></p> <a href='<jsp:getProperty name="subscription" property="jnlpaddr"/>
'>Launch JWS App.</a> <p>HavObj: <%=subscription.toString()%> </p> </body>
---------- StdOut from prints that prove 2 different objects on the server
OID : [EMAIL PROTECTED]
URL to Bean prop jnlpaddr : file:/G:/jakarta-tomcat-5.0.16/work/Catalina/localhost/struts-blank/A022B619 DD01CCEpoll.jnlp
on IE
Launch JWS App. HavObj: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
Get a FREE online virus check for your PC here, from McAfee. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]