2 Replies Latest reply on Jan 5, 2008 9:15 AM by pmuir

    List within a list

    odedia

      Hi,

      I'm trying to create a simple JSF page where there's a list of questions, and in each question, there's a list of possible answers. I manage to get the questions list, but the "inner" list of possible answers is not presented at all.


      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:s="http://jboss.com/products/seam/taglib">
      <body>
      
      <h2>Quiz</h2>
      
      <h:form>
      Please select your answers<br />
      
       <s:selectItems value="#{questions}" var="selectedQuestion">
       <h:outputText value="#{selectedQuestion.questionText}"></h:outputText>
       <p/>
       <ui:repeat value="#{selectedQuestion.possibleAnswers}" var="possibleAnswer">
       <h:outputText value="#{possibleAnswer.answerText}"></h:outputText>
       </ui:repeat>
       </s:selectItems>
       <h:commandButton type="submit" value="Submit"
       action="#{manager.checkAllAnswers}" />
      </h:form>
      </body>
      </html>
      


      What am I missing here? The object does have the list of possible answers inside, but it is not displayed.

      Thanks.

        • 1. Re: List within a list
          odedia

          Just to be clear: I tried it with the inner tag being "s:selectItems" as well instead of "ui:repeat", still the same result.

          • 2. Re: List within a list
            pmuir

            s:selectItems populates a drop down box, you use it inside a h:selectXXX.

            Try using a datatable or ui:repeat for the outer loop, and putting your answers into a dropdown.