my dog learned polymorphism
The moose likes JSF and the fly likes Displaying dynamic views using Facelets / JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Displaying dynamic views using Facelets / JSF" Watch "Displaying dynamic views using Facelets / JSF" New topic

Displaying dynamic views using Facelets / JSF

Jason Ambrose

Joined: Oct 22, 2011
Posts: 2

I am about to commence work on a project using JSF/Facelets that shall integrate with a third party library.

This third party library contains the screen definition and it has the following API :

The "Screen" object contains a list of controls. A "control" is an interface that has about 25 implementations
- namely LabelControl, TextBoxControl, TextAreaControl, DropDownListControl etc....

Here is an example of how the API will be used to collect data from the user:

Step 1: call getFirstScreenId() ==> This will return the id of the first screen to display to the user.

Step 2: call getScreen() using the screen id

Step 3: The Screen object returned in Step 2 has the list of controls. Display a HTML representation of the screen with all the controls (as a HTML form) to the user.

Step 4: The user has submitted the HTML form. Use the submitScreen() to submit the values.
The third party library will return the next screen id, or -1 if there are no more screens to show.

Step 5: Repeat steps 2-4 until the submitScreen() returns -1. If -1 is returned it means that the
data collection step is over, display the "thank you" page to the user.

The submitScreen() can throw a ScreenValidationException - In this case, redisplay the current screen with the
validation messages present in the ScreenValidationException object.


So, my question is how can I use JSF/Facelets to display the User Interface in this scenario?

I can picture that I need the following

(a) a managed bean that has an action method that performs the interaction with the third party library. Although I think a servlet might be best suited for this?

(b) Facelets UI templates for the 25 odd controls (textboxControl , dropdownlistControl etc....)

(c) Code that loops through the controls in the "Screen" object and does something like

I cannot picture how I can put these three together. Can someone help me?
Jason Ambrose

Joined: Oct 22, 2011
Posts: 2
Any ideas?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

It sounds like JSF is pointless here. Your third-party library is usurping most of the functionality of JSF anyway. Trying to weld the to together sounds like an immense amount of work.

Also, anything that involves looping through the UI in JSF is probably not a good idea anyway. JSF is not a linear display technology like JSPs are. It's based on a 2-dimensional component tree. If you have to run up and down that tree for every little detail, you're talking a lot of work and it's going to be more complex work than simply cycling over flat code a la JSP.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Displaying dynamic views using Facelets / JSF
It's not a secret anymore!