having a bit of a spanner moment. I need to convert a List to String Array:
List<String> selectedIndicie to String[] targetIndices;
The selectedIndicie list is pulled from a backing bean and I attempt to convert it to a String array like so:
setTargetIndices(initialiseBean.getSelectedIndicie().toArray(getTargetIndices()));
But Java has a right old moan saying:
An error occurred performing resource injection on managed bean searchBean
As I said I am having a spanner moment on how else to convert the List of Strings to an array of String so any suggests would be lovely.
Cheers
List.toArrayreturns an array ofObjects, which is likely to result in an exception when you executesetTargetIndicesfor this method would be accepting an array ofStringobjects. The answer is to not convert the setter to accept an array ofObject(for the JSF runtime might simply fail to recognize the setter as belonging to thetargetIndicesproperty), rather it is to invoke the setter with an array of Strings.