• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to create a questionaire form dynamically?

 
Alex Zhang
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Anand Hariharan
Rancher
Posts: 272
C++ Debian VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JR.

Please review the web-site's Name policy

- Anand
 
Alex Zhang
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reminding me the naming police.

Can anybody give me any pointers about how to approach this? Thanks.
 
Mark Spritzler
ranger
Sheriff
Posts: 17290
9
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ryan Lubke
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!