Hello,
I used the normal <select> and <option> tag and built the form by hand. But on
this way, I lost all the save mechanisms from struts (if the page is reloaded
all the dropdown value are lost).
I didn't find a working solution...
So I tried again with the struts tag, and I did:
<s:iterator value="questions">
<s:property value="questionId"/><br/>
<s:property value="questionName"/><br/>
<s:select key="??????????????" list="answers"/><br/><br/>
</s:iterator>
- I iterate on the list "questions" (return by the function:
List<QuestionObject> getQuestions() in the action class) with the iterator.
- I display the id and the questionName
- Then I would like to generate for each question a drop down list with the
answers (return by the function: List<String> getAnswers() in the action class)
The form is properly generated, all the questions with dropdown are displayed...
But how can I save all the values of the dropdowns in my bean?
I thought maybe with a list or a table attribute in the bean, with getter and
setter...
Any Idea?
Thanks and regards,
Matthieu
-----Ursprüngliche Nachricht-----
Von: Chris Pratt [mailto:[email protected]]
Gesendet: Dienstag, 18. Januar 2011 17:18
An: Struts Users Mailing List
Betreff: Re: Dynamic dropDown List
Unfortunately the <s:select> tag doesn't work like the <select> HTML element.
If that's what you are trying to do you could either set up the list to be
displayed in the action and reference it in the <s:select> "list"
attribute, or you could just use <select> and <option> and build it yourself.
(*Chris*)
On Tue, Jan 18, 2011 at 12:37 AM, [email protected] <[email protected]> wrote:
> Hi Chris,
>
> Thank you for your reply, I had already try with the iterator but I
> had two
> problem:
> - I would like to put the <:property value="name"> in a
> dropdown List (<s:select>)
> - the answerList from the second iterator, depends from the
> current item from the first list
>
> Something like:
>
> <s:iterator value="questionList" status="qStatus">
> <s:select label="<s:property value='description' />"
> <s:iterator value="answerList(<s:property
> value=questionId/>)" status="aStatus">
> <option value="<s:property
> value='AnswerDescription'/>" name="<s:property value='answerId'/>" />
> </s:iterator>
> </s:iterator>
>
> Thank you for your help,
> Mat
>
> -----Ursprüngliche Nachricht-----
> Von: Chris Pratt [mailto:[email protected]]
> Gesendet: Montag, 17. Januar 2011 19:22
> An: Struts Users Mailing List
> Betreff: Re: Dynamic dropDown List
>
> The Struts documentation can be pretty helpful here. Here's an
> excerpt from http://struts.apache.org/2.1.8.1/docs/iterator.html (I
> changed the variable names to match yours):
>
> <s:iterator value="questionList" status="qStatus">
> <tr class="<s:if test="#qStatus.odd == true
> ">odd</s:if><s:else>even</s:else>">
> <td><s:property value="name"/></td>
> <td><s:property value="description"/></td>
> <td>
> <s:iterator value="answerList" status="aStatus">
> <s:property value="description"/><s:if
> test="!#aStatus.last">,</s:if>
> </s:iterator>
> </td>
> </tr>
> </s:iterator>
>
> If you need to access the current question while inside the answer
> loop, look at the var attribute.
> (*Chris*)
>
> On Mon, Jan 17, 2011 at 2:59 AM, [email protected] <[email protected]> wrote:
>
> > Hello,
> >
> > This is my first request in this mailing list, I hope I am doing it
> > right
> !
> >
> > I am currently developing a Portlet for Liferay using Struts 2, it
> > is working good and I am often surprised with all the possibilities
> > from Struts2.
> > Unfortunately I have a blocker !
> > I would like to design a form with a survey thanks to dropDown List
> > and would like to get all the content from a database.
> > In the database, there are a table question (questionId,
> > questionName) and a table answer (answerId, answerName, questionId)
> > and I would like to generate all the dropdown from these table...
> >
> > While (question)
> > {
> > While {answer from this question)
> > {
> > }
> >
> >
> > I tried many solutions, but I didn't achieved it!
> >
> > Thank you for your help,
> > Mat
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]