I'm having some problems with JSF navigation and passing parameters; this is the scenario:
Three pages: artists, albums, tracks
For each page a bean: ArtistBean, AlbumBean, TrackBean (session scoped)
The artist page contains a list of artists, each artistname is a link and when clicking it you navigate to the album page which lists the albums by that artist. Similarly, when clicking an album, you navigate to the track page with a list of tracks for that album.
The links looks as follows:
Page artist: <h:commandLink action="#{albumBean.showAlbums(artist)}" value="#{artist.name}" />
Page album: <h:commandLink action="#{trackBean.showTracks(album)}" value="#{album.name}" />
The beans looks as follows:
AlbumBean: public String showAlbums(Artist artist){
[generate list of albums, fetched by page "albums" using getAlbumList()]
return "Albums";
}
public List<Album> getAlbumList(){
return albumList;
}
TrackBean: public String showTracks(Album album){
[generate list of tracks, fetched by page "tracks" using getTrackList()]
return "Tracks";
}
public List<Track> getTrackList(){
return trackList;
}
I'm not sure if this is an "OK" way to handle navigation; calling a backing bean for a page that has not yet bean displayed. I also get some weird behaviour, mainly that the links to show tracks only works if I click twice, whereas the links to show albums always work when just clicking once.
Thanks in advance!