On 4/4/2018 7:20 PM, Nuno Oliveira wrote:
> Hi,
> 
> I am having problems populating an action variable Set by request using
> struts type conversion if the Set has the element type defined as an
> interface.
> I have a UserAction-conversion.properties file with the following
> configuration using the class implementation:
> 
> KeyProperty_roles=id
> Element_roles=path.to.class.Roles
> CreateIfNull_roles=true
> 
> And UserAction has the collection Set<RolesInterface>. Roles obviously
> implements RolesInterface.
> 
> If the Set element type <RolesInterface> is deleted it works just fine.
> Am I doing something wrong or is this not possible?

I reproduced it and seems it's because it tries to instantiate a new
element but the interface cannot being instantiated. Please see [1] to
know why it tries to instantiate interface instead of class.

Annotating the getRoles or setRoles method with @Element(value =
path.to.class.Roles.class) may fix this issue. (shouldn't it be
path.to.class.Role instead? it seems Roles is a list not element)

Regards.

[1]
https://github.com/apache/struts/blob/05829e3faadd15cfa67eb234cd1775f2b98918cb/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultObjectTypeDeterminer.java#L100

> 
> Thanks
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to