<s:set name="thisCountry" value="regionList(0).name" scope="page"/>

or maybe

<s:set name="thisCountry" value="regionList[0].name" scope="page"/>

At any rate, you need to use the 'value' attribute to specify the value :-)

L.

[EMAIL PROTECTED] wrote:
I wondered what is the struts tag equivalent of this JSTL to retrieve
the first element from an arrayList:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
<c:set var="thisCountry" value="${regionList[0].countryCode}"
scope="page" />
<c:set var="lastCountry" value="${regionList[0].countryCode}"
scope="page" />

Where regionList is of type ArrayList<RegionBean>
Looking at the online guides I guessed at
<%@ taglib prefix="s" uri="/struts-tags"%>
<s:set id="thisCountry" name="regionList(0).name" scope="page"/>
or
<s:set id="lastCountry" name="regionList(%{0}).name" scope="page" />

But these don't seem to work.
I'm happy that regionList is in scope and not null because an iterator
like this works OK
    <s:iterator value="regionList">
      <tr>
        <td>
          <s:property value="countryCode"/>
        </td>
        <td>
            <s:property value="regionName"/>
        </td>
      </tr>
    </s:iterator>

(the JSTL code I'm converting inserts a spacer row in the table when
the countryCode changes, hence the need to initialise before starting
the iterator)

Apologies if I missed something obvious ;-)




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

Reply via email to