2011/10/29 Agelos Pikoulas <agelos.pikou...@gmail.com>

> Thank you Jean-Pierre/James for your answer - what you propose is certainly
> one valid way of doing it, but it is still doesnot feel like a 'natural'
> way
> : It doesn't allow the dynamic 'navigation' of bean properties that are
> them
> selves Collections that each entry might have other Collections etc.
> For instance I might have a User which has a getFollowers() or
> getLikedObjects() etc and I want to display some of their stuff, following
> some display logic etc :-) Perhaps this wouldn't be the most elegant way
> MVC
> wise, but I am not a spring/jsp/mvc expert anyway.
>

I just remembered that there is an iterator() method on collections in some
newer servlet implementations (maybe a servlet 3 spec?). So this is
possible:

<c:forEach items="${device.measurements.iterator() }" var="measurement">
  <c:out value="${measurement.collector.name}" />
</c:forEach>

We are using tomcat 7 (inside Virgo 3) and it works.


Best regards,
James

Surelly this isn't SDN's fault, but JSP's. It would though be very helpful
> (and perhaps its a twoliner) if we could annotate @Query on more (immutable
> or not) Collection/iteration interfaces, say Iterator for a start....
>
> Regards
>
> On Thu, Oct 27, 2011 at 10:01 PM, Jean-Pierre Bergamin <
> jpberga...@gmail.com
> > wrote:
>
> > Hi Agelos
> >
> > Regarding your 2nd point:
> >
> > 2)      2) The minor issue I have regards (the otherwise brilliant)
> @Query,
> > > due to its constraint of annotating (mainly) Iterable and NOT allowing
> > Set,
> > > List etc (a runtime exception is thrown
> > > org.springframework.data.neo4j.conversion.QueryResultBuilder$1 cannot
> be
> > > cast to java.util.List).
> > >
> > > This wouldn’t be a huge problem, but the JSP/JSLT <forEach> tag DOESNOT
> > > iterate Iterable (!!!), nor you can directly call .iterator() from
> within
> > > JSP, making life hard on both ends.
> > >
> >
> > From the controller, just pass the iterator of the iterable to your JSP.
> > With Spring MVC, this would look like:
> >
> >    @RequestMapping(method = RequestMethod.GET)
> >    public String list(Model uiModel) {
> >        uiModel.addAttribute("kpis", kpiRepository.findAll().iterator());
> >        return "secure/kpis/list";
> >    }
> >
> > In your JSP, you then can use this iterator as expected:
> >
> > <c:forEach items="${kpis}" var="kpi">
> > <tr>
> > <td><c:out value="${kpi.uuid}" /></td>
> > <td><c:out value="${kpi.name}" /></td>
> > </tr>
> > </c:forEach>
> >
> >
> > Best regards,
> > James
> > _______________________________________________
> > Neo4j mailing list
> > User@lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
> >
> _______________________________________________
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to