struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "mreisz@4sxs.de" <mre...@4sxs.de>
Subject AW: Dynamic dropDown List
Date Tue, 18 Jan 2011 08:37:19 GMT
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:thechrispratt@gmail.com] 
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, mreisz@4sxs.de <mreisz@4sxs.de> 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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message