File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes how to create a questionaire form dynamically? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSF
Reply Bookmark "how to create a questionaire form dynamically?" Watch "how to create a questionaire form dynamically?" New topic
Author

how to create a questionaire form dynamically?

Alex Zhang
Greenhorn

Joined: Feb 21, 2007
Posts: 3
I need to generate a questionaire form per user based on the user's profile. My plan is like this:
1. create a base jsf page with a blank form with submit and cancel buttons.
2. create a jsp code snippet file per question type.
3. iterate through the user's profile, and include corresponding code snippet for each question.

Can anybody tell me how I should approach #3?

Thank you very much.


Ctrl Space Enter
Anand Hariharan
Rancher

Joined: Aug 22, 2006
Posts: 252

Welcome to JR.

Please review the web-site's Name policy

- Anand


"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery
Alex Zhang
Greenhorn

Joined: Feb 21, 2007
Posts: 3
Thanks for reminding me the naming police.

Can anybody give me any pointers about how to approach this? Thanks.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17243
    
    1

Good Question. There really is a few approaches.

If you use Facelets you can use xhtml pages as templates. create your template, and have one xhtml doc that is defining the content via an HTMLPanelGroup that it gets from a backing bean. So you can build up your UIComponents in code and pass it out to the page.

If each question is an Object then you can create an xhtml page that displays the parts of the Object and just return the object from the backing bean.

If you want all the questions to appear at once, then you could return a list of these objects to the page and use something like a datatable to loop through.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Ryan Lubke
Ranch Hand

Joined: Jun 20, 2007
Posts: 36
Originally posted by Ctrl Space Enter:
I need to generate a questionaire form per user based on the user's profile. My plan is like this:
1. create a base jsf page with a blank form with submit and cancel buttons.
2. create a jsp code snippet file per question type.
3. iterate through the user's profile, and include corresponding code snippet for each question.

Can anybody tell me how I should approach #3?

Thank you very much.


Here is a project with an alternate approach: https://surveytool-sample.dev.java.net/

They use XML documents to define questionnaires and then use JAXB
to create an object graph from said documents. The web interface is
JSF based on completely dynamic based on the survey being used.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: how to create a questionaire form dynamically?
 
Similar Threads
Java interactive questionnaire module
best solution to questionnaire web app
JSP Reload without loosing values
hibernate inheritence problem
How to display questions in several pages?