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 h:SelectBoolean复选框valueChangeListener不工作_Jsf_Ajax4jsf - Fatal编程技术网

Jsf h:SelectBoolean复选框valueChangeListener不工作

Jsf h:SelectBoolean复选框valueChangeListener不工作,jsf,ajax4jsf,Jsf,Ajax4jsf,我正面临h:selectBooleanCheckbox的valueChangeListener的问题。我有以下代码块: <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"

我正面临
h:selectBooleanCheckbox
valueChangeListener
的问题。我有以下代码块:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">
    <link href="../css/profile.css" rel="stylesheet" type="text/css" />
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../css/twt.css" rel="stylesheet" type="text/css" /> 
    <script language="JavaScript" src="../js/custom-form-elements.js"></script>
    <a4j:form id="userList">
        <a4j:outputPanel id="userListPanel" rendered="#{popupController.iIndex >= 0}">          
            <div id="listPopup_#{popupController.iIndex}" 
                style="width: 202px; height: 235px; position: absolute; right: 0%; display: none; z-index: 10000; 
                background-image: url('../images/Alert/createNewListBack.gif'); background-repeat: no-repeat;">
                <table width="180" cellpadding="0" cellspacing="0" height="100%" style="margin-top: 6px; margin-left: 10px;">
                    <a4j:repeat id="userListRepeat" value="#{popupController.userList}" rowKeyVar="i" var="listByUser">
                        <tr>
                            <td valign="middle" align="center" width="35" style="padding-left: 8px;">                               
                                <h:selectBooleanCheckbox id="listCheckbox_#{i}" name="listCheckbox_#{i}"                                                                        
                                valueChangeListener="#{popupController.addUserListMember}" immediate="true">

                            </h:selectBooleanCheckbox>
                            </td>
                            <td valign="middle" align="left" class="alertSelect" width="145">
                                <div style="width: 170px; height: auto; word-wrap: break-word; white-space: pre-wrap;">
                                    <h:outputText style="padding-right: 8px;" value="#{listByUser.name}" />                                 
                                </div>                              
                            </td>
                        </tr>                                           
                    </a4j:repeat>                   
                </table>    
            </div>          
        </a4j:outputPanel>
    </a4j:form>

</ui:composition>
但是
valuechangelistner
不起作用。我不能使用
this.form.submit()
,因为它不适合代码。我使用的是JSF1.2


补救办法是什么?谢谢

valueChangeListener
不是客户端事件/事件。它完全是服务器端的。您应该在更改值后将表单提交到服务器端,以便调用它

由于您显然已经在使用Ajax4jsf,您可以添加一个


valueChangeListener
不是客户端事件/事件。它完全是服务器端的。您应该在更改值后将表单提交到服务器端,以便调用它

由于您显然已经在使用Ajax4jsf,您可以添加一个



您是否建议像这样使用它:
可能您的
popupController
bean是请求范围,并且
的数据模型没有正确地保存在bean的构造函数中。尝试将
添加到视图中,在
之后的某个位置。那么,这将是RichFaces/Ajax4jsf特有的。我不知道,因为我不完全熟悉RF 3.x。我将很快删除答案。类似的以rf4.x/jsf2.x为目标的构造会很好地工作。这是一个Bug吗?我的意思是我发现了各种各样的网站和论坛,其中讨论了许多与
h:selectBooleanCheckbox
valueChangeListener
相关的问题。这就是我问这个问题的原因。问题解决了。
h:selectBooleanCheckbox
位于中继器内,其值以前取自请求范围内的控制器,这就是为什么
actionlistener
在使用
a4j:commandLink
时未触发的原因。我将其更改为会话范围内的另一个控制器。行动开始了。但是
valueChangeListener
使用
触发相同方法三次。您能帮助我吗?您是否建议像这样使用它:
也许您的
popupController
bean是请求范围,并且
的数据模型没有正确地保存在bean的构造函数中。尝试将
添加到视图中,在
之后的某个位置。那么,这将是RichFaces/Ajax4jsf特有的。我不知道,因为我不完全熟悉RF 3.x。我将很快删除答案。类似的以rf4.x/jsf2.x为目标的构造会很好地工作。这是一个Bug吗?我的意思是我发现了各种各样的网站和论坛,其中讨论了许多与
h:selectBooleanCheckbox
valueChangeListener
相关的问题。这就是我问这个问题的原因。问题解决了。
h:selectBooleanCheckbox
位于中继器内,其值以前取自请求范围内的控制器,这就是为什么
actionlistener
在使用
a4j:commandLink
时未触发的原因。我将其更改为会话范围内的另一个控制器。行动开始了。但是
valueChangeListener
使用
触发相同方法三次。你能帮助我吗?
public void addUserListMember(ValueChangeEvent event) throws Exception {
    System.out.println("=========================== PopupController.addUserListMember() ==================");
    Boolean isChecked = (Boolean) event.getNewValue();
    if(isChecked) {
        System.out.println("===== Checked =====");                                              
    } else {
        System.out.println("===== Un Checked =====");
    }                
}
<h:selectBooleanCheckbox ...>
    <a4j:support event="onclick" reRender="someOtherComponentIfNecessary" />
</h:selectBooleanCheckbox>