Why below works:
<h:form id="form1">
<p:carousel id="carousel" value="#{galleriaBean.paths_tn}" var="img" itemStyle="width: 200px">
<p:graphicImage value="#{img}"/>
</p:carousel>
<p:commandLink id="here" value="click me" update="hello11" oncomplete="dlg.show()">
<f:setPropertyActionListener value="hello!!!" target="#{galleriaBean.selected}"/>
</p:commandLink>
<p:dialog widgetVar="dlg">
<h:outputText id="hello11" value="#{galleriaBean.selected}"/>
</p:dialog>
</h:form>
But moving the commandLink into the carousel, it doesn’t work? setPropertyActionListener does not even set the variable in the bean.
@RequestScoped CDI Bean.
<p:carousel id="carousel" value="#{galleriaBean.paths_tn}" var="img" itemStyle="width: 200px">
<p:graphicImage value="#{img}"/>
<p:commandLink id="here" value="click me" update=":form1:hello11" oncomplete="dlg.show()">
<f:setPropertyActionListener value="#{img}" target="#{galleriaBean.selected}"/>
</p:commandLink>
</p:carousel>
You didn’t show second version of your code (when you put
p:commandLinkinsidep:carousel), but I suppose that you putted some property of backing bean insidevalueattribute ofp:commandLink. You must be aware that AJAX request is also request, so you request scoped bean is recreated in each AJAX request. To preserve state of property, which you are using forf:setPropertyActionListeneryou must make your bean at least view scoped, or somehow retain state in@PostConstructormethod. If you can use view scoped bean, that should be done.