You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Galbreath <ma...@qat.com> on 2003/05/24 21:39:39 UTC

DynaActionForm Coolness

I finally got this working and I may never use an explicit ActionForm again!
The problem (which no one caught, btw) was in my method signatures.  I had:

public ActionForward execute( ActionMapping mapping,
                              DynaActionForm form,
                              HttpServletRequest request,
                              HttpServletResponse response ) throws
ServletException,
 
IOException,
 
ModuleException {

when I should have had:

public ActionForward execute( ActionMapping mapping,
                              ActionForm form,
                              HttpServletRequest request,
                              HttpServletResponse response ) throws
ServletException,
 
IOException,
 
ModuleException {

Thanks for all the help!
Mark



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


Re: DynaActionForm Coolness

Posted by Kris Schneider <kr...@dotech.com>.
My guess would be that a special code path is taken by 
PropertyUtils.getProperty if the bean is a DynaBean so that it's looking 
for "map" as a dyna property and not a standard bean property.

Ted Husted wrote:
> OK, my turn =:)
> 
> Given an Action that just does this:
> 
>  DynaActionForm input = (DynaActionForm) form;
>  Map map = input.getMap();
>  request.setAttribute(Tokens.LIST,map);
>  return mapping.findForward(Tokens.SUCCESS);
> 
> How come this works:
> 
>  <html:link action="/MultipleParametersForm" name="<%=Tokens.LIST%>" >
> 
> and this works:
> 
>  <bean:write name="<%=Tokens.MULTIPLE_PARAMETERS_FORM%>" 
> property="latDeg" />
> 
> (I can create a list of parameters from the map, and access the 
> DynaProperties.)
> 
> But this doesn't?
> 
>  <html:link action="/MultipleParametersForm" 
> name="<%=Tokens.MULTIPLE_PARAMETERS_FORM%>" property="map" >
> 
> (I can't pass the same map stored in the request (by the Action) to 
> html:link directly.)
> 
> Under RC1 and this morning's build, Tomcat 4.06 reports:
> 
> "No getter method for property map of bean MultipleParametersForm"
> 
> Same thing with bean:write. The html/bean tags see the object, but not 
> getMap().
> 
> 
> -Ted.
> 
> 

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>



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


RE: DynaActionForm Coolness

Posted by Steve Raeburn <st...@ninsky.com>.
Aha! Found the culprit. From PropertyUtilsBean.getSimpleProperty()...

   // Handle DynaBean instances specially
   if (bean instanceof DynaBean) {
       DynaProperty descriptor =
               ((DynaBean) bean).getDynaClass().getDynaProperty(name);
       if (descriptor == null) {
           throw new NoSuchMethodException("Unknown property '" +
                   name + "'");
       }
       return (((DynaBean) bean).get(name));
   }

With the benefit of hindsight (20-20) if you'd tried
<bean:write name="<%=Tokens.MULTIPLE_PARAMETERS_FORM%>" property="map" />
that would also fail.

Not sure if JSTL would be a solution, but setting the map in the request via
the Action, as per your example, works.

Steve

p.s. Ted, if you get a chance, I could use a quick "yes, it looks like it
might be useful" or "no, its a big pile of ****" on the Struts Examples
that were mentioned earlier this week
(http://bobcat.webappcabaret.net/ninsky/index.jsp). Thanks!


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


RE: DynaActionForm Coolness

Posted by Steve Raeburn <st...@ninsky.com>.
Could be because the <html:link> tag is Map backed form aware and is using
get(String name) method of the DynaAction form, rather than getMap(). Of
course the get() method does not have a property named "map".

I'll take at look at the tag source and check if this is the case.

Steve

> -----Original Message-----
> From: Ted Husted [mailto:husted@apache.org]
> Sent: May 30, 2003 1:40 PM
> To: Struts Users Mailing List
> Subject: Re: DynaActionForm Coolness
>
>
> OK, my turn =:)
>
> Given an Action that just does this:
>
>   DynaActionForm input = (DynaActionForm) form;
>   Map map = input.getMap();
>   request.setAttribute(Tokens.LIST,map);
>   return mapping.findForward(Tokens.SUCCESS);
>
> How come this works:
>
>   <html:link action="/MultipleParametersForm" name="<%=Tokens.LIST%>" >
>
> and this works:
>
>   <bean:write name="<%=Tokens.MULTIPLE_PARAMETERS_FORM%>"
> property="latDeg" />
>
> (I can create a list of parameters from the map, and access the
> DynaProperties.)
>
> But this doesn't?
>
>   <html:link action="/MultipleParametersForm"
> name="<%=Tokens.MULTIPLE_PARAMETERS_FORM%>" property="map" >
>
> (I can't pass the same map stored in the request (by the Action) to
> html:link directly.)
>
> Under RC1 and this morning's build, Tomcat 4.06 reports:
>
> "No getter method for property map of bean MultipleParametersForm"
>
> Same thing with bean:write. The html/bean tags see the object, but not
> getMap().
>
>
> -Ted.
>
>
> --
> Ted Husted,
> Struts in Action <http://husted.com/struts/book.html>
>
>
>
> ---------------------------------------------------------------------
> 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


Re: DynaActionForm Coolness

Posted by Ted Husted <hu...@apache.org>.
OK, my turn =:)

Given an Action that just does this:

  DynaActionForm input = (DynaActionForm) form;
  Map map = input.getMap();
  request.setAttribute(Tokens.LIST,map);
  return mapping.findForward(Tokens.SUCCESS);

How come this works:

  <html:link action="/MultipleParametersForm" name="<%=Tokens.LIST%>" >

and this works:

  <bean:write name="<%=Tokens.MULTIPLE_PARAMETERS_FORM%>" 
property="latDeg" />

(I can create a list of parameters from the map, and access the 
DynaProperties.)

But this doesn't?

  <html:link action="/MultipleParametersForm" 
name="<%=Tokens.MULTIPLE_PARAMETERS_FORM%>" property="map" >

(I can't pass the same map stored in the request (by the Action) to 
html:link directly.)

Under RC1 and this morning's build, Tomcat 4.06 reports:

"No getter method for property map of bean MultipleParametersForm"

Same thing with bean:write. The html/bean tags see the object, but not 
getMap().


-Ted.


-- 
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>



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