>>>>> "Carl" == Carl Schwarcz <[EMAIL PROTECTED]> writes:

    Carl> I'm trying to conver some existing jsp's to Struts but confused about
    Carl> the interaction between JTSL looping constructs and Struts tags. I''ve
    Carl> got a session attribute containing a list of subjects which get output
    Carl> as the options in a select.  The Struts version complains that that the
    Carl> attribute subj has no value, while everything works fine in the
    Carl> original.  Anybody have any advice?

    Carl> Here's my original jsp-based form:

    Carl> <form method="post" action="/grumpy/Controller"  >
    Carl>   <select name="topic">
    Carl>     <c:forEach items="${subjects}" var="subj">
    Carl>         <p><option value= "<c:out value="${subj}"/>"> <c:out
    Carl> value="${subj}"/> </option></p>
    Carl>   </select>
    Carl> <input type="submit" value="Choice" name="action" />
    Carl> </form>

    Carl> Here's my attempt at a struts version"

    Carl> <html:form action="/choice" name="choiceForm"
    Carl> type="carl.struts.ChoiceForm" > 
    Carl>   <html:select property="topic">
    Carl>     <c:forEach items="${subjects}" var="subj">
    Carl>       <p><html:option value= "<c:out value="${subj}"/>"> <c:out
    Carl> value="${subj}"/></html:option></p>
    Carl>     </c:forEach>
    Carl>   </html:select>
    Carl>   <html:submit>Choose Subject</html:submit>
    Carl> </html:form>

You can't nest custom tags in the attribute values of custom tags.

If you instead used the Struts-EL library (check "contrib/struts-el" in Struts
distribution), your excerpt would look like this:

 <html-el:form action="/choice" name="choiceForm"
               type="carl.struts.ChoiceForm" > 
   <html-el:select property="topic">
     <c:forEach items="${subjects}" var="subj">
       <html-el:option value="${subj}"/>
     </c:forEach>
   </html-el:select>
   <html-el:submit>Choose Subject</html-el:submit>
 </html-el:form>

This might be better if you could use the "options" or "optionsCollection"
tags, instead of iterating through a collection and explicitly creating
"option" tags.  However, this may have a wrinkle, as I believe those two assume
the collection is a collection of beans, not strings, as I think you have here.

-- 
===================================================================
David M. Karr          ; Java/J2EE/XML/Unix/C++
[EMAIL PROTECTED]   ; SCJP



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to