Details

    • Type: Temp Temp
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Not a Problem
    • Affects Version/s: 2.0.6
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Apache Tomcat 5.5, Java 1.6, Windows XP

      Description

      First, you can look through next jsp codes:

      <s:iterator status="stat" value="destObjects">
      <tr>
      <s:iterator value="visibleColumns">
      <td>
      <s:property value="destObjects[%

      {#stat.index}].%{fieldDefName}" />
      </td>
      </s:iterator>
      </tr>
      </s:iterator>

      Variable "destObejcts" is a <LIST> type which contains a serial of objects named "destObject".

      Variable "visibleColumns" is also a LIST of objects named "visibleColumn", and "fieldDefName" is a property of "visibleColumn".

      And thus value of expression "visibleColumn.fieldDefName" will be a property name of object "destObject".

      Above relationship between two objects sounds a bit boring. As a trouble, I failed to get the correct values of these dynamic fields of "destObejct", and I had tried in many ways, and next Struts2 expressions ALL could not work:

      <s:property value="destObjects[%{#stat.index}

      ].%

      {fieldDefName}" />
      <s:property value="%{destObjectsstat.index.%{fieldDefName}}" />
      <s:property value="%{fieldDefName}

      " />
      OR
      <s:iterator value="destObjects" id="do">
      <s:iterator value="visibleColumns" id="vc">
      <s:property value="#do.%

      {vc.fieldDefName}

      "/>
      </s:iterator>
      </s:iterator>

      However, if I specify a real fieldname out of the second iterator tag, it does work:
      <s:property value="destObjects[%

      {#stat.index}

      ].field1" />

        Activity

        Hide
        Davey Xu added a comment -

        <s:iterator id="do" value="destObjects">
        <tr>
        <s:iterator value="visibleColumns">
        <td>
        <s:property value="%

        {#do[fieldDefName]}

        "/>
        </td>
        </s:iterator>
        </tr>
        </s:iterator>

        This will does!

        Close it.

        Show
        Davey Xu added a comment - <s:iterator id="do" value="destObjects"> <tr> <s:iterator value="visibleColumns"> <td> <s:property value="% {#do[fieldDefName]} "/> </td> </s:iterator> </tr> </s:iterator> This will does! Close it.
        Hide
        Rainer Hermanns added a comment -

        Closed as requested

        Show
        Rainer Hermanns added a comment - Closed as requested

          People

          • Assignee:
            Davey Xu
            Reporter:
            Davey Xu
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development