• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Confused. How do I add links to each item in a list, how to get JSF to know which link was clicked?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a page listing books. How do I go about adding a link to each one? When one of them is clicked how do I get it to go to a separate page "book.xhtml" showing details of that specific book clicked?

Here is my code so far:

Book.java


BookCatalogBean.java



index.xhtml
 
Greenhorn
Posts: 6
Hibernate Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can either do it in multiple approaches using h:commandLink or h:outputLink

Approach1:



implement navigation rule to handle bookDetails.

Approach2:



implement navigation rule to handle someAction

Approach3:





 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or better yet, you can use a JSF dataTable instead of violating the MVC paradigm by putting what amounts to executable code on the View template.

By proper use of CSS, a dataTable can be made to visually appear just like an ordered (or unordered) list. In fact, the h:messages tag does exactly that, if the message display options are set for it.
 
Jonny Devine
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Abhinav Taduka wrote:You can either do it in multiple approaches using h:commandLink or h:outputLink



Thanks very much! I shall try these out now.

Tim Holloway wrote:Or better yet, you can use a JSF dataTable instead of violating the MVC paradigm by putting what amounts to executable code on the View template.

By proper use of CSS, a dataTable can be made to visually appear just like an ordered (or unordered) list. In fact, the h:messages tag does exactly that, if the message display options are set for it.



But aren't tables becoming obsolete? When I program in OO PHP I like looping through arrays and designing the layout with div's. Seems so much easier. Perphaps im looking at this the wrong way.
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you are looking at it the wrong way. You're also buying into an outmoded bit of folk wisdom.

When CSS rose to ascendency, some dogmatists began insisting that HTML tables should be verboten and everything should be done with div elements, instead. The div has its place, but the HTML table tag is still cleaner and simpler when you want to lay out a general grid.

In any event, we're talking JSF here, not raw HTML, and in JSF, the dataTable is the premier way to present grid-structured data (including cases where the "grid" is only 1 column wide, such as an ordered list). In addition to the layout, it also provides the datamodel and code infrastructure to make it easier.

Furthermore, we're talking Model/View/Controller. In MVC, each of the 3 components has a definite role. In JSF, most of the Controllers are pre-supplied for you, the backing bean is the Model, and the JSF page definition is the View template. The View template should be exactly that - a template, not a code module. Code goes in the Model (and in the Controllers, but like I said, JSF's Controllers are mostly pre-supplied).

I'm very fond of PHP as a quick-and-dirty way of getting webapps, out, but the key word here is dirty. It is, in fact, precisely the case that PHP embeds the code onto the View that make PHP difficult to work with on large complex projects. JSF, on the other hand, is horribly expensive as a platform for developing simple webapps, precisely because of all the extra files you have to set up and include. As you scale up, PHP becomes less beautiful and J2EE (and JSF) become more beautiful. They each have their places.
 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic