<f:setPropertyActionListener> Parent is not of type ActionSource

8.1k Views Asked by At

I would like to pass value when I click on a table row:

<h:outputLink id="lnkHidden" value="DatacenterProfile.html" style="text-decoration:none; color:white;">
    <f:setPropertyActionListener target="#{DatacentersController.selectedId}" value="#{item.componentStatsId}" />
</h:outputLink>

I get this error:

<f:setPropertyActionListener> Parent is not of type ActionSource, type is: javax.faces.component.html.HtmlOutputLink@aa25b91

Is there any appropriate JSF tag which can be used to replace <h:outputLink>?

3

There are 3 best solutions below

0
On

In addition to @BalusC answer. I have used something like this in my project.

<h:commandButton 
       id="" 
       styleClass="" 
       type="submit" 
       rendered="#{}" 
       value="#{}" 
       action="#{}"> 
       <f:setPropertyActionListener target="#{}" value="#{}" /> 
</h:commandButton>

You can pass/use attributes based on your scenarios.

2
On

The f:setPropertyActionLister only works for ActionSource components like h:commandLink and h:commandButton. You should use one of these if you want to do it that way. See also

0
On

Do you want your URL (href) to be conserved, or do you just want it to act like a button ?

  1. If you want the URL to be conserved (with, obviously its params, so you can open it in other tabs etc...), just use f:param instead of f:setPropertyActionLister.
  2. If losing URL display (no meaningful url is displayed), you can use as Chkal said, commandButton or commndLink