Re: [Stripes-users] Populating Sets

Subject:   Re: [Stripes-users] Populating Sets (find more)
From:   Sebastian Beigel <hidden> (find more)
Date:   Dec 05, 2005 08:54


> I think there are several ways to tackle this depending on exactly what
> the underlying objects look like, and what you need done in order to
> make your use case work...

I made this work using a request-scope action bean, a Formatter for my
domain objects and a constructor with an appropriate String param (to
process the id) -- and fixing a bug (or missing feature *g*) in Stripes


In your action bean:

public Foo foo;

// getter & setter...

in your domain object Foo:

public Set<Bar> bars;

// getter & setter...

in your child domain object Bar:

// constructor
public Bar(String id) { = new Long(id);

and in your JSP:

<c:forEach items="${actionBean.bars}" var="b" varStatus="status">
 <stripes:checkbox name="foo.bars" value="${}"
checked="${}" /> ${b.label}

This works also w/ multi-select boxes like:

<stripes:select multiple="true" name="foo.bars">
 <stripes:options-collection collection="${actionBean.bars}" value="id"
label="label" />

You need a special Formatter for your domain objects or you adjust your
toString() in these objects, I prefer the former (my domain objects all
extend BaseModel):


// other (empty) methods omitted

public String format(Object input) {
 return ((BaseModel) input).getId().toString();

Stripes is great! I knew there would be a way to do this in a simple and
elegant way! :)



Sebastian Beigel // Software Architekt
(F) Die Firma GmbH // Innovative Kommunikation
Schwalbacher Stra├če 74 // D-65183 Wiesbaden
T +49.6 11.2 38 50.24 // F +49.6 11.2 38 50.11
mailto:hidden //

This email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
Stripes-users mailing list