开发者

Seam: Richfaces h:selectManyCheckbox cannot get checked values?

I am trying a simple thing in Seam using rich faces. i am displaying a list of checkboxes from another source like Ldap (groups or roles) and I want to persist the checked ones to my own table for groups, which i call profiles.

now i am not good at this for Which I apologize in advance. I am using an action to load the profiles from the ldap in getLdapOrgs method it returns a List of NGBProfiles the ones checked should be transfered to chosenNgbs of the same action. chosenNgbs开发者_运维问答 are also the same type of List. the action implements ValueChangeListener so I have a processValueChange method overriden which doesnt do much right now cos It never gets called at the right time.

What happens is this: I load the page and when i select a check box the page reloads itself. and the check is gone. and the save button is never called.. Nor the valuchangelistner??? the only method that does get called is the getChosenNgbs method. and the getLdapOrgs method ofourse loads the roles from the ldap correctly.

my action class looks like this:

public void processValueChange(ValueChangeEvent arg0)
        throws AbortProcessingException {
    // TODO Auto-generated method stub
    System.out.println("in alue chaneg listener");
     if (getChosenNgbs() != null) {
            System.out.println(getChosenNgbs().size());
        }

}

public void setChosenNgbs(List<NotifyingBodyProfile> chosenNgbs) {
    this.chosenNgbs = chosenNgbs;
    for(NotifyingBodyProfile chosenNgb : chosenNgbs){
        entityManager.persist(chosenNgb);           
    }
}




public List<NotifyingBodyProfile> getChosenNgbs() {
    return chosenNgbs;
}

public List<NotifyingBodyProfile> getLdapOrgs(){

//get data from ldap }

public  List<NotifyingBodyProfile>  getchosenNgbsfromDB(){

    List<NotifyingBodyProfile> chosenNgbsList= entityManager.createQuery("from NotifyingBodyProfile").getResultList();

    return chosenNgbsList;


}

public void save(){
    System.out.print("size of chosen Ngbs on save" + this.chosenNgbs.size());
}   

the xhtml is pretty straight forward as well. (sorry for formatting, code block was somehow not working. previously it did work... but now its not. I am not able to)

h:selectManyCheckbox title="Select which types of NGBs you want to see" layout="pageDirection" value="#{ngbProfileAction.chosenNgbs}" id="selectBoxContainer" >valueChangeListener="#{ngbProfileAction.processValueChange}" > label="#ngbProfile.name}"/>

a:support event="onclick" reRender="selectBoxContainer"/>

/h:selectManyCheckbox>

h:commandButton value="Save " action="#{ngbProfileAction.save}" />


Have you tried to add ajaxSingle="true" to a:support?

Also with Checkboxes i usually use the "onchange" event

HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜