Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<f:setPropertyActionListener> Parent is not of type ActionSource, type is: com.sun.faces.component.PassthroughElement

I'm using Passthrough elements in my JSF project, and need to do something similar to this:

<h:commandLink action="#{myBean.acao()}" value="click me">
        <f:setPropertyActionListener target="#{myBean.object}" value="#{localObject}"/>
</h:commandLink>

but using Passthrough elements to have more control of my frontend like trying below:

<a href="#" jsf:action="#{myBean.acao()}">click me
        <f:setPropertyActionListener target="#{myBean.object}" value="#{localObject}"/>
</a>

but apparently this is not working, I get the following error message:

<f:setPropertyActionListener> Parent is not of type ActionSource, type is: com.sun.faces.component.PassthroughElement

Does anyone know how I could solve this?

like image 953
Walter Gandarella Avatar asked Oct 18 '22 20:10

Walter Gandarella


1 Answers

Looks like just a bug in your Mojarra version. It works for me with current latest 2.2.12 version.

You could workaround it by utilizing the EL 2.2 feature of passing method arguments. See also Invoke direct methods or methods with arguments / variables / parameters in EL. It's surely available in your environment as #{myBean.acao()} apparently didn't throw an EL exception (this syntax is not supported before EL 2.2).

<a href="#" jsf:action="#{myBean.acao(localObject)}">click me</a>

If you absolutely need to invoke a setter during an action listener event, e.g. because you'd like to control the invocation of action by throwing AbortProcessingException in case the set value is invalid, see also Differences between action and actionListener, then declare a jsf:actionListener.

<a href="#" jsf:actionListener="#{myBean.setObject(localObject)}" jsf:action="#{myBean.acao}">click me</a>
like image 165
BalusC Avatar answered Jan 04 '23 06:01

BalusC