原來,faces-config.xml重寫了我的Controller類中的inline註釋ViewScoped w/RequestScoped。修正了它,似乎解決了這個問題。未調用Bean方法
這個問題沒有答案在這裏commandButton/commandLink/ajax action/listener method not invoked or input value not updated,如果你想這樣做,請使用primefaces fluidGrid擴展提供一個工作修復/例子。
我使用primefaces UI exension fluidGrid:http://fractalsoft.net/primeext-showcase-mojarra/sections/fluidgrid/dynamic.jsf
我似乎無法調用profileController.testControl(),如果我把命令按鈕的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("---------------------------------------");
}
}
可能重複[h:commandLink/h:commandButton未被調用](http://stackoverflow.com/questions/2118656/hcommandlink-hcommandbutton-is-not-being-invoked) –
@LuiggiMendoza其中之一列出的問題會是? – Fabii
從你的代碼,我不能確定。 –