On the same "Iterable" problem (deviating from the "main OO question" unwillingly), I 've made my own Iterable<Someclass> property which is backed by a List<Someclass> filled at runtime using the @Query backed Iterable (thus enabling my class filtering to solve the "main OO question") and the JSP works fine... When I substitute with the @Query filled Iterable directly I get:
javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in <forEach> Surely this is a JSP error, but how do we solve it ? On Sat, Oct 29, 2011 at 8:16 PM, Agelos Pikoulas <agelos.pikou...@gmail.com>wrote: > 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. > > 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