Seam:Richfaces h:selectManyCheckbox 无法获取选中值?

发布于 2024-11-05 12:56:40 字数 2080 浏览 0 评论 0原文

我正在 Seam 中使用丰富的面孔尝试做一件简单的事情。我正在显示来自 Ldap(组或角色)等其他来源的复选框列表,并且我想将选中的复选框保留到我自己的组表中,我将其称为配置文件。

现在我不擅长这个,为此我提前道歉。我正在使用 getLdapOrgs 方法中的操作从 ldap 加载配置文件,它返回 NGBProfiles 列表,检查的配置文件应传输到同一操作的 selectedNgbs。 selectedNgbs也是同一类型的List。该操作实现了 ValueChangeListener,因此我重写了一个 processValueChange 方法,该方法现在没有做太多事情,因为它永远不会在正确的时间被调用。

发生的情况是这样的:我加载页面,当我选择一个复选框时,页面会自行重新加载。支票不见了。并且保存按钮永远不会被调用..也不会调用 valuechangelistner ???唯一被调用的方法是 getChosenNgbs 方法。我们的 getLdapOrgs 方法可以正确从 ldap 加载角色。

我的操作类如下所示:

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(){

// 从 ldap 获取数据 xhtml

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());
}   

也非常简单。 (抱歉格式化,代码块不知何故无法工作。以前它确实有效......但现在不行。我无法)

h:selectManyCheckbox title="选择您想要查看的 NGB 类型" 布局=“pageDirection”值=“#{ngbProfileAction.chosenNgbs}”id=“selectBoxContainer”>valueChangeListener=“#{ngbProfileAction.processValueChange}”> label="#ngbProfile.name}"/>

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

/h:selectManyCheckbox>

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

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}" />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘初心 2024-11-12 12:56:40

您是否尝试过将 ajaxSingle="true" 添加到 a:support 中?

另外,对于复选框,我通常使用“onchange”事件

HTH

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

Also with Checkboxes i usually use the "onchange" event

HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文