You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Scrut Inizer <sc...@hotmail.com> on 2006/05/11 13:48:12 UTC
[newbie] Beginners questions regarding dynamic links
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!
Re: [newbie] Beginners questions regarding dynamic links
Posted by Scrut Inizer <sc...@hotmail.com>.
Thanks for your hints. However, as a JSF beginner I still don't know what to
do. I spent the past 8 hours reading everything I found on the myfaces page
including the wiki, reviewed the examples and used google extensively. All
examples I found either used hard coded tabs and such or didn't offer any
documentation.
But I assume there must be some documentation SOMEWHERE which is sufficient
to use the panelTabbedPane with a binding?
I couldn't find a much and don't understand what I got.
Thank you very much
>From: "Matthias Wessendorf" <ma...@apache.org>
>Reply-To: "MyFaces Discussion" <us...@myfaces.apache.org>
>To: "MyFaces Discussion" <us...@myfaces.apache.org>
>Subject: Re: [newbie] Beginners questions regarding dynamic links
>Date: Thu, 11 May 2006 16:57:38 +0200
>
>To make a long story short :-)
>
>JSF Core can mean MyFaces IMPL or SUN RI, since JSF is a spec
>(all <h:*** and <f:*** related stuff)
>
>Tomahawk is a set of custom components, like Tobago and the ADF Faces
>donation
>
>Reading myfaces.apache.org (and wiki.apache.org/myfaces) will help you
>on some questions.
>
>For a tabbed pane you can use MyFaces Tomahawk's component ([1]). the
>example is "hard coded" as well. But you can use the binding attribute
>to push the component itself to a backing bean. This will allow you
>access to the component by hacking java code inside the backing bean.
>Means you can add childrens with Java Code (aka tabs)
>
>HTH,
>Matthias
>
>[1] http://www.irian.at/myfaces/tabbedPane.jsf
>
>On 5/11/06, Scrut Inizer <sc...@hotmail.com> wrote:
>>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)
>>Let's 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: Let's 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 let's 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!
>>
>>
>>
>
>
>--
>Matthias Wessendorf
>Aechterhoek 18
>48282 Emsdetten
>http://jroller.com/page/mwessendorf
>mwessendorf-at-gmail-dot-com
Re: [newbie] Beginners questions regarding dynamic links
Posted by Matthias Wessendorf <ma...@apache.org>.
To make a long story short :-)
JSF Core can mean MyFaces IMPL or SUN RI, since JSF is a spec
(all <h:*** and <f:*** related stuff)
Tomahawk is a set of custom components, like Tobago and the ADF Faces donation
Reading myfaces.apache.org (and wiki.apache.org/myfaces) will help you
on some questions.
For a tabbed pane you can use MyFaces Tomahawk's component ([1]). the
example is "hard coded" as well. But you can use the binding attribute
to push the component itself to a backing bean. This will allow you
access to the component by hacking java code inside the backing bean.
Means you can add childrens with Java Code (aka tabs)
HTH,
Matthias
[1] http://www.irian.at/myfaces/tabbedPane.jsf
On 5/11/06, Scrut Inizer <sc...@hotmail.com> wrote:
> 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)
> Let's 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: Let's 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 let's 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!
>
>
>
--
Matthias Wessendorf
Aechterhoek 18
48282 Emsdetten
http://jroller.com/page/mwessendorf
mwessendorf-at-gmail-dot-com