[Opensource] "zebra striping" question

Michael Rimov rimovm at centercomp.com
Mon Aug 5 22:36:56 PDT 2002


At 06:43 PM 8/1/2002 -0600, you wrote:
>okay, I see how that would work.  however, I'm still a little stuck...
>
>so in the iterate name attribute you can put in the name of any block that
>is in the response.  So if you have many blocks in the response and are
>looking to iterate through one of them you can just use that one.  Is this
>correct?
>
>so I have a block "TopicList"  that contains another block called "Topic".
>
>inside Topic I have an output "ATopic" which has attributes "TopicName" and
>"TopicID"
>Topic also contains another block called "SubTopic" which contains an output
>called "ASubTopic" which has attributes "SubTopicName" and "SubTopicID".
>
>I tried to iterate through these blocks with the iterate tag, but I kept
>getting an exception...
>
>with this code:
><logic:iterate id="eachItem" property="TopicList" indexId="counter">
>                 <bean:write name="eachItem"  property="Topic"/>
></logic:iterate>
>
>it would say "No such property as 'Topic' in Block 'ATopic'"
>
>I appreciate the help...

Hi Brian,

It took me some time wrestling with nesting with the struts tags, so don't 
worry, keep trying different combinations and it eventually makes sense.

In your case, if I've got the picture right, by calling logic:iterate over 
TopicList, you will be pointing to each 'ATopic' (thus the error).  Then to 
get attributes you use '@' and to get nested objects you use '/'s as 
delimiterse.  So If I have your code right, your bean:write code to print 
the Topic name and id and then the subtopic name and id (if it exists) is:


<bean:write name="eachItem" property="@TopicName"/>
<bean:write name="eachItem" property="@TopicID"/>
<logic:Present name="eachItem" property="SubTopic">
         <bean:write name="eachItem" property = "SubTopic/@SubTopicName"/>
         <bean:write name="eachItem" property = "SubTopic/@SubTopicID"/>
</logic:Present>


No guarantees on accuracy ;)  (Esp since if I didn't have a spell checker, 
I would have just misspelled accuracy... now there's something to boost 
your confidence, eh? :) )

HTH!
                                                 -Mike




More information about the Opensource mailing list