2013/10/16 Umesh Awasthi <[email protected]>:
> I am trying to inject few values to my bean like
>
> @Inject
> public
> DefaultJSR303ValidationManager(@Inject(value=ValidatorConstants.PROVIDER_CLASS,required=false)
> String providerClassName,
>
> @Inject(value=ValidatorConstants.IGNORE_XMLCONFIGURAITION,required=false)
> boolean ignoreXMLConfiguration
> )
> {
> // some code
> }
>
>
> Entries from struts-plugin.xml
>
> <constant name="providerClass" value=""/>
> <constant name="ignoreXMLConfiguration" value="false"/>
>
> but i am getting following exception
>
> Caused by:
> com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No
> mapping found for dependency [type=boolean, name='ignoreXMLConfiguration']
>
> how ever if i change it to
> @Inject
> public
> DefaultJSR303ValidationManager(@Inject(value=ValidatorConstants.PROVIDER_CLASS,required=false)
> String providerClassName
> )
> {
> }
>
> @Inject(value=ValidatorConstants.IGNORE_XMLCONFIGURAITION,required=false)
> public void setIgnoreXMLConfiguration( boolean ignoreXMLConfiguration )
> {
> this.ignoreXMLConfiguration = ignoreXMLConfiguration;
> }
>
> everything is working fine and dependencies are being injected correctly.
> I am not sure if where i am doing wrong ?
> can't i have multiple @inject inside constructor?
<constant/> defines String not boolean, try something like this:
@Inject
public
DefaultJSR303ValidationManager(@Inject(value=ValidatorConstants.PROVIDER_CLASS,required=false)
String providerClassName,
@Inject(value=ValidatorConstants.IGNORE_XMLCONFIGURAITION,required=false)
String ignoreXMLConfiguration) {
this. ignoreXMLConfiguration =
"true".equalsIgnoreCase(ignoreXMLConfiguration);
}
Regards
--
Ćukasz
+ 48 606 323 122 http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]