Zack
Zack

Reputation: 21

In Ibatis, how does one write a nested Iterate tag to loop through a two-dimensional array?

I was troubleshooting the following code and was unable to find an answer, so I figured I would document my solution.

The problem was:

<iterate property="twoDimArray" prepend="and (" close=")" conjunction="or">
    <iterate property="twoDimArray[]" open="(" close=")" conjunction="and">  
        $twoDimArray[][].columnName$ = #twoDimArray[][].value#  
    </iterate>  
</iterate>  

Resulted in an error: There is no READABLE property named 'columnName' ...

Upvotes: 1

Views: 2291

Answers (1)

Zack
Zack

Reputation: 21

I found that I needed to reference the second array as a property of the first:
$twoDimArray[].[].columnName$ = #twoDimArray[].[].value#

Upvotes: 1

Related Questions