After working through some tutorials and documentations I ran into some
beginners questions while writing my own, little JSF application.
I would really appreciate it if you could take some time to give me some
hints because I am really lost. Reading the following text will probably
take the longest as I am sure you all know the answers to my newbie
questions off by heart. Here we go:
1. How do I create a tabbed pane and fill the tabs and the active pane with
dynamic links?
3. How do I associate a different parameter to each of those links?
3. How do I pass that parameter on to the Backing Bean method that is called
after clicking on a link?
4. How do I pass such a parameter to a method in a different Backing Bean?
5. Which component is most suitable for such a tabbed pane?
Thank you so much!
Scrut
--
Here is what I want to do:
I have a collection of music pieces and the associated metadata for each
piece is stored in one database table. In a second table I have multiple
classifications such as
Genre
Classical
Jazz
Acid Jazz
Latin Jazz
Rock
Region
Africa
America
South America
North America
Europe
Asia
Australia
Something like that. Each music piece is associated with each classification
tree. (Each music piece belongs to a Genre and comes from a different
region
)
Now I want a user to be able to find a list of music pieces by navigating
through any of those classification systems.
I want something like a tabbed pane where the tabs are filled with the roots
of those classification trees (in this example there are two tabs: Genre and
Region)
Lets assume the active tab is Genre. Then the content of the associated
pane is to be the list of the first level descendants of the root. (In this
example: Classical, Jazz, Rock)
Each item is to be a link so that when the user clicks on Jazz, the pane
will be populated with Acid Jazz and Latin Jazz.
But how do I do that?
1. What components (JSF Core, MyFaces, Tomahawk, Tobago, Sun UI
) should I
use?
2. How do I create the tabs dynamically? I mean: all examples I have seen so
far assume that one knows the number and names of the tabs and hard-codes
each of them. But how do I do that dynamically? (If there is only 2 trees in
the database there will be only 2 tabs but if there are suddenly 3 trees
there will be 3 tabs and so on)
3. How do I create a dynamic list of links where each link carries a
different parameter (e.g. a unique ID)?
4. How do I pass that parameter on to the Backing Bean method that is
invoked by clicking on the link?
Is that even the way to do this?
My idea was: Lets assume, Jazz has primary key 2 in the database and
Acid Jazz has 3 and Latin Jazz has 4 and the database knows that 3
and 4 are children of 2 because each child holds its parent ID:
ITEM_ID NAME PARENT_ID SONG_ID
2 Jazz -- --
3 Acid Jazz 2 --
4 Latin Jazz 2 --
5 Song1 4 1
6 Song2 4 2
Now the user clicks on Jazz which calls the method userClick() within
the associated Backing Bean. Somehow that link carried the parameter 2
which is now used by userClick() to ask the database give me all children
of 2. The database will return a list with the two items Acid Jazz and
Latin Jazz. So the method fills those two items into the managed
properties of the Backing Bean and returns the outcome menupage which is
defined in faces-config.xml to call the menupage.jsp (menupage calls
menupage), thereby filling the active pane with those two items Acid Jazz
and Latin Jazz.
Now lets assume that the user clicks on Latin Jazz so userClick() asks
the database give me all children of 4. The resultset returns items 5 and
6 which are links to two songs. This is evident because the attribute
SONG_ID contains an entry.
Again, the returned outcome is menupage so the pane is populated with
Song1 and Song2.
If the user clicks on Song1, userClick() receives the parameter 5 and
notices that this item links to a Song with the ID 1.
So instead of returning the outcome menupage again, it returns songpage
and passes the parameter 1 to that page which then looks up the metadata
of the song with the ID 1 in the database and displays the content.
But how do I propagate that parameter 1 to the songpage or its backing
bean?
Can I even make the backing bean do a database call BEFORE the songpage is
rendered? Because when the user clicks on Song1 I want to invoke a method
which requests the associated data from the database and displays it on the
songpage.
Is this even the way to go?
Or how should I tackle this problem?
How do I do that?
Thanks so much!