I'm not having a problem using the proper attributes within the foreach, I'm having a problem passing an XML fragment to my Tile. I need to be able to pass

<family order="1">key1</family>
<family order="2">key2</family>
...

to the Tile - and that's not happening, as far as I can tell. Within the foreach I'm doing a few different things, pulling out nameKey, and various other attributes and such - and that's all fine, its actually getting the entire node that is the "current" node and passing that to the Tile that seems to be troublesome.

So, my XML for a particular category looks like this:

           <category order="8" nameKey="nav.crafts.webcat.trimmers">
               <family order="1">nav.crafts.prdctfm.prsnlppr</family>
               <family order="2">nav.crafts.prdctfm.rtry</family>
           </category>

So, with my x:forEach XPath statement, the "context" node is a category like this - and I can pull out @nameKey, @order, etc. - to my heart's content. I can also do an x:if on "family" to determine if any family nodes exist in the current context - this is all OK.

However, there's processing that the tile I include in my x:forEach needs to do that needs this XML fragment (specifically, it needs to loop through each family and do something specific, much in the same way that the parent is looping through each category and doing something specific). So, I need to pass XML like that above, from the "current" context to the Tile ... somehow.

Is this possible?

Kris Schneider wrote:

That's fine, isn't it? It should just be the string representation of the
context node (i.e. nodeclass.toString()). What if you do:

<x:forEach select="$xml//catalog">
 nameKey: <x:out select="@nameKey"/>
</x:forEach>

Quoting "Ruth, Brice" <[EMAIL PROTECTED]>:



Hrmpf, not working they way I expected.

When I add var="node" to my x:forEach, and then use <c:out value="${node}"/> to display the contents (as this is what would be passed to the Tile, via <tiles:put>) - I get the following:

[category: null]

The XPath statement I am using as my select for the forEach, has as its last node, "category" ... what I would hope to get is either something like this:

<category order="3" nameKey="nav.section.whatever">
   <family order="1">whatever</family>
   ...
</category>

-OR- just the list of "family" nodes.

Kris Schneider wrote:



I don't know much about Tiles, but <x:forEach> can explicitly export a


scoped


variable via its "var" attribute:

<x:forEach var="node" select="...">

It also implicitly sets the context node each time through an iteration. So,


I'm


assuming that another XPath expression within the tile would operate


realtive to


the context set by <x:forEach>. If you know Tiles and have some handy test


XML


data, it shouldn't be too hard to test out either (or both) of those


approaches...


Quoting "Ruth, Brice" <[EMAIL PROTECTED]>:





I have an x:forEach loop (JSTL) that contains within it a <tiles:insert> statement - and I'd like to pass the current node of XML to the tile for additional processing (conditionally). Is this possible? Within the tile, I'll need to do an x:forEach loop on the passed in fragment, so I believe I'll need to be able to use x:parse on the fragment that was passed in. I'm open to other ways of doing this, as well, but they need to only involve what can be done within a JSP/tile, really. I'm extending an existing set of code, and am not really open to rewriting it all :)

--
Brice D. Ruth
Sr. IT Analyst
Fiskars Brands, Inc.








--
Brice D. Ruth
Sr. IT Analyst
Fiskars Brands, Inc.






-- Brice D. Ruth Sr. IT Analyst Fiskars Brands, Inc.



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



Reply via email to