Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Tips to create web forum in JSF

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • 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.
 
Gerardo Tasistro
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • 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.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • 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
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!