I think that's for indexed properties.. For OneToManyTypeConverter, you can override getCollectionInstance() to use the Collection implementation that you want.
Cheers, Freddy http://www.stripesbook.com On Thu, 2 Oct 2008 15:13:29 -0400, "Poitras Christian" <[EMAIL PROTECTED]> said: > Could this be because you use set instead of list? > Stripes is not supposed to support set... > > Christian > > ________________________________ > From: Newman, John W [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 02, 2008 2:13 PM > To: Stripes Users List > Subject: Re: [Stripes-users] Collections, textareas, > OneToManyTypeConverter, and no possiblitity of inverse formatting > > Well I went into InputTextAreaTag and changed > > // Find out if we have a value from the PopulationStrategy > Object value = getSingleOverrideValue(); > To > Object value = getOverrideValueOrValues(); > > And my formatter is getting called and I see a nice comma delimited set > of codes in the text area! So my question for the devs is can we do > something differently here? > > getSingleOverrideValue() is used by the text, textarea, and radio button > tags. All it really does differently is return the first element in the > case of arrays/collections, which seems totally unexpected to me. Can we > provide a default array/collection formatter and eliminate that method? > Or am I not seeing a legitimate reason for why this happens? > > Thanks, > John > > From: Newman, John W [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 02, 2008 12:36 PM > To: [email protected] > Subject: [Stripes-users] Collections, textareas, OneToManyTypeConverter, > and no possiblitity of inverse formatting > > Hi, > > One of the requirements of the app I'm currently working on is to enter > comma delimited codes into a text area. I found the useful > OneToManyTypeConverter, which transparently allows my bean to use a > Set<String>, while the user enters a delimited string. > > @Validate(converter=OneToManyTypeConverter.class) > Set<String> codes; > > <stripes:textarea name="codes">1234, 2346, 2345</stripes:textarea> > > That's pretty decent, but when the user goes to edit to set I just saved > for them, the population strategy doesn't provide a delimited string into > the text area. I initially figured it was due to the formatter factory > not having an inverse formatter, so I wrote my own OneToManyFormatter > that loops over the collection and builds a string. I subclassed > formatter factory, added this thing in there, but it never gets called. > What's odd is the first item in the set does show up in the text area as > a string. > > So I went digging through the code, and I found > > InputTextAreaTag: > @Override > public int doEndInputTag() throws JspException { > try { > // Find out if we have a value from the PopulationStrategy > Object value = getSingleOverrideValue(); > > InputTagSupport: > protected Object getSingleOverrideValue() throws StripesJspException { > Object unknown = getOverrideValueOrValues(); > Object returnValue = null; > > if (unknown != null && unknown.getClass().isArray()) { > if (Array.getLength(unknown) > 0) { > returnValue = Array.get(unknown, 0); > } > } > else if (unknown != null && unknown instanceof Collection) { > Collection<?> collection = (Collection<?>) unknown; > if (collection.size() > 0) { > returnValue = collection.iterator().next(); > } > } > else { > returnValue = unknown; > } > > return returnValue; > } > > So if a text area is trying to populate with a collection, all I can > potentially format is collection.iterator().next(); the formatter > factory never gets asked for the set formatter. The javadoc states: > > "This can be used to ensure that > * only a single value is returned by the population strategy, which > is useful in the case > * of text inputs etc. which can have only a single value." > > Right, but it doesn't allow the possibility of multiple values being > later formatted into a single one. I don't think this is ideal behavior. > Thoughts? > > Thanks, > John ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Stripes-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/stripes-users
