File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Need advice for converting this page to JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Need advice for converting this page to JSF" Watch "Need advice for converting this page to JSF" New topic

Need advice for converting this page to JSF

Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
FYI - I'm using Glassfish w/ the JSF 1.2 RI...but this should be a straightforward question regardless.

I have a page w/ a rather strange layout that I had previously written w/ a Servlet+JSP using RequestDispatcher...the old-skool MVC approach.

I'd now like to convert it to JSF since we're using that more these days but I'm having a tough time figuring out how it should be done.

The page is a list of employees, split into two columns. Each row has a radio button list to indicate the status of the employee (in regards to attendance) - i.e., the employee is either In, Out, or At Lunch. Next to that is a single text field for the employee to enter a note (e.g., will be out until next Monday, out sick, etc.)

We use this app at our front desk so visitors and employees can keep track of who's in and who is not. It's also used within our portal. Employees use it to set their own status and notes, if needed.

Now, the old way I had done this was; each row (employee) had its own form and I would auto-submit the individual form when one of the radio-buttons was clicked...and the logic to persist the status change was done in the doPost method of the servlet. I used a hidden field to track the employee ID (PK) for each row/form.

I'm really struggling with a simple way to do this in JSF. An h:form for each row, as was done w/ the old version, only renders one form control...and it only gets displayed for the last employee on the list. A global h:form throws an error since you can't have and id value repeated twice.

Here's what the OLD JSP looked like:

Thanks in advance! The help is appreciated!


PS - I had to change "onclick" to "onclik" or I couldn't post, sorry for the previous message, the error I was getting was misleading.
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Use single <h:form> before the start of the table and end it after table. However you will require a field "status" in your employee bean to hold the status against radio button. Its simple enough, i don't think there is any conplexity in converting this page into JSF.
I agree. Here's the link:
subject: Need advice for converting this page to JSF
It's not a secret anymore!