java - loops binary tree in jstl -


i create binary tree , display result in jsp conditions.

each node has 4 elements (id, question, answer, , leftnode rightnode)

if user clicks "yes", program goes left of tree , if answers "no" right of tree.

for example, initial question "you're man?" if answers "yes" go left , page view "you're singer?" if answers "no" page displays "you're french? ".

in java, original question.

cursor [i]. getquestion () 

then yes

cursor [i] getquestion. getleftnode () 

and no

cursor [i]. getrightnode (). getquestion 

until the, works normally, when want loop until there no longer issue by

<c:when test="${not empty cursor[i].getquestion() }"> 

the program stops @ first loop , stops cursor not empty

here complete code jstl

<c:choose>    <c:when test="${not empty cursor[i].getquestion() }">       <c:if test="${param.btn eq 'oui'}" var="oui">          <c:set var="cursor" value="${cursor[i].getleftnode() }" scope="session"></c:set>          <c:set var="i" value="${i+1 }" scope="session"></c:set>       </c:if>       <c:if test="${param.btn eq 'non'}" var="non">          <c:set var="cursor" value="${cursor[i].getrightnode() }" scope="session"></c:set>      <c:set var="i" value="${i+1 }" scope="session"></c:set>       </c:if>    </c:when> </c:choose>  <c:out value="${cursor.getquestion() }"></c:out> 

thank you

rather using methods ${cursor.getquestion() } have use property names this: ${cursor.question }

p.s. , make sure have proper getter names (get should lower case)


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -