struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Koenig <scott.l.koe...@gmail.com>
Subject using a custom Converter for elements of a Collection
Date Wed, 12 Jan 2011 21:43:48 GMT
Hello,

In my company's internal CMS, we are implementing two new asset types,
Videos and Playlists (collections of Videos). In the Video UI, the user
designates which Playlists are to be associated with a given Video, and
these values are posted on save via an array called "playlists" which
contains the UIDs of each Playlist. These are represented as an
ArrayList<Playlist> in the Video POJO.

We have implemented a PlaylistConverter to convert each String UID to a
Playlist instance (and back), and going off of
http://struts.apache.org/2.1.8/docs/type-conversion.html#TypeConversion-CollectionandMapSupport,
added Element_playlists=[converterpackage].PlaylistConverter to
Video-conversion.properties.

Save was not committing and there seemed to be some conversion error, so I
stepped through the conversion process to try and determine what was going
wrong. Everything seems to be fine at the Collection level; it properly
determines that the toType of the collection is List and the memberType is
Playlist. However, when XWorkConverter.getConverter() tries to find the
converter for the individual members, even though Element_playlists=class
[converterpackage].PlaylistConverter is present in the mappings, the
property String passed in is still "playlists" instead of
"Element_playlists" and thus it does not hook up the playlist ID with the
converter and falls back to the default converter (which cannot handle it
and is what is raising the error).

Any guidance as to what could be going wrong here would be greatly
appreciated.

Thank you very much,
~~Scott


PS--If it's useful, our system depends on the following libraries:

ognl-3.0.jar
struts2-core-2.1.8.1.jar
xwork-core-2.1.6.jar

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message