struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chen, Gin" <Gin.C...@NielsenMedia.com>
Subject RE: Accessing the ActionForm object from within JSP
Date Wed, 09 Jul 2003 18:35:41 GMT
I gave this on the Struts irc channel once:

<c:set var="currentFormName"
value="${requestScope['org.apache.struts.action.mapping.instance'].name}"/>
Then access the form using the name.
<c:out value="${request.attribute[currentFormName].blah}" />

Hope that works for you.
I think someone had a shorter solution for it (combine it into one c:out?)
but you can probably figure that one out based on this.
-Tim

-----Original Message-----
From: Larson, Kirk [mailto:Kirk.Larson@pearson.com]
Sent: Wednesday, July 09, 2003 2:04 PM
To: 'struts-user@jakarta.apache.org'
Subject: Accessing the ActionForm object from within JSP


I want to access a form within my JSP page using JSTL.  I have it working by
simply specifying the name of the form (cycleDateForm) in the JSTL EL.
However, this does not seem like the correct method of solving this problem.
The form name is derived from the Struts configuration file using the
appropriate action mapping.  Since the JSP page only specifies the action
name and does not directly specify the form name, it does not seem that it
should reference the form directly. However, I am not sure how to determine
the name of the form object?  Any suggestions?

Sample JSP page :
==============
<html:form action="/cycledates/edit" >
	<c:forEach items="${cycleDateForm.cycleDates}" var="cycleDate">
		<c:out value="${cycleDate.key}"/><br>
	</c:forEach>
</html:form>

Relevant portion of struts-config.xml :
==========================
<form-beans>
	<form-bean name="cycleDateForm"
type="com.pearson.tools.setup.CycleDatesForm" />
</form-beans>
<action-mappings>
	<action 
		path="/cycledates/edit" 
		parameter="" 
		type="com.pearson.tools.setup.CycleDatesDispatchAction" 
		name="cycleDateForm" 
		scope="request">
			<forward name="success" path="cycledates.edit.frame"
redirect="false" />
	</action>
</action-mappings>


****************************************************************************

This email may contain confidential material. 
If you were not an intended recipient, 
Please notify the sender and delete all copies. 
We may monitor email to and from our network. 
****************************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message