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/06/27 12:38:56 UTC

How to string concatenate listValue in struts (radio) tag?

Hi


here's the deal.

Suppose I want to display a <s:radio> tag showing a list of 
TicketDescriptions where each has the property ticketName, i.e. a method 
getTicketName()).
getTicketName itself returns an instance of type LocalizedString for 
which I wrote a custom struts conversion.
LocalizedString  is basically an enhanced java.util.String object which 
contains the TicketDescription's name.
After the conversion ticketName will be of type java.lang.String.

So this is what I use so far:

                         <s:radio name="ticket"
                                  list="ticketDescriptions"
                                  listKey="id"
                                  listValue="ticketName"
                                  />


and as an example results in
[ ] student ticket
[ ] VIP ticket
[ ]...



BUT what I really would like to see is

[ ] student ticket (10 Euro)
[ ] VIP ticket (100 Euro)
[ ]...



This is what I tried so far but with no avail


                         <s:radio name="ticket"
                                  list="ticketDescriptions"
                                  listKey="id"
                                  listValue="%{ticketName +  ' (100 
Euro)' }"
                                  />


The output is

[ ] xx.xx.LocalizedString@1bb8d3e[ID=373,Locale=en,Title="student 
ticket"] (100 Euro)
[ ] xx.xx.LocalizedString@1bb8d3e[ID=374,Locale=en,Title="VIP ticket"] 
(100 Euro)

Any ideas? thanks!




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


Re: How to string concatenate listValue in struts (radio) tag?

Posted by Mounir Benzid <mb...@meetingmasters.de>.
Fair question... it's because the right label which is the localised 
name of the current TicketDescription will be determined only by the 
choosen locale during  runtime and is not knowm during
compile time. For instance German clients will be presented with German 
translations. Someone in France wants to see the French translation and 
so forth.


This's what I  do now which is pretty lame imo.

/***********************************************************************************************/
     public String getTicketLabel(Long id) {
         if (id == null) {
             throw new NullArgumentException("id");
         }
         List<TicketDescription> list = 
bookingTransactionBean.getEventProductCatalog().getTicketDescriptionsWithFirstAsPrimary();

         for (TicketDescription description : list) {
             if (!id.equals(description.getId()) {
                 continue;
             }
             String name = 
description.getTicketNameByLocale(**getLocale()**);
             String price = 
description.getPrice().getAmount().toPlainString();
             String symbol = 
description.getPrice().getCurrencyUnit().getSymbol();

             return name + " (" + price + " " + symbol + ")";
         }

         // given id doesn't match any ticketdescription
         return "";

     }



Am 6/27/2012 2:14 PM, schrieb Dave Newton:
> Why not just build the list with the right label already in it?
>
> Dave
>
> On Wed, Jun 27, 2012 at 8:01 AM, Mounir Benzid <mb...@meetingmasters.de> wrote:
>
>> Can I do something along the lines of this?
>>
>>
>>                         <s:radio name="ticket"
>>                                  list="ticketDescriptions"
>>                                  listKey="id"
>> listValue="%{getTicketLabel(#**this)}"
>>                                  />
>>
>> using #this as a reference for the current TicketDescription instance.
>>
>> Am 6/27/2012 1:41 PM, schrieb Mounir Benzid:
>>
>>
>>> Like this?
>>>
>>> String getTicketLabelById(Long id) {
>>>    TicketDescription td = lookupTicketDescriptionBy(id);
>>> ....
>>> }
>>>
>>>                        <s:radio name="ticket"
>>>                                 list="ticketDescriptions"
>>>                                 listKey="id"
>>> listValue="%{**getTicketLabelById(id)}"
>>>                                 />
>>>
>>> The only downside I see is the lookup that has to be carried out every
>>> time the method is called, since in theory I'm already iterating through
>>> the appropriate instance.
>>>
>>>
>>>
>>>
>>> Am 6/27/2012 1:14 PM, schrieb Dave Newton:
>>>
>>>> My idea would be to create presentation layer data outside of the JSP.
>>>>
>>>> Dave
>>>>
>>>> On Wed, Jun 27, 2012 at 6:38 AM, Mounir Benzid <mb...@meetingmasters.de>
>>>> wrote:
>>>>
>>>>   Hi
>>>>>
>>>>> here's the deal.
>>>>>
>>>>> Suppose I want to display a <s:radio> tag showing a list of
>>>>> TicketDescriptions where each has the property ticketName, i.e. a method
>>>>> getTicketName()).
>>>>> getTicketName itself returns an instance of type LocalizedString for
>>>>> which
>>>>> I wrote a custom struts conversion.
>>>>> LocalizedString  is basically an enhanced java.util.String object which
>>>>> contains the TicketDescription's name.
>>>>> After the conversion ticketName will be of type java.lang.String.
>>>>>
>>>>> So this is what I use so far:
>>>>>
>>>>>                         <s:radio name="ticket"
>>>>>                                  list="ticketDescriptions"
>>>>>                                  listKey="id"
>>>>>                                  listValue="ticketName"
>>>>>                                  />
>>>>>
>>>>>
>>>>> and as an example results in
>>>>> [ ] student ticket
>>>>> [ ] VIP ticket
>>>>> [ ]...
>>>>>
>>>>>
>>>>>
>>>>> BUT what I really would like to see is
>>>>>
>>>>> [ ] student ticket (10 Euro)
>>>>> [ ] VIP ticket (100 Euro)
>>>>> [ ]...
>>>>>
>>>>>
>>>>>
>>>>> This is what I tried so far but with no avail
>>>>>
>>>>>
>>>>>                         <s:radio name="ticket"
>>>>>                                  list="ticketDescriptions"
>>>>>                                  listKey="id"
>>>>>                                  listValue="%{ticketName +  ' (100
>>>>> Euro)' }"
>>>>>                                  />
>>>>>
>>>>>
>>>>> The output is
>>>>>
>>>>> [ ] xx.xx.LocalizedString@1bb8d3e[****ID=373,Locale=en,Title="****
>>>>> student
>>>>> ticket"] (100 Euro)
>>>>> [ ] xx.xx.LocalizedString@1bb8d3e[****ID=374,Locale=en,Title="VIP
>>>>> ticket"]
>>>>> (100 Euro)
>>>>>
>>>>> Any ideas? thanks!
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ------------------------------****----------------------------**--**---------
>>>>>
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.**apac**he.org<http://apache.org>
>>>>> <us...@struts.apache.org>
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>
>>>>>
>>>>>
>>>
>> --
>> Mounir Benzid
>> Systementwickler / EDV
>>
>> meetingmasters.de
>> meetings meisterhaft managen
>>
>> · Unabhängige Vermittlung von Tagungshotels
>> · Online-**Hotelreservierungssystem zur Integration in die
>> Veranstaltungs-Webseite
>> · Webbasiertes Veranstaltungs- und Teilnehmermanagement
>> · E-Procurement für den MICE-Einkauf
>> · Webbasierte Anfrage und Verhandlung von Firmenraten
>>
>> Max-Planck-Straße 22
>> D-54296 Trier
>>
>> fon +49 (0)651-145789-38
>> fax +49 (0)651-145789-20
>>
>> www.meetingmasters.de
>> mb@meetingmasters.de
>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>


-- 
Mounir Benzid
Systementwickler / EDV

meetingmasters.de
meetings meisterhaft managen

· Unabhängige Vermittlung von Tagungshotels
· Online-Hotelreservierungssystem zur Integration in die Veranstaltungs-Webseite
· Webbasiertes Veranstaltungs- und Teilnehmermanagement
· E-Procurement für den MICE-Einkauf
· Webbasierte Anfrage und Verhandlung von Firmenraten

Max-Planck-Straße 22
D-54296 Trier

fon +49 (0)651-145789-38
fax +49 (0)651-145789-20

www.meetingmasters.de
mb@meetingmasters.de


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


Re: How to string concatenate listValue in struts (radio) tag?

Posted by Dave Newton <da...@gmail.com>.
Why not just build the list with the right label already in it?

Dave

On Wed, Jun 27, 2012 at 8:01 AM, Mounir Benzid <mb...@meetingmasters.de> wrote:

>
> Can I do something along the lines of this?
>
>
>                        <s:radio name="ticket"
>                                 list="ticketDescriptions"
>                                 listKey="id"
> listValue="%{getTicketLabel(#**this)}"
>                                 />
>
> using #this as a reference for the current TicketDescription instance.
>
> Am 6/27/2012 1:41 PM, schrieb Mounir Benzid:
>
>
>> Like this?
>>
>> String getTicketLabelById(Long id) {
>>   TicketDescription td = lookupTicketDescriptionBy(id);
>> ....
>> }
>>
>>                       <s:radio name="ticket"
>>                                list="ticketDescriptions"
>>                                listKey="id"
>> listValue="%{**getTicketLabelById(id)}"
>>                                />
>>
>> The only downside I see is the lookup that has to be carried out every
>> time the method is called, since in theory I'm already iterating through
>> the appropriate instance.
>>
>>
>>
>>
>> Am 6/27/2012 1:14 PM, schrieb Dave Newton:
>>
>>> My idea would be to create presentation layer data outside of the JSP.
>>>
>>> Dave
>>>
>>> On Wed, Jun 27, 2012 at 6:38 AM, Mounir Benzid <mb...@meetingmasters.de>
>>> wrote:
>>>
>>>  Hi
>>>>
>>>>
>>>> here's the deal.
>>>>
>>>> Suppose I want to display a <s:radio> tag showing a list of
>>>> TicketDescriptions where each has the property ticketName, i.e. a method
>>>> getTicketName()).
>>>> getTicketName itself returns an instance of type LocalizedString for
>>>> which
>>>> I wrote a custom struts conversion.
>>>> LocalizedString  is basically an enhanced java.util.String object which
>>>> contains the TicketDescription's name.
>>>> After the conversion ticketName will be of type java.lang.String.
>>>>
>>>> So this is what I use so far:
>>>>
>>>>                        <s:radio name="ticket"
>>>>                                 list="ticketDescriptions"
>>>>                                 listKey="id"
>>>>                                 listValue="ticketName"
>>>>                                 />
>>>>
>>>>
>>>> and as an example results in
>>>> [ ] student ticket
>>>> [ ] VIP ticket
>>>> [ ]...
>>>>
>>>>
>>>>
>>>> BUT what I really would like to see is
>>>>
>>>> [ ] student ticket (10 Euro)
>>>> [ ] VIP ticket (100 Euro)
>>>> [ ]...
>>>>
>>>>
>>>>
>>>> This is what I tried so far but with no avail
>>>>
>>>>
>>>>                        <s:radio name="ticket"
>>>>                                 list="ticketDescriptions"
>>>>                                 listKey="id"
>>>>                                 listValue="%{ticketName +  ' (100
>>>> Euro)' }"
>>>>                                 />
>>>>
>>>>
>>>> The output is
>>>>
>>>> [ ] xx.xx.LocalizedString@1bb8d3e[****ID=373,Locale=en,Title="****
>>>> student
>>>> ticket"] (100 Euro)
>>>> [ ] xx.xx.LocalizedString@1bb8d3e[****ID=374,Locale=en,Title="VIP
>>>> ticket"]
>>>> (100 Euro)
>>>>
>>>> Any ideas? thanks!
>>>>
>>>>
>>>>
>>>>
>>>> ------------------------------****----------------------------**--**---------
>>>>
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.**apac**he.org<http://apache.org>
>>>> <us...@struts.apache.org>
>>>> >
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>>
>>
>>
>
> --
> Mounir Benzid
> Systementwickler / EDV
>
> meetingmasters.de
> meetings meisterhaft managen
>
> · Unabhängige Vermittlung von Tagungshotels
> · Online-**Hotelreservierungssystem zur Integration in die
> Veranstaltungs-Webseite
> · Webbasiertes Veranstaltungs- und Teilnehmermanagement
> · E-Procurement für den MICE-Einkauf
> · Webbasierte Anfrage und Verhandlung von Firmenraten
>
> Max-Planck-Straße 22
> D-54296 Trier
>
> fon +49 (0)651-145789-38
> fax +49 (0)651-145789-20
>
> www.meetingmasters.de
> mb@meetingmasters.de
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: How to string concatenate listValue in struts (radio) tag?

Posted by Mounir Benzid <mb...@meetingmasters.de>.
Can I do something along the lines of this?

                         <s:radio name="ticket"
                                  list="ticketDescriptions"
                                  listKey="id"
listValue="%{getTicketLabel(#this)}"
                                  />

using #this as a reference for the current TicketDescription instance.

Am 6/27/2012 1:41 PM, schrieb Mounir Benzid:
>
> Like this?
>
> String getTicketLabelById(Long id) {
>    TicketDescription td = lookupTicketDescriptionBy(id);
> ....
> }
>
>                        <s:radio name="ticket"
>                                 list="ticketDescriptions"
>                                 listKey="id"
> listValue="%{getTicketLabelById(id)}"
>                                 />
>
> The only downside I see is the lookup that has to be carried out every 
> time the method is called, since in theory I'm already iterating 
> through the appropriate instance.
>
>
>
>
> Am 6/27/2012 1:14 PM, schrieb Dave Newton:
>> My idea would be to create presentation layer data outside of the JSP.
>>
>> Dave
>>
>> On Wed, Jun 27, 2012 at 6:38 AM, Mounir Benzid <mb...@meetingmasters.de> 
>> wrote:
>>
>>> Hi
>>>
>>>
>>> here's the deal.
>>>
>>> Suppose I want to display a <s:radio> tag showing a list of
>>> TicketDescriptions where each has the property ticketName, i.e. a 
>>> method
>>> getTicketName()).
>>> getTicketName itself returns an instance of type LocalizedString for 
>>> which
>>> I wrote a custom struts conversion.
>>> LocalizedString  is basically an enhanced java.util.String object which
>>> contains the TicketDescription's name.
>>> After the conversion ticketName will be of type java.lang.String.
>>>
>>> So this is what I use so far:
>>>
>>>                         <s:radio name="ticket"
>>>                                  list="ticketDescriptions"
>>>                                  listKey="id"
>>>                                  listValue="ticketName"
>>>                                  />
>>>
>>>
>>> and as an example results in
>>> [ ] student ticket
>>> [ ] VIP ticket
>>> [ ]...
>>>
>>>
>>>
>>> BUT what I really would like to see is
>>>
>>> [ ] student ticket (10 Euro)
>>> [ ] VIP ticket (100 Euro)
>>> [ ]...
>>>
>>>
>>>
>>> This is what I tried so far but with no avail
>>>
>>>
>>>                         <s:radio name="ticket"
>>>                                  list="ticketDescriptions"
>>>                                  listKey="id"
>>>                                  listValue="%{ticketName +  ' (100 
>>> Euro)' }"
>>>                                  />
>>>
>>>
>>> The output is
>>>
>>> [ ] xx.xx.LocalizedString@1bb8d3e[**ID=373,Locale=en,Title="**student
>>> ticket"] (100 Euro)
>>> [ ] xx.xx.LocalizedString@1bb8d3e[**ID=374,Locale=en,Title="VIP 
>>> ticket"]
>>> (100 Euro)
>>>
>>> Any ideas? thanks!
>>>
>>>
>>>
>>>
>>> ------------------------------**------------------------------**--------- 
>>>
>>> To unsubscribe, e-mail: 
>>> user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>
>


-- 
Mounir Benzid
Systementwickler / EDV

meetingmasters.de
meetings meisterhaft managen

· Unabhängige Vermittlung von Tagungshotels
· Online-Hotelreservierungssystem zur Integration in die Veranstaltungs-Webseite
· Webbasiertes Veranstaltungs- und Teilnehmermanagement
· E-Procurement für den MICE-Einkauf
· Webbasierte Anfrage und Verhandlung von Firmenraten

Max-Planck-Straße 22
D-54296 Trier

fon +49 (0)651-145789-38
fax +49 (0)651-145789-20

www.meetingmasters.de
mb@meetingmasters.de


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


Re: How to string concatenate listValue in struts (radio) tag?

Posted by Mounir Benzid <mb...@meetingmasters.de>.
Like this?

String getTicketLabelById(Long id) {
    TicketDescription td = lookupTicketDescriptionBy(id);
....
}

                        <s:radio name="ticket"
                                 list="ticketDescriptions"
                                 listKey="id"
                                 listValue="%{getTicketLabelById(id)}"
                                 />

The only downside I see is the lookup that has to be carried out every 
time the method is called, since in theory I'm already iterating through 
the appropriate instance.




Am 6/27/2012 1:14 PM, schrieb Dave Newton:
> My idea would be to create presentation layer data outside of the JSP.
>
> Dave
>
> On Wed, Jun 27, 2012 at 6:38 AM, Mounir Benzid <mb...@meetingmasters.de> wrote:
>
>> Hi
>>
>>
>> here's the deal.
>>
>> Suppose I want to display a <s:radio> tag showing a list of
>> TicketDescriptions where each has the property ticketName, i.e. a method
>> getTicketName()).
>> getTicketName itself returns an instance of type LocalizedString for which
>> I wrote a custom struts conversion.
>> LocalizedString  is basically an enhanced java.util.String object which
>> contains the TicketDescription's name.
>> After the conversion ticketName will be of type java.lang.String.
>>
>> So this is what I use so far:
>>
>>                         <s:radio name="ticket"
>>                                  list="ticketDescriptions"
>>                                  listKey="id"
>>                                  listValue="ticketName"
>>                                  />
>>
>>
>> and as an example results in
>> [ ] student ticket
>> [ ] VIP ticket
>> [ ]...
>>
>>
>>
>> BUT what I really would like to see is
>>
>> [ ] student ticket (10 Euro)
>> [ ] VIP ticket (100 Euro)
>> [ ]...
>>
>>
>>
>> This is what I tried so far but with no avail
>>
>>
>>                         <s:radio name="ticket"
>>                                  list="ticketDescriptions"
>>                                  listKey="id"
>>                                  listValue="%{ticketName +  ' (100 Euro)' }"
>>                                  />
>>
>>
>> The output is
>>
>> [ ] xx.xx.LocalizedString@1bb8d3e[**ID=373,Locale=en,Title="**student
>> ticket"] (100 Euro)
>> [ ] xx.xx.LocalizedString@1bb8d3e[**ID=374,Locale=en,Title="VIP ticket"]
>> (100 Euro)
>>
>> Any ideas? thanks!
>>
>>
>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>


-- 
Mounir Benzid
Systementwickler / EDV

meetingmasters.de
meetings meisterhaft managen

· Unabhängige Vermittlung von Tagungshotels
· Online-Hotelreservierungssystem zur Integration in die Veranstaltungs-Webseite
· Webbasiertes Veranstaltungs- und Teilnehmermanagement
· E-Procurement für den MICE-Einkauf
· Webbasierte Anfrage und Verhandlung von Firmenraten

Max-Planck-Straße 22
D-54296 Trier

fon +49 (0)651-145789-38
fax +49 (0)651-145789-20

www.meetingmasters.de
mb@meetingmasters.de


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


Re: How to string concatenate listValue in struts (radio) tag?

Posted by Dave Newton <da...@gmail.com>.
My idea would be to create presentation layer data outside of the JSP.

Dave

On Wed, Jun 27, 2012 at 6:38 AM, Mounir Benzid <mb...@meetingmasters.de> wrote:

> Hi
>
>
> here's the deal.
>
> Suppose I want to display a <s:radio> tag showing a list of
> TicketDescriptions where each has the property ticketName, i.e. a method
> getTicketName()).
> getTicketName itself returns an instance of type LocalizedString for which
> I wrote a custom struts conversion.
> LocalizedString  is basically an enhanced java.util.String object which
> contains the TicketDescription's name.
> After the conversion ticketName will be of type java.lang.String.
>
> So this is what I use so far:
>
>                        <s:radio name="ticket"
>                                 list="ticketDescriptions"
>                                 listKey="id"
>                                 listValue="ticketName"
>                                 />
>
>
> and as an example results in
> [ ] student ticket
> [ ] VIP ticket
> [ ]...
>
>
>
> BUT what I really would like to see is
>
> [ ] student ticket (10 Euro)
> [ ] VIP ticket (100 Euro)
> [ ]...
>
>
>
> This is what I tried so far but with no avail
>
>
>                        <s:radio name="ticket"
>                                 list="ticketDescriptions"
>                                 listKey="id"
>                                 listValue="%{ticketName +  ' (100 Euro)' }"
>                                 />
>
>
> The output is
>
> [ ] xx.xx.LocalizedString@1bb8d3e[**ID=373,Locale=en,Title="**student
> ticket"] (100 Euro)
> [ ] xx.xx.LocalizedString@1bb8d3e[**ID=374,Locale=en,Title="VIP ticket"]
> (100 Euro)
>
> Any ideas? thanks!
>
>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
> For additional commands, e-mail: user-help@struts.apache.org
>
>