Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how do i turn URLs into hyperlinks in JSF page?

 
Victor Ade
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on an app that displays hyperlinks in JSF page  from URLs and text from my database. I've  created connection to database in a bean class. I could retrieve URLs and Text  from database like this:

how do I go about turning LinkName and Text into hyperlink on my JSF page?
Happy new year!
 
Tim Holloway
Bartender
Posts: 18465
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That won't work. You need to study up on JavaBean naming conventions.

For example, to expose the property "lname" you'd need to name its "get" function "getLname", not "getlname".

If you set up your bean properly, you can emit hyperlinks like this:

 
Victor Ade
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:That won't work. You need to study up on JavaBean naming conventions.

For example, to expose the property "lname" you'd need to name its "get" function "getLname", not "getlname".

If you set up your bean properly, you can emit hyperlinks like this:


How do you suggest i do this Tim? i have my connection in a bean class as Thus:



 
Tim Holloway
Bartender
Posts: 18465
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's going to be a long journey.

First, as I said, you'll need to learn about JavaBeans. JavaBeans are a very important concept in Java and are the basis for many Java services, including JSF.

Secondly, you'll need to cache the results of your database fetch operation. JSF may call a "get" method up to 6 times per page request. So you wouldn't want to fetch the data 6 times. Aside from the overhead of a database fetch, you have the issue of idempotency. Meaning that if you don't get EXACTLY the same set of items in the same order each time you make the query, then JSF can get messed up.

Thirdly, you should learn about database connection pools. Java is an expensive language to program in, and so it's best used for high-performance apps. Connection pools make more efficient use of your database resources in a multi-user application (which most webapps are).
 
Victor Ade
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:It's going to be a long journey.

First, as I said, you'll need to learn about JavaBeans. JavaBeans are a very important concept in Java and are the basis for many Java services, including JSF.

Secondly, you'll need to cache the results of your database fetch operation. JSF may call a "get" method up to 6 times per page request. So you wouldn't want to fetch the data 6 times. Aside from the overhead of a database fetch, you have the issue of idempotency. Meaning that if you don't get EXACTLY the same set of items in the same order each time you make the query, then JSF can get messed up.

Thirdly, you should learn about database connection pools. Java is an expensive language to program in, and so it's best used for high-performance apps. Connection pools make more efficient use of your database resources in a multi-user application (which most webapps are).

First of Tim, thanks for your reply. although i'm on "JAVA EE 6 DEVELOPMENT WITH NETBEANS 7"  i'll definitely readup more on java bean from SUN. I know a little about caching too. but i dont think i know the process involved in building this webapp. did i tell you i am self learning java? yes. This is my first venture into programming and i want to build a single page webapp to display a group of link from database as hyperlink to other site on a JSF webpage. IF you were to be in my position, how would you go about building this APP? i understand i'll have to cache results, but then i'll also want results to be fresh as data in database change frequently.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!