Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSF
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JSF
Need correct syntax for dynamic form, list of elements
George Schrader
Greenhorn
Posts: 20
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am trying to code up a dynamic form. Here is the
JSF
:
<h:form> <p:dataTable id="dta" value="#{FormComponent.listFormTypeQuestions(1)}" var="current" rows="15" paginator="false"> <h:inputHidden id="formQuestionId" value="#{FormComponent.formQuestionId.add(#{current.formQuestionId})}"/> <p:column> <f:facet name="header"> <h:outputText value="Question" /> </f:facet> <!-- <p:message/>--> <h:outputText value="#{current.question}" rendered="#{not empty current.responses}"/> <h:outputText value="#{current.question}" rendered="#{empty current.responses}" style="font-weight:bold"/> </p:column> <p:column width="100"> <f:facet name="header"> <h:outputText value="Responses" /> </f:facet> <h:selectOneRadio id="response" value="#{FormComponent.responses.add(itemValue)}" required="true" rendered="#{not empty current.responses}" requiredMessage="The question -- #{current.question} -- requires an answer."> <!-- #{assessmentmsgs['assessment.question.required']}">--> <f:selectItem id="yes" itemLabel="Yes" itemValue="yes"/><!-- <h:selectOneRadio id="#{current.formQuestionId}" label="Yes" value="yes"/>--> <f:selectItem id="no" itemLabel="No" itemValue="no"/><!-- <h:selectOneRadio id="#{current.formQuestionId}" label="No" value="no"/>--> </h:selectOneRadio> </p:column> </p:dataTable> <div align="center"><p:commandButton id="SubmitButton" ajax="false" value="Save Assessment" action="#{FormComponent.saveTest()}"/></div> </h:form>
This is the bean code:
private HashSet<Integer> formQuestionIds; private ArrayList<String> responses; public HashSet<Integer> getFormQuestionIds() { return formQuestionIds; } public void setFormQuestionIds(HashSet<Integer> formQuestionIds) { this.formQuestionIds = formQuestionIds; } public ArrayList<String> getResponses() { return responses; } public void setResponses(ArrayList<String> responses) { this.responses = responses; public void saveTest(){ System.out.println("++++++++++++++++++++++++++++++++++++++"); for (Integer questionId : formQuestionIds) System.out.println(questionId); for (String response : responses) System.out.println(response); }
The systax I need is how to add to the Lists on each iteration. What do I code to add a new value to the sets/lists in each case?
Thanks in advance!Top Delete postReport this postReply with quoteEdit post
The happiness of your life depends upon the quality of your thoughts -Marcus Aurelius ... think about this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Problem trying to send file to browser in JSF
JSF - Missing source code using templating and composition
Unable to populate values obtained from ajax call using PrimeFaces
Dynamic Radio Button
Radio
More...