struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmk...@earthlink.net (David M. Karr)
Subject Re: html:text tag "indexed" attribute
Date Sun, 02 Feb 2003 07:24:10 GMT
>>>>> "Charlie" == Charlie Toohey <ctoohey@pacbell.net> writes:

    Charlie> Thanks David. That worked for the value attribute:
    Charlie> <logic:iterate name="aForm" property="stringArray" id="aString" >
    Charlie>    <html:text indexed="true" property="aString" value='<%= aString.toString()

    Charlie>  %>' /> 
    Charlie> </logic:iterate>

    Charlie> BUT, this resolves to an HTML text tag of:
    Charlie> <input type="text" name="org.apache.struts.taglib.html.BEAN[0].aString"

    Charlie> value="somevalue">

    Charlie> This is my larger question --- what I'm trying to get is
    Charlie> <input type="text" name=aString[0] value="somevalue">

    Charlie> Using the Struts html:text tag with indexed="true", I am iterating over a

    Charlie> collection of String objects, NOT a collection of bean objects with 
    Charlie> properties. Therefore, instead of using the bean name for the "name" 
    Charlie> attribute and the bean property for the "property" attribute, like all of
the 
    Charlie> examples I have seen, I do not know what to put for the "name" and "property"

    Charlie> attributes, because this is a collection of Strings, not beans, and the 
    Charlie> String objects do NOT have a property.

    Charlie> Please help !     I've been trying to get this to work for 2 days now.

This is where it gets a little tricky to visualize, and I'm not sure I'm going
to get this right, but I'll give it a try.

First of all, you should change "aString" to something that doesn't have a
capital in the first two characters of the property name.  I believe that
triggers some funny behavior in the JavaBeans spec.  If you just change it to
"astring" or "someString", that would work fine.

Now, try adding a "name" parameter to your "html:text" tag.  I don't know what
to call it yet, but let's call it "stringObj".

Now, add an indexed getter (may not need the getter) and setter to your form
bean, for the "stringObj" property.  The value parameter will be a "String".

That may work.  Personally, I find "indexed" tags confusing, but I haven't
tried to use them very much.  It seems to me that it's more understandable to
build the array reference expression manually, and this is easier to do if you
use Struts-EL, as the EL expressions are more concise than scriptlet
expressions.

-- 
===================================================================
David M. Karr          ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net   ; SCJP; SCWCD




---------------------------------------------------------------------
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