You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Moore <jo...@jmsd.co.uk> on 2005/05/16 14:09:26 UTC
Getting name of form bean?
In a JSP which uses html:form, is there any way of determining the name
of the form bean (assuming it's been set in the mapping, of course, not
in the html:form tag!).
TIA
--
==============================================
John Moore - Norwich, UK - john@jmsd.co.uk
==============================================
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Getting name of form bean?
Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Not sure if anyone else gave this answer yet, but I needed to do the
same thing in StrutsWS's default response template, and here's how I
wound up doing it (modified slightly to be a little better!):
String formName =
((org.apache.struts.config.ActionConfig)request.getAttribute(
org.apache.struts.Globals.MAPPING_KEY)).getName();
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
Ed Griebel wrote:
> Here's what we use. It's not great that things are hard-coded such as
> the mapping name in line 1 (and the scope in line 3), but it works as
> long as the <bean:struts> tag and scope is kept in sync with the
> struts-config.xml.
>
> <bean:struts id="mapping" mapping="/actionPathFromStrutsConfig"/>
> <c:set var="formName" value="${mapping.attribute}"/>
> <c:set var="form" value="${sessionScope[formName]}"/>
>
> -ed
>
>
> On 5/16/05, John Moore <jo...@jmsd.co.uk> wrote:
>
>>In a JSP which uses html:form, is there any way of determining the name
>>of the form bean (assuming it's been set in the mapping, of course, not
>>in the html:form tag!).
>>
>>TIA
>>
>>--
>>==============================================
>>John Moore - Norwich, UK - john@jmsd.co.uk
>>==============================================
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Getting name of form bean?
Posted by Ed Griebel <ed...@gmail.com>.
Here's what we use. It's not great that things are hard-coded such as
the mapping name in line 1 (and the scope in line 3), but it works as
long as the <bean:struts> tag and scope is kept in sync with the
struts-config.xml.
<bean:struts id="mapping" mapping="/actionPathFromStrutsConfig"/>
<c:set var="formName" value="${mapping.attribute}"/>
<c:set var="form" value="${sessionScope[formName]}"/>
-ed
On 5/16/05, John Moore <jo...@jmsd.co.uk> wrote:
> In a JSP which uses html:form, is there any way of determining the name
> of the form bean (assuming it's been set in the mapping, of course, not
> in the html:form tag!).
>
> TIA
>
> --
> ==============================================
> John Moore - Norwich, UK - john@jmsd.co.uk
> ==============================================
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Getting name of form bean?
Posted by "Eric C. Hein" <er...@sbcglobal.net>.
It should be the "name" declared in the "form-bean" tag of the
struts-config.xml file. You can always do view>source on the html markup of
the jsp and see the names of the form and fields.
- Eric
----- Original Message -----
From: "John Moore" <jo...@jmsd.co.uk>
To: "Struts Mailing List" <us...@struts.apache.org>
Sent: Monday, May 16, 2005 5:09 AM
Subject: Getting name of form bean?
> In a JSP which uses html:form, is there any way of determining the name of
> the form bean (assuming it's been set in the mapping, of course, not in
> the html:form tag!).
>
> TIA
>
>
> --
> ==============================================
> John Moore - Norwich, UK - john@jmsd.co.uk
> ==============================================
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Getting name of form bean?
Posted by Dakota Jack <da...@gmail.com>.
If you want to get the value in the model, just ask the ActionMapping.
I assume you do not want merely to present or to show the name.
RIght?
On 5/16/05, John Moore <jo...@jmsd.co.uk> wrote:
> In a JSP which uses html:form, is there any way of determining the name
> of the form bean (assuming it's been set in the mapping, of course, not
> in the html:form tag!).
>
> TIA
>
> --
> ==============================================
> John Moore - Norwich, UK - john@jmsd.co.uk
> ==============================================
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Getting name of form bean?
Posted by James Mitchell <jm...@apache.org>.
That's easy with the html:struts taglib:
<bean:struts id="myActionMapping" mapping="/Some/Mapping/Path"/>
<bean:write name="myActionMapping" property="name"/>
--
James Mitchell
Software Engineer / Open Source Evangelist
Consulting / Mentoring / Freelance
EdgeTech, Inc.
http://www.edgetechservices.net/
678.910.8017
AIM: jmitchtx
Yahoo: jmitchtx
MSN: jmitchell@apache.org
----- Original Message -----
From: "John Moore" <jo...@jmsd.co.uk>
To: "Struts Mailing List" <us...@struts.apache.org>
Sent: Monday, May 16, 2005 8:09 AM
Subject: Getting name of form bean?
> In a JSP which uses html:form, is there any way of determining the name
> of the form bean (assuming it's been set in the mapping, of course, not
> in the html:form tag!).
>
> TIA
>
>
> --
> ==============================================
> John Moore - Norwich, UK - john@jmsd.co.uk
> ==============================================
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Getting name of form bean?
Posted by Martin Gainty <mg...@hotmail.com>.
John-
Maven's FormBean uses getName to determine the name of the underlying
property
http://maven.apache.org/reference/plugins/struts/apidocs/index.html
Is there something specific you were desiring?
HTH,
Martin-
----- Original Message -----
From: "John Moore" <jo...@jmsd.co.uk>
To: "Struts Mailing List" <us...@struts.apache.org>
Sent: Monday, May 16, 2005 8:09 AM
Subject: Getting name of form bean?
> In a JSP which uses html:form, is there any way of determining the name of
> the form bean (assuming it's been set in the mapping, of course, not in
> the html:form tag!).
>
> TIA
>
>
> --
> ==============================================
> John Moore - Norwich, UK - john@jmsd.co.uk
> ==============================================
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org