jsf 2.2 - Is the class extending ClientBehaviorBase can be considered as an injection target? -
the bean defined simple follows:
@named @requestscoped public class confirmbean { private string confirmmsg; public confirmbean(){ confirmmsg = "are sure want delete file ?"; } // getters & setters }
and class inheriting clientbehaviorbase
@facesbehavior(value = "confirm") public class confirmdeletebehavior extends clientbehaviorbase { @inject confirmbean confirmbean; //@inject //confirmejbbean confirmejbbean; //@ejb //confirmejbbean confirmejbbean; @override public string getscript(clientbehaviorcontext behaviorcontext) { return "return confirm('"+confirmbean.getconfirmmsg()+"');"; } }
with taglib file-
<namespace>http://www.custom.tags/jsf/delete</namespace> <tag> <tag-name>confirmdelete</tag-name> <behavior> <behavior-id>confirm</behavior-id> </behavior> </tag>
with entry context-param
in web.xml
-
<context-param> <param-name>javax.faces.facelets_libraries</param-name> <param-value>/web-inf/taglib/delete.taglib.xml</param-value> </context-param>
and accessing custom tag in front layer-
<h:form> <h:commandbutton value="delete" action="done"> <b:confirmdelete/> </h:commandbutton> </h:form>
i using glassfish
application server 4.1.1
mojarra 2.2.12
version being used internally.
i got npe
here-
it's not extending class makes not eligable injection @facesbehaviour
annotation not make target of injection. little googling told me this: in jsf 2.2 not target injection, in 2.3 is.
omnifaces added support injection in facesconverters , facesvalidators used jsf 2.2 not facesbehaviour.
see also:
Comments
Post a Comment