简体   繁体   English

JSF a4j:支持h:selectManyCheckbox

[英]JSF a4j:support with h:selectManyCheckbox

I'm having trouble with a JSF selectManyCheckbox and A4J support. 我在使用JSF selectManyCheckbox和A4J支持时遇到了麻烦。 The purpose is to run some action when a checkbox is selected. 目的是在选中复选框时运行某些操作。 This works perfectly in Firefox. 这在Firefox中完美运行。 Yet, when testing in any IE (ie6 / ie7 / ie8), found out that the action was being called but the selected value was put to null. 然而,当在任何IE(ie6 / ie7 / ie8)中进行测试时,发现该动作被调用但所选值被置为空。 Just to test it, I placed a JSF commandButton to submit the form and to check the value that was selected and it was correct. 为了测试它,我放置了一个JSF commandButton来提交表单并检查所选的值并且它是正确的。 So the problem is really in the ajax action (without submiting the form). 所以问题实际上是在ajax动作中(没有提交表单)。 Here is my code: 这是我的代码:

        <h:selectManyCheckbox id="supportCategoryCardFilter" value="#{cardListProvider.categoriesHolder.selectedCategories}"  layout="pageDirection" required="false" >
            <f:selectItems value="#{cardListProvider.categoriesList}" />
            <a:support ajaxSingle="true" status="statusSearchCard" id="supportCategoryCardFilter2" event="onclick" reRender="cardsHolder, renderCardsCategoriesPanel" 
                 action="#{cardListProvider.findCards(cardListProvider.categoriesHolder.selectedCategories)}"  >
            </a:support>
        </h:selectManyCheckbox>

where cardListProvider.categoriesList is a List<SelectItem> and cardListProvider.categoriesHolder.selectedCategories is a List<String> 其中cardListProvider.categoriesListList<SelectItem>cardListProvider.categoriesHolder.selectedCategoriesList<String>

Has anyone had this problem? 有谁有这个问题? Can anyone help me with this? 谁能帮我这个? Thank you 谢谢

You should use either JBoss EL, or declare a JSF function. 您应该使用JBoss EL,或声明JSF函数。 If you are using facelets, this is as easy as: 如果您使用facelets,这很简单:

  • declare a public static method in a class of your preference 在您偏好的类中声明一个public static方法
  • in a my.taglib.xml (facelets decriptor) add: 在my.taglib.xml(facelets decriptor)中添加:
  • <function>
        <function-name>concat</function-name>
        <function-class>com.mycompany.myproject.ServiceFunctions</function-class>
        <function-signature>java.lang.String concat(java.lang.String, java.lang.String)   </function-signature>
    </function>
    

  • Also, try setting the event to "onselect" (or "onchange") rather than "onclick" 另外,尝试将事件设置为“onselect”(或“onchange”)而不是“onclick”
  • try seting immediate="true" 尝试seting immediate =“true”
  • try removing the method parameter - you don't need it, since you can access it via the property of the managed bean - ie action="#{cardListProvider.findCards}" and then in findCards() get this.cardListProvider.categoriesHolder.selectedCategories 尝试删除方法参数 - 您不需要它,因为您可以通过托管bean的属性访问它 - 即action="#{cardListProvider.findCards}"然后在findCards()获取this.cardListProvider.categoriesHolder.selectedCategories
  • try upgrading to richfaces 3.3.2.SR1 尝试升级到richfaces 3.3.2.SR1
  • I am surprised this even works in Firefox. 我很惊讶这甚至适用于Firefox。 Action methods don't support parameters. 操作方法不支持参数。 From the Richfaces docs: 来自Richfaces文档:

    signature must match java.lang.Object action()

    http://livedemo.exadel.com/richfaces-demo/richfaces/support.jsf?tab=info&cid=1615759 http://livedemo.exadel.com/richfaces-demo/richfaces/support.jsf?tab=info&cid=1615759

    声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM