结果是 faces-config.xml 覆盖了带有 RequestScoped 的 Controller 类中的内联注释 ViewScoped。修复了它,这似乎解决了问题。
这个问题在这里没有答案 commandButton/commandLink/ajax action/listener 方法没有被调用或输入值没有更新,如果你认为是这样,请提供一个使用 primefaces fluidGrid 扩展的工作修复/示例。
我正在使用 primefaces ui exension fluidGrid:http ://fractalsoft.net/primeext-showcase-mojarra/sections/fluidgrid/dynamic.jsf
我似乎无法调用 profileController.testControl() ,如果我将 commandButton 放在 fluidGrid 之外,它工作正常,但不在网格内。有任何想法吗?
我已经通过将我的 bean 更改为 @ViewScoped 进行了测试,没有嵌套表单等。
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="resultList" />
</composite:interface>
<composite:implementation>
<h:form id="form1" rendered="true">
<!-- Grid -->
<pe:fluidGrid value="#{resultList}" var="showvar" hGutter="20" rowKeyVar="rowKey" fitWidth="true" hasImages="true" rendered="true" >
<pe:fluidGridItem rendered="true" >
<p:panel id="seriesPanel" rendered="#{showvar.isSeries()}"></p:panel>
<p:panel id="episodePanel" rendered="#{!showvar.isSeries()}" >
<p:commandButton value="click me" action="#{profileController.testControl()}"/>
<!-- another button attempt that doesn't work -->
<p:commandButton process="fluidGrid" value="click me again" ajax="false" actionListener="#{profileController.testControlEvent()}" />
</p:panel>
</pe:fluidGridItem>
</pe:fluidGrid>
</h:form>
</composite:implementation>
</html>
//Tried with @ViewScoped as well
@Model
public class ProfileController {
public void testControl(){
log.info("---------------------------------------");
log.info("TEST CONTROL CLICKED");
log.info("---------------------------------------");
}
public void testControlEvent(ActionEvent actionEvent){
log.info("---------------------------------------");
log.info("TEST CONTROL CLICKED");
log.info("---------------------------------------");
}
}