I made a simple and clean example which manifests my problem. Let's say we
have two domain classes: Movie and Actor. We have collection (List) of
movies, and every movie has a collection (List) of actors.

Actor.java:
-----------------------
public class Actor {
 
    private String name;
    
    public Actor() { }
    public Actor(String name) { this.name = name; }
    
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
}
-----------------------

Movie.java:
-----------------------
import java.util.ArrayList;
import java.util.List;
 
public class Movie {
 
    private String title;
    private List actors = new ArrayList();
 
    public Movie(String title, List actors) {
        this.title = title;
        this.actors = actors;
    }
 
    public String getTitle() { return title; }
    public void setTitle(String title) { this.title = title; }
 
    public List getActors() { return actors; }
    public void setActors(List actors) { this.actors = actors; }
    
}
-----------------------


This is MovieManager class, which is JSF managed bean with request scope. It
has a method getMovies which is used to populate outer h:dataTable element.

MovieManager.java:
-----------------------
import java.util.ArrayList;
import java.util.List;
 
public class MovieManager {
 
    public MovieManager() { }
 
    public List getMovies() {
 
        List movieList = new ArrayList();
 
        List actorList = new ArrayList();
        actorList.add(new Actor("Joe I Smith"));
        actorList.add(new Actor("Joe II Smith"));
        actorList.add(new Actor("Joe III Smith"));
 
        Movie movie = new Movie("Movie1", actorList);
 
        movieList.add(movie);
 
        return movieList;
       
    }
}
-----------------------


Finally, next goes jsp page with two h:dataTable elements:
-----------------------
<%...@page contentType="text/html" pageEncoding="UTF-8"%>
 
<%...@taglib prefix="h" uri="http://java.sun.com/jsf/html"; %>
<%...@taglib prefix="f" uri="http://java.sun.com/jsf/core"; %>
 
<f:view>
    <h:dataTable value="#{movieManager.movies}" var="movie"  >
        <h:column>
            <h:outputText value="#{movie.title}" />
        </h:column>
        <h:column>
            <h:dataTable value="#{movie.actors}" value="actor" >
                <h:column>
                    <h:outputText value="#{actor.name}" />
                </h:column>
            </h:dataTable>
        </h:column>
    </h:dataTable>
</f:view>
-----------------------


What I'm trying to do here is make a table which lists movies, and which
lists all actors for current movie. But, result is showing only movies,
without actors, and without any exception. How to? 
-- 
View this message in context: 
http://www.nabble.com/h%3AdataTable-inside-h%3AdataTable-doesn%27t-work%21-tp21078788p21078788.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to