I think in your case the code would look something like this:

                               <% var items = currentNode.lineItems; %>
                               <% var nodeIterator = items.nodes; %>
                               <% while (nodeIterator.hasNext()) %>
                               <% { %>
                               <%    var itemNode = nodeIterator.nextNode();
%>
                               <%= itemNode.itemDescr %>
                               <% } %>
                               <b> End of loop</b><br/>


On Thu, Aug 5, 2010 at 9:28 PM, Tony Giaccone <[email protected]> wrote:

> Justin,
>
> Not that I'm trying to be intentionally dense, but... when i google JCR API
> NodeIterator I get a bunch of references to java.jcr classes, which clearly
> aren't going to work in the esp transform.
>
> Is there a javascript/esp version of the jcr API?
>
> Or are you telling me I need to use  java/jsp pages?
>
>
> Tony
>
>
>
>
> On Aug 5, 2010, at 10:03 PM, Justin Edelson wrote:
>
> > Not being purposely vague here (am away from a computer and don't have
> the syntax memorized), but... You need to use the JCR API. Something like
> getting a NodeIterator and using the typical hasNext() and nextNode()
> methods.
> >
> > On Aug 5, 2010, at 7:47 PM, Tony Giaccone <[email protected]> wrote:
> >
> >>
> >>
> >>
> >> So I'm trying to get the data in the lineItems.
> >>
> >> Here's the XML fragment
> >>
> >> <lineItems jcr:primaryType="sling:OrderedFolder"
> jcr:created="2010-08-02T19:54:57.329-04:00" jcr:createdBy="admin">
> >>   <_x0031_ jcr:primaryType="nt:unstructured" lineItemSeq="1" itemId="55"
>  itemDescr="Item selected to purchase"
> sling:resourceType="mll/item"></lineItems>
> >>
> >>
> >> I tried this:
> >>
> >>
> >>               <% var items = currentNode.lineItems; %>
> >>               <% for (var i = 0;i<items.length;i++) %>
> >>               <% { %>
> >>               <%= currentNode.lineItems[i].itemDescr %>
> >>               <% } %>
> >>               <b> End of loop</b><br/>
> >>
> >> And get this message:
> >>
> >> TypeError: Cannot read property "shortDescr" from undefined
> >>
> >>
> >>
> >>
> >>
> >> So I change it to this:
> >>
> >>               <% var items = currentNode.lineItems; %>
> >>               <% for (var i = 0;i<items.length;i++) %>
> >>               <% { %>
> >>               <%= currentNode.lineItems[i] %>
> >>               <% } %>
> >>               <b> End of loop</b><br/>
> >>
> >> This is what I get..
> >> undefined End of loop
> >>
> >> Change the code to this:
> >>
> >>               <% var items = currentNode.lineItems; %>
> >>               <% for (var i = 0;i<items.length;i++) %>
> >>               <% { %>
> >>               <%= currentNode.lineItems %>
> >>               <% } %>
> >>               <b> End of loop</b><br/>
> >>
> >> And I get this:
> >>
> >> content/Documents/2008/1155383/Order/2_1280793297315/lineItems
> >> End of loop
> >>
> >> I'm guessing I need to do something to load that node(?) into the page?
> >>
> >>
> >> Tony
>
>

Reply via email to