JSF: use <f:setPropertyActionListener /> inside a graphicImage

Viewed 33

Every time I try to use "setPropertyActionListener" inside an graphicImage, this shows up: Error Message

<h:graphicImage value="/images/h.png">
     <f:setPropertyActionListener target="#{pokemonController.haarfarbe}" value="h" />
</h:graphicImage>
            

Does it only work with commandButtons?

EDIT: correct way:

<h:commandLink action="Augenfarbe.xhtml">
      <h:graphicImage value="/images/h.png" />             
      <f:setPropertyActionListener target="#{pokemonController.hautfarbe}" value="h" />
</h:commandLink>
            
1 Answers

Quite true, the image ui element in JSF is only a box for a graphic. The JSF ui component must implement ActionSource interface in its hierarchy to bind an event. Also, command button elements do not tend to operate unless inside a jsf form element. You can wrap a commandButton around the image.

Related