{"id":1313,"date":"2011-04-12T15:28:08","date_gmt":"2011-04-12T15:28:08","guid":{"rendered":"http:\/\/salientsoft.co.uk\/?p=1313"},"modified":"2017-06-27T10:28:13","modified_gmt":"2017-06-27T10:28:13","slug":"action-retargetting-in-a-jsf-composite-component","status":"publish","type":"post","link":"https:\/\/salientsoft.co.uk\/?p=1313","title":{"rendered":"Action, Listener and Validator Retargeting in a JSF composite component"},"content":{"rendered":"<p><strong><span style=\"text-decoration: underline;\">Update 6\/7\/2011<\/span><\/strong><\/p>\n<p>There appear to be major issues with the design of retargeting when using it in nested composite components &#8211; it fundamentally does not work. See<strong> <a href=\"http:\/\/java.net\/jira\/browse\/JAVASERVERFACES_SPEC_PUBLIC-755\">this JSF JIRA issue here<\/a> <\/strong>for details on this. There is quite a robust debate in the comments on the post as to whether to deprecate and redesign retargeting completely, but it looks like that will not happen.<\/p>\n<p><strong><span style=\"text-decoration: underline;\">Original Post<\/span><\/strong><\/p>\n<p>This is very much an undocumented feature of JSF 2, but it is possible for the action method for a command component such as a button or link to be passed in to the CC by its client.<\/p>\n<p>You might think that you can just pass in a method expression string as an attribute and use that attribute within the CC on the action attribute of a button, but this fails as there is more that needs to go on behind the scenes. To make it work, you use the <em>targets=<\/em> attribute when declaring the <em>action<\/em> attribute on the CCs interface using <em>composite:attribute <\/em>\u2013 note that the attribute in the CC interface <strong>must <\/strong>be called <em>action. <\/em><\/p>\n<p>This is discussed in a comment (by Cay Horstmann no less) in <a href=\"http:\/\/stackoverflow.com\/questions\/2851708\/how-to-pass-a-action-string-into-a-jsf-2-composite-component\"><strong>this StackOverflow post here<\/strong><\/a>.<\/p>\n<p>Note that according to the<a title=\"http:\/\/javaserverfaces.java.net\/nonav\/docs\/2.0\/pdldocs\/facelets\/composite\/attribute.html\" href=\"http:\/\/javaserverfaces.java.net\/nonav\/docs\/2.0\/pdldocs\/facelets\/composite\/attribute.html\"><strong> link here from the above post<\/strong><\/a>, you can also retarget actionListeners, validators and valueChangeListeners in the same way. In these cases, the attribute name <strong>must<\/strong> be called <em>actionListener, validator or valueChangeListener<\/em> respectively in the same manner as is done with action above. Check the link out for full details &#8211; its not exactly clear on its own but it is easier to understand once you have the concepts from Cay Horstmann&#8217;s post above.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update 6\/7\/2011 There appear to be major issues with the design of retargeting when using it in nested composite components &#8211; it fundamentally does not work. See this JSF JIRA issue here for details on this. There is quite a robust debate in the comments on the post as to whether to deprecate and redesign [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[22],"tags":[40,181,184,16,15],"_links":{"self":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1313"}],"collection":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1313"}],"version-history":[{"count":8,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1313\/revisions"}],"predecessor-version":[{"id":2165,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1313\/revisions\/2165"}],"wp:attachment":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}