tags:

views:

1985

answers:

2
+4  Q: 

JSF A4j support

Hello everyone,

I'm having trouble with a JSF selectManyCheckbox and A4J support. The purpose is to run some action when a checkbox is selected. This works perfectly in 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. 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. So the problem is really in the ajax action (without submiting the form). 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>

Has anyone had this problem? Can anyone help me with this? Thank you

+1  A: 

I am surprised this even works in Firefox. Action methods don't support parameters. From the Richfaces docs:

signature must match java.lang.Object action()

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

Naganalf
It however does support it if you're using JBoss EL instead of standard EL.
BalusC
yeah, I'm using JBoss EL... can't figure this one out :/
GuilhermeA
+4  A: 

You should use either JBoss EL, or declare a JSF function. If you are using facelets, this is as easy as:

  • declare a public static method in a class of your preference
  • in a my.taglib.xml (facelets decriptor) add:
  • <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"
  • try 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 - i.e. action="#{cardListProvider.findCards}" and then in findCards() get this.cardListProvider.categoriesHolder.selectedCategories
  • try upgrading to richfaces 3.3.2.SR1
  • Bozho
    I'm using JBoss EL, my framework is Seam...
    GuilhermeA
    Then try "onchange" or better "onselect" rather than "onclick"
    Bozho
    Another event isn't going to help. Besides, in a checkbox/radiobutton you really want onclick instead of onchange.
    BalusC
    you're right BalusC, changing the event did not help me... thank you anyway Bozho! Any other idea?
    GuilhermeA
    Check firefox error console. And see if there is a JS error in IE.(P.S. I don't agree 'onclick' is preferable with radios/checkboxes)
    Bozho
    Did that and found no errors...
    GuilhermeA
    Try immediate="true" (to suppress validation problems)
    Bozho
    Bozho: in case of radios/checkboxes the change event is in certain browsers only fired if you click 2 times.
    BalusC
    tryed immediate="true" and didn't work :/
    GuilhermeA
    immediate="true" on the a4j:support , not on the h:select..
    Bozho
    immediate="true" on the a4j:support doesn't work even in firefox...
    GuilhermeA
    check my next suggestion :)
    Bozho
    yeah, I already tried it! The problem is that in IE, the setter of the selected elements (this.cardListProvider.categoriesHolder.selectedCategories) is not running! So, even if I do it the way you suggested, I get the same result! I would understand that I had something wrong in the whole mechanism if it wasn't working in Firefox but since it is I can't understand what I'm doing wrong!
    GuilhermeA
    which version of richfaces, btw. If not 3.3.2.SR1 , try upgrading to it.
    Bozho
    it's not the 3.3.2.SR1, it's the 3.3.1.GA. I cannot update, other colleagues depend on this version too.. But do you think the problem comes from richfaces? Isn't the JSF selectManyCheckbox control that is not setting the variable?
    GuilhermeA
    perhaps "not triggering the event". Which is fine with JSF alone, but breaks richfaces. btw, JSF RI or MyFaces?P.S. Upgrading is something that CAN be done within a team. Just agree on a time for the upgrade. In my team we have changed 2 versions of richfaces for tha past 4 months with no problems.
    Bozho
    It's not myfaces (don't know what JSF RI means). I've tried so many things and can't get this to work. It's very frustrating. Yeah, I will suggest we upgrade, we are overloaded with work this week so maybe next week! By the way, than you very much for the time you are spending helping me! Back to my bug... :/
    GuilhermeA
    Thank you very much Bozho! problem solved! ;)
    GuilhermeA
    How exactly? after an upgrade?
    Bozho
    No... stupid mistake... we made a huge redesign and during the process a colleague of mine included the form inside a form...We are including lots of .xhtml in others .xhtml so it was hard to notice! thank you very much! I can't understand why it worked in firefox! Thank you
    GuilhermeA