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.
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.
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...
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 ]
This tiny ad is suggesting that maybe she should go play in traffic.