You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mounir Benzid <mb...@meetingmasters.de> on 2012/07/17 12:08:47 UTC
doesn't like to render my listed item as selected
Hey,
I'm iterating through a list of ticket(descriptions) where each ticket
has its own VAT value (I'm in Germany so that could be 0%, 7% or 19% VAT)
The action method "List<TicketDescriptions> getTicketDescriptions()"
returns all available tickets. A TicketDescription has the method
"BigDecimal getValueAddedTaxPercentage()"
which of cource returns the VAT value of that ticket. A list of possible
VAT values is also held in my action class. There's a "List<BigDecimal>
getAllVats()" action method which returns the list, which is then
rendered by <s:select>.
Now I'd like the <s:select> tag to display the appropiate VAT value as
select according to the VAT value currently held by the ticket.
So here is what I did:
<s:iterator var="ticket" value="ticketDescriptions" status="row">
...
<td>
<s:select list="allVats"
value="%{#ticket.valueAddedTaxPercentage}"
name="ticketDescriptions[%{#row.index}].valueAddedTaxPercentage"/>
</td>
...
</s:iterator>
But for some reasons that doesn't work....
So I added a few "debuggging" statements
<s:iterator var="ticket" value="ticketDescriptions" status="row">
...
<td>
<s:property
value="#ticket.valueAddedTaxPercentage"/>
<s:select list="vats"
value="%{#ticket.valueAddedTaxPercentage}"
name="ticketDescriptions[%{#row.index}].valueAddedTaxPercentage"/>
<s:select list="vats" value="7"
name="ticketDescriptions[%{#row.index}].valueAddedTaxPercentage"/>
</td>
...
</s:iterator>
This is the resulting html output generated by the above jsp snippet
0 <<------------------ THE VAT VALUE OF
THE CURRENT TICKET IS 0. CORRECT!
<select name="ticketDescriptions[2].valueAddedTaxPercentage"
id="price_183_create_ticketDescriptions_2__valueAddedTaxPercentage">
<option value="19">19</option>
<option value="7">7</option>
<option value="0">0</option> <<-------------- WHY ISN'T THIS BEING
MARKED AS SELECTED SINCE VALUE == 0 !!
</select>
<select name="ticketDescriptions[2].valueAddedTaxPercentage"
id="price_183_create_ticketDescriptions_2__valueAddedTaxPercentage">
<option value="19">19</option>
<option value="7" selected="selected">7</option> <<--------------
HARD CODING THE VALUE WORKS
<option value="0">0</option>
</select>
Thumbnail picture
http://www1.picturepush.com/photo/a/8750054/640/8750054.png
Any ideas? Thanks!
- Mounir
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: doesn't like to render my listed item as selected
Posted by Mounir Benzid <mb...@meetingmasters.de>.
Could it be that the select-tag doesn't get along well with BigDecimal ?
Am 7/17/2012 12:08 PM, schrieb Mounir Benzid:
> Hey,
>
> I'm iterating through a list of ticket(descriptions) where each
> ticket has its own VAT value (I'm in Germany so that could be 0%, 7%
> or 19% VAT)
>
> The action method "List<TicketDescriptions> getTicketDescriptions()"
> returns all available tickets. A TicketDescription has the method
> "BigDecimal getValueAddedTaxPercentage()"
> which of cource returns the VAT value of that ticket. A list of
> possible VAT values is also held in my action class. There's a
> "List<BigDecimal> getAllVats()" action method which returns the list,
> which is then rendered by <s:select>.
>
> Now I'd like the <s:select> tag to display the appropiate VAT value as
> select according to the VAT value currently held by the ticket.
>
>
> So here is what I did:
>
> <s:iterator var="ticket" value="ticketDescriptions" status="row">
> ...
> <td>
> <s:select list="allVats"
> value="%{#ticket.valueAddedTaxPercentage}"
> name="ticketDescriptions[%{#row.index}].valueAddedTaxPercentage"/>
> </td>
> ...
> </s:iterator>
>
> But for some reasons that doesn't work....
>
>
> So I added a few "debuggging" statements
>
> <s:iterator var="ticket" value="ticketDescriptions" status="row">
> ...
> <td>
> <s:property
> value="#ticket.valueAddedTaxPercentage"/>
> <s:select list="vats"
> value="%{#ticket.valueAddedTaxPercentage}"
> name="ticketDescriptions[%{#row.index}].valueAddedTaxPercentage"/>
> <s:select list="vats" value="7"
> name="ticketDescriptions[%{#row.index}].valueAddedTaxPercentage"/>
> </td>
> ...
> </s:iterator>
>
>
> This is the resulting html output generated by the above jsp snippet
>
> 0 <<------------------ THE VAT VALUE
> OF THE CURRENT TICKET IS 0. CORRECT!
>
> <select name="ticketDescriptions[2].valueAddedTaxPercentage"
> id="price_183_create_ticketDescriptions_2__valueAddedTaxPercentage">
> <option value="19">19</option>
> <option value="7">7</option>
> <option value="0">0</option> <<-------------- WHY ISN'T THIS BEING
> MARKED AS SELECTED SINCE VALUE == 0 !!
> </select>
>
> <select name="ticketDescriptions[2].valueAddedTaxPercentage"
> id="price_183_create_ticketDescriptions_2__valueAddedTaxPercentage">
> <option value="19">19</option>
> <option value="7" selected="selected">7</option> <<--------------
> HARD CODING THE VALUE WORKS
> <option value="0">0</option>
> </select>
>
> Thumbnail picture
> http://www1.picturepush.com/photo/a/8750054/640/8750054.png
>
> Any ideas? Thanks!
>
> - Mounir
>
>
>
>
>
> ---------------------------------------------------------------------
> 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