You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kevin Wang <KW...@Partnerware.com> on 2001/01/25 18:00:25 UTC

Nested and indexed attributes with the latest builds?

Just wondering whether anyone has successfully used nested/indexed
attributes in Struts. Sample codes?

Thanks.

Re: Nested and indexed attributes with the latest builds?

Posted by Michael Mok <mo...@hotmail.com>.
Hi

I looked at the example script in struts-test.war and here is the code snip
below. I use the same technique in my application
(www.webappcabaret.com/teatimej) which work fine.

However there are potential for making syntax mistake when defining which
index value the bean needs to display.

ie
<bean:write name="test4" property='<%= "stringArray[" + index + "]" %>'/>

Is it possible to extent the bean:write tag to handle index like the iterate
tag's offset ?
eg

<bean:write name="test4" property="stringArray" index="<%=index%>" />

Regards

Michael Mok
www.webappcabaret.com/teatimej

The code from the struts-test.war is below.


<h3>Test 4 - String Array And Indexed Lookups</h3>

<jsp:useBean id="test4" scope="page"
class="org.apache.struts.test.TestBean"/>

<table border="1">
<tr>
  <th>Correct Value</th>
  <th>Array Result</th>
  <th>Indexed Result</th>
</tr>
<% for (int index = 0; index < 5; index++) { %>
  <tr>
    <td><%= "String " + index %></td>
    <td><bean:write name="test4" property='<%= "stringArray[" + index + "]"
%>'/></td>
    <td><bean:write name="test4" property='<%= "stringIndexed[" + index +
"]" %>'/></td>
  </tr>
<% } %>
</table>

Re: Nested and indexed attributes with the latest builds?

Posted by Ted Husted <ne...@husted.com>.
I also have one that I will be able to share later today, as soon as
finish updating some of the code.

*********** REPLY SEPARATOR  ***********

On 1/25/2001 at 11:29 AM Craig R. McClanahan wrote:

Kevin Wang wrote:

> Just wondering whether anyone has successfully used nested/indexed
> attributes in Struts. Sample codes?
>

It's not very pretty or elegant, but the pages in the "struts-test.war"
application include some code that uses these sorts of attributes.

>
> Thanks.

Craig



-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 425-0252; Fax 716 223-2506.
-- http://www.husted.com/about/struts/



Re: Nested and indexed attributes with the latest builds?

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Kevin Wang wrote:

> Just wondering whether anyone has successfully used nested/indexed
> attributes in Struts. Sample codes?
>

It's not very pretty or elegant, but the pages in the "struts-test.war"
application include some code that uses these sorts of attributes.

>
> Thanks.

Craig