• 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

Tips to create web forum in JSF

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
I want to create a small web forum using JSF in order to learn more about it.
After some hours of thinking, Some problems started to hit my brain.
Assume my forum home page will be :
http://domain/forum/index.faces
index.faces is similiar to JR saloon index page, it displays a list of forums and lablabla ..
Well, how could this page (index.faces) gets its data from the database ?
And consider the following URL :
http://domain/forum/showthread.faces?forum=12&message=24355
Again, how could this page (showthread.faces) gets it data from the database ?
Any tips ? design tips ?
Thanks.
 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well JSF uses managed beans so you can have a managed bean connect to the dbase and "build itself" or "get built". Then the bean has all the data it needs to render the index page.

Regarding the URL GET values. I use the JSP useBean and setProperty tags. Basically a managed bean is still a bean. So on the top of the page I do any init that hasn't been done by Faces yet. Hence use the useBean. Once that is called I know the bean exists so I setProperty on it. In your case two calls to setProperty should do it.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't look at regular JSP/Servlet type development and figure out how to do the same thing the same way in JSF. JSF is a component oriented framework (sort of). If it does help though, think of it like this...

[JSP/Servlets]


Given you mapped IndexServlet to index in web.xml
URL would be http://server.com/app/index

[JSF]


URL would be http://server.com/app/index.faces

In both cases, when the index page is called the servlet or backing bean is instantiated and it then forwards everything to the JSP.
 
Hussein Baghdadi
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider your URL :
http://server.com/app/index.faces
Well, please correct me if I'm wrong :
Assume that index.faces (index.jsp) contains the following lines :

So, when index.faces displayed, JSF framework will create an instance of IndexBean and every one is happy !
And what to do for a URL like :
http://domain/forum/showthread.faces?forum=12&message=24355
How to pass the parameters to the bean ?
Thanks again guys.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, for starters, JSF doesn't currently support JSTL all that well. Specifically the forEach component. JSF2.0 should though. If I were you I would ust a dataTable instead and then your queryString issue goes away because you deal with a dataRow from the HtmlDataTable component. I can show you some sample code of what I mean when I get home from work later tonight.

You have to stop thinking in JSP/Servlet world. Start thinking about components. Start thinking OO. Think about what properties you could extract from a ForumList (getForumId, getForumName, etc). That will help.
[ January 20, 2006: Message edited by: Gregg Bolinger ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic