i come up with easy solution. thanks for help:
.properties
attendees.names=All attendees include: {0}
webpage
// example list, but do not know size of list at all times
List<String> attendees = new ArrayList<String>();
attendees.add("Attendee 1");
attendees.add("Attendee 2");
attendees.add("Attendee 3");
add(new Label("attendee-names", new StringResourceModel("attendees.names",
this, null, new Object[]{ Arrays.toString(attendees.toArray()) })));
output:
All attendees include: [Attendee 1, Attendee 2, Attendee 3]
> Date: Fri, 18 Apr 2008 09:22:12 -0700
> From: [EMAIL PROTECTED]
> To: [email protected]
> Subject: Re: StringResourceModel with unknown array parameters
>
> On Fri, Apr 18, 2008 at 8:49 AM, Enrique Rodriguez <[EMAIL PROTECTED]> wrote:
> > ...
> > Cool, I just had to do something similar yesterday. I ended up ...
>
> I coded this up for your example:
>
> MyApp.properties
> ================
>
> label.attendees=All attendees include: ${attendees}
>
> Usage
> =====
>
> List<String> attendees = new ArrayList<String>();
> attendees.add( "Johan" );
> attendees.add( "James" );
> add( new AttendeeLabel( "attendees", "label.attendees", this,
> attendees ) );
>
> Code
> ====
>
> public class AttendeeLabel extends Label
> {
> public AttendeeLabel( String id, String resourceKey, Component
> component, List<String> attendees )
> {
> super( id, new StringResourceModel( resourceKey, component,
> new Model( new Attendees( attendees ) ) ) );
> }
>
> private static class Attendees implements Serializable
> {
> private List<String> attendees;
>
>
> public Attendees( List<String> attendees )
> {
> this.attendees = attendees;
> }
>
>
> public String getAttendees()
> {
> StringBuffer sb = new StringBuffer();
>
> for ( Iterator<String> iterator = attendees.iterator();
> iterator.hasNext(); )
> {
> String attendee = iterator.next();
>
> sb.append( attendee );
>
> if ( iterator.hasNext() )
> {
> sb.append( " " );
> }
> }
>
> return sb.toString();
> }
> }
> }
>
>
> HTH,
>
> Enrique
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>