0

Is there a way to pass an bean action as attribute of a custom tag which is inside ui:repeat of my JSF 2.2 page?

<ui:repeat value="#{list}" var="item">
    <custom:component action="#{abean.method}" id="#{item.id}"/>
</ui:repeat>

and then inside of custom tag :

<h:form>
    #{id}
    <h:commandButton value="say hi" action="#{action}"/>
</h:form>

This will give the error message :

action="#{action}": Identity 'action' was null and was unable to invoke

The id shows up, so if I understand correctly , my custom component is added once during the build time, then during the render time the component is being recycled for each item (thus assigning the correct id). However why action isn't interpreted as a parameter is beyond me and I'd like some clarification as to why. Is it I can only pass strings ?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Ced
  • 15,847
  • 14
  • 87
  • 146
  • Even outside `` it won't work. Or does it really? If so which JSF impl/version? – BalusC Mar 21 '16 at 08:42
  • @BalusC Well, it works somewhere else in my code but I did it a bit differently. I gave the bean as argument to my custom tag, I also gave the parameter of the method as arg (which is an object) and I had multiple bean with the same method name, so I could call the bean arg in the custom tag with the proper method parameters. The method itself was hardcoded. (I doubt I'm making lots of sens lol). I guess the process is just different then and it just override the param with the string which is then evaluated by EL. It's on mojarra 2.2.12 – Ced Mar 21 '16 at 15:04
  • And this was made about a year ago when I started jsf and programing altogether so I didn't know about composite components, I went some length to make it work in a custom tag and never had the need to come back to my custom tags... I don't know why I'm justifiing myself right now – Ced Mar 21 '16 at 15:10
  • It's not the same as you did here. See duplicate. By the way, custom tag != composite component != custom component. For concrete examples and the difference, head to http://stackoverflow.com/q/6822000 – BalusC Mar 21 '16 at 15:10
  • @BalusC Isn't what you wrote in the duplicate exactly like this (except this use custom tag)? http://www.icesoft.org/JForum/posts/list/17830.page#sthash.70GMZziX.dpbs (the first answer). – Ced Mar 21 '16 at 15:20

0 Answers0