You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Donald Ball <db...@rhoworld.com> on 2002/08/29 20:16:51 UTC

dynamic forms and map-backed ActionForm beans

Hi guys. I'm back to playing with the map-backed ActionForm beans again.
I've got a dynamically created HTML form that I'm trying to make play
nicely with a map-backed ActionForm. The ActionForm uses get/setProperty as
described by Ted Husted and works nicely. The problem I'm having is
accessing properties on the JSP page where the property is not known until
request-time. Here's the stupid example I'm working with:

<%@taglib uri='WEB-INF/struts-html.tld' prefix="html"%>
<html>
  <head>
    <title>Foo Test</title>
  </head>
  <body>
    <h3>Foo Test</h3>
    <html:errors />
    <html:form method="post" action="Foo">
      bar: <html:text property="property(bar)"/>
      <% String name1 = "bat"; %>
      bat: <html:text property="<%=name1%>"/>
      <% String name2 = "fubar"; %>
      fubar: <html:text property="property(<%=name2%>)"/>
      <html:submit />
    </html:form>
  </body>
</html>

assuming my bean defines set/getProperty and set/getBat, this example will
compile and run, but the third HTML input's name is '<%=name2%>' and that's
also the name of the property it sets on the map-backed bean. Obviously, I
want the input's name and bean property to be 'fubar' instead. I'm not much
of a JSP expert so I bet I'm doing something stupid, but I've tried about a
half a dozen different things and nothing works right. Any suggestions?

Eventually, the name of the property is going to come from a List - I'm
going to be iterating over a List of name/value pairs and generating HTML
inputs for them. I was planning on using the logic:iterate tag to help with
that, dunno if that affects the suggested solutions or not.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>