8 Replies Latest reply on Nov 6, 2008 11:36 PM by Raghunath Nandy

    Iteration in JSF is not working

    Raghunath Nandy Newbie


      JSF Iteration in seam level of context values are not working.
      Even I tried with c:forEach, it's working but I'm not able to refer properties of iteration var(coursei) in side  loop.

      where collegeCources is a

      <rich:tabPanel switchType="ajax" >
                              <ui:repeat value="#{CollegeProfile.collegeCources}" var="coursei">
                                        <rich:tab >
                                              <f:facet name="label">
                                                      <h:outputText value="#{coursei.title}" />

          List<Course> collegeCources;
          public List<Course> getCollegeCources() {

      plz help me


        • 1. Re: Iteration in JSF is not working
          Mikael Andersson Master

          Have you tried #{collegeCources} instead of #{CollegeProfile.collegeCources} ?

          Don't use @DataModel much myself but think that it is being outjected.

          • 2. Re: Iteration in JSF is not working
            Raghunath Nandy Newbie

            Thanks for your quick reply,

            I tried it , but no use, I have seen couple of forms reporting on Seam iteration, but still need bug it more, With out iterator writing dynamic pages is horrible ..


            • 3. Re: Iteration in JSF is not working
              Mikael Andersson Master

              Another thing is that your factory method is the getter, you should probably rename that method to something like initCollegeCources, try something like this:

              List<Course> collegeCources;
              public List<Course> initCollegeCources() {

              And then access it as #{collegeCources}, it that doesn't work something else is the problem.

              Alternatively you could skipp the @DataModel stuff entierly and do what I usually do. This:

              List<Course> collegeCources;
              public void initCollegeCources() {
                  collegeCources = // create the college cources.
              public List<Course> getCollegeCources(){}

              And then access it like this in the page #{CollegeProfile.collegeCources}, gievn that CollegeProfile is the name of the backing bean/component.


              • 4. Re: Iteration in JSF is not working
                Mikael Andersson Master

                Hmm, is iteration not working at all or is it just with the tabbed panel? Haven't tried creating tabs dynamically myself.

                If it is the tabbed panel component, you might have better luck asking in the richfaces forum.

                • 5. Re: Iteration in JSF is not working
                  Raghunath Nandy Newbie
                  Ya, there is no prob with tabpanel, The iteration itself is not happening, I'm able to print the list on the page.
                  But Iteration is not really happening with ui:repeat , c:forEach is working fine but , the index var is not available in seam context, only i can print the value(toString) but no inner properties are not available ..

                  look at this   

                  `<c:forEach items="#{CollegeProfile.collegeCources}" var="coursei">
                                                          <h:outputText value="#{coursei.title}"/>


                  above code is not working .. throwing following exception :

                  `javax.el.PropertyNotFoundException: /collegeProfile.xhtml @70,48 value="#{coursei.title}": Property 'title' not found on type java.lang.String

                  Following code is working upto displaying the value. coursei.toString() printing..
                  `       <c:forEach items="#{CollegeProfile.collegeCources}" var="coursei">
                                                          <h:outputText value="#{coursei}"/>

                  im confused how to use it...

                  plz help me ,
                  • 6. Re: Iteration in JSF is not working
                    Raghunath Nandy Newbie

                    hi all,
                    i guess this is a bug, any one plz confirm me.
                    While using iterators c:forLoop,ui:repeat,on list type variables in seam context, the indexing variable's properties are not available inside the loop.


                    <ui:repeat value="#{CollegeProfile.collegeCourses}" var="coursei">
                    <s:label title="${coursei.title}"></s:label>


                    • 7. Re: Iteration in JSF is not working
                      Raghunath Nandy Newbie

                      Here is the result of my long investigation ,
                      I'm using jboss-4.2.3.GA pack, which is using JSP Engine: 2.1

                      According to JBoss EL docs , it's incompatible with JSP 2.1.

                      Incompatibility with JSP 2.1 — JBoss EL can't currently be used with JSP 2.1 as the compiler rejects expressions with parameters in. So, if you want to use this extension with JSF 1.2, you will need to use Facelets. The extension works correctly with JSP 2.0. 

                      Seam Docs

                      So this might be the reason for this , I'm still not resolved it, but seriously working on it.


                      Following is the code to find version of JSP Engin in any server.  

                                      Servlet Engine:
                                      <%= session.getServletContext().getMajorVersion() %>.<%= session.getServletContext().getMinorVersion() %>
                                      JSP Engine:
                                      <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion()%>
                                      Application Server:
                                      <%= application.getServerInfo()%>

                      • 8. Re: Iteration in JSF is not working
                        Raghunath Nandy Newbie

                        HI ALL,

                        This is working.. thanks for your help.

                        thanks Mikael, I'm following your suggestion,it's working pretty.

                        I did a mistake in query itself, but took long time to rectify it. Now I'm able to generate Dynamic tabs using forEach.

                        As I'm novice in seam , it's taking long time to debug the issues.
                        But It is really challenging to understand complex code. But any how nice experience. This issue took 1 full day,some times I was about to give-up but took it as challenging, now I completed.


                        last works for now...
                        Seam is excellent but really takes much time for self learners like me.It's is not simple as other frameworks like Struts,Hibernate...If I do any mistake-some times it will work fine but gives performance issues.experience will give lot of knowledge.