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]