jsf - accessing native query list using ui:repeat -
lets have table test columns id , name
on bean got query
public list gettestlist(){ query q = em.createnativequery("select * test"); list list = q.getresultlist(); return list; } and on jsf page have:
<ul> <ui:repeat id="resulta" value="#{testcontroller.testlist}" var="item"> <li>#{item.id}</li> </ui:repeat> </ul> why severe: javax.el.elexception: /test.xhtml: input string: "id"
why severe: javax.el.elexception: /test.xhtml: input string: "id"
because native query returns list<object[]>, not list<test>. you're attempting access object[] array using string such "id" index instead of integer such 0. if closer stack trace, should have noticed presence of arrayelresolver little further in stack after exception, should have hinted #{item} been interpreted array.
so, if absolutely can't obtain fullworthy list<test> (you can inner joins using @manytoone , on), should obtain first column select query:
<li>#{item[0]}</li>
Comments
Post a Comment