Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf f:setPropertyActionListener未调用方法_Jsf_Primefaces - Fatal编程技术网

Jsf f:setPropertyActionListener未调用方法

Jsf f:setPropertyActionListener未调用方法,jsf,primefaces,Jsf,Primefaces,我需要一些帮助。我在JSF上使用f:setPropertyActionListener时遇到问题。问题是JSF没有在目标方法上设置任何值 xhtml代码的一部分如下所示: <h:form> <fieldset style="width:100; margin-left: 350px; margin-top: 250px; position:absolute; border-style: none"> <p:dataGrid var="prod

我需要一些帮助。我在JSF上使用
f:setPropertyActionListener
时遇到问题。问题是JSF没有在目标方法上设置任何值

xhtml代码的一部分如下所示:

<h:form>
    <fieldset style="width:100; margin-left: 350px; margin-top: 250px; position:absolute; border-style: none">
        <p:dataGrid var="prod" value="#{productoController.arrProductosRelevantes}" 
                    columns="5" rows="10" paginator="true">

            <p:panel style="text-align:center">  
                <h:panelGrid columns="1" style="width:100%" columnClasses="colStyle1" rowClasses="rowStyle1" >  
                    <p:graphicImage value="#{prod.imagenUrl}" style="width:100px; height:100px"/>   
                    <h:outputText value="#{prod.marca}" style="width:40px"/>  
                    <p:commandLink value="Ver" action="#{productoController.visualizarProducto()}">  
                        <f:setPropertyActionListener value="#{prod}"   
                                                     target="#{productoController.productoSeleccionado()}" />  
                    </p:commandLink>
                </h:panelGrid>  
            </p:panel>  
        </p:dataGrid>  
    </fieldset>
</h:form>

支持bean如下(最相关):

public Producto getProductoSeleccionado(){
返回产品Seleccionado;
}
公共无效集合productoSeleccionado(Producto productoSeleccionado){
if(productoSeleccionado!=null){
this.productoSeleccionado=productoSeleccionado;
arrComentarios=null;
arrproductoscompletarios=null;
arrProductOSuplementarios=null;
}
}
公共字符串visualizarProducto(){
如果(arrComentarios==null){
obtenerComentarios();
}
if(arrProductOSComponentarios==null){
obtenerarrProductoscompletarios();
}
if(arrProductOSuplementarios==null){
obtenerarrProductOSuplementarios();
}
返回“visualizarProducto.xhtml?faces redirect=true”;
}
公共阵列列表GetArrProductosRelevants(){
返回相关产品;
}
公共无效获得者arroProductosRelevants(){
clienteDAO=新clienteDAO();
productoDAO=新的productoDAO();
cliente=clienteDAO.getClientePorId(Sesion.IDCLIENTE);
ArrProductosRelevants=productoDAO.obtenerProductor相关客户(客户);
}
顺便说一下,我正在使用@SessionScoped

感谢您的帮助。

f:setPropertyActionListener的target属性应该是属性,而不是方法。这意味着,如果设置
target=“#{productoController.productoSeleccionado}”
它将调用
productoController
bean中的
setProductoSeleccionado(Producto prod)
方法,将为value属性设置的值作为参数传递

您所指的是一个方法
productoSeleccionado()
,它甚至可能不存在于您的代码中。所以,只要去掉括号,你就会没事了:

<f:setPropertyActionListener value="#{prod}"
               target="#{productoController.productoSeleccionado}" />


实际上有一个名为setProductoSeleccionado()的方法,正如我之前在backbean代码中所示,即使去掉括号,它也不会设置产品。同样,我在其他JSF页面中也使用了该方法,但在这个页面中它不起作用。我知道setter在那里,但您没有提到它,您指的是
productoSeleccionado()
方法。现在,当你去掉括号时,setter确实被引用了,为什么它现在不工作,这可能是另一回事。你的bean是什么范围?那么你应该被设置。你能将问题中的代码更新为你现在正在使用的代码吗?我没有为我的特殊目的使用datagrid,而是将其更改为datatable,它工作得很好。谢谢你抽出时间
<f:setPropertyActionListener value="#{prod}"
               target="#{productoController.productoSeleccionado}" />