JSF Primefaces无法重新启用单选按钮

JSF Primefaces无法重新启用单选按钮,jsf,primefaces,Jsf,Primefaces,我有以下非常简单的页面,包含两个selectoneradio组,它们使用PF 5、netbeans和glassfish。我检查了几个浏览器,结果是一样的 第一个控制另一个。当我更改choice1时,我可以看到choice2中的按钮如我所料被禁用和启用 当页面“刷新”时,我可以切换选项2中的值。但当我第一次更改choice1中的值导致choice2更改时,它仍然无法访问 谁能向我解释一下原因吗?我想我读到一个复选框有同样的问题,这是因为你看到的不是控件,而是一个图像。但我再也找不到那个信息了 守则

我有以下非常简单的页面,包含两个selectoneradio组,它们使用PF 5、netbeans和glassfish。我检查了几个浏览器,结果是一样的

第一个控制另一个。当我更改choice1时,我可以看到choice2中的按钮如我所料被禁用和启用

当页面“刷新”时,我可以切换选项2中的值。但当我第一次更改choice1中的值导致choice2更改时,它仍然无法访问

谁能向我解释一下原因吗?我想我读到一个复选框有同样的问题,这是因为你看到的不是控件,而是一个图像。但我再也找不到那个信息了

守则:

我的页面:

希望有人能帮忙

提前谢谢

Kim

这里有一个解决方案

或者,如果不想更新表单,可以将和组包装在一个内,然后只更新该面板

像这样:

<h:form id="prodForm" prependId="false">
        <p:selectOneRadio valueChangeListener="#{myBean.doSomething()}" id="choice1"  value="#{myBean.firstChoice}" >
            <f:selectItem itemLabel="0 choice" itemValue="0" />
            <f:selectItem itemLabel="1 choice" itemValue="1" />
            <f:selectItem itemLabel="2 choice" itemValue="2" />
            <f:selectItem itemLabel="3 choice" itemValue="3" />
            <f:selectItem itemLabel="4 choice" itemValue="4" />
            <f:selectItem itemLabel="5 choice" itemValue="5" />
            <p:ajax   update="choice2panel"  />
        </p:selectOneRadio>
        <h3>Choice 2</h3>
        <p:outputPanel  id="choice2panel">
        <p:selectOneRadio immediate="true" id="choice2" value="#{myBean.secondChoice}" layout="custom" >
            <f:selectItem itemLabel="Choice 2 0" itemValue="0" />
            <f:selectItem itemLabel="Choice 2 1" itemValue="1" />
            <f:selectItem itemLabel="Choice 2 2" itemValue="2" />
            <f:selectItem itemLabel="Choice 2 3" itemValue="3" />
        </p:selectOneRadio>
        <p:radioButton  id="ch2Id0" for="choice2" itemIndex="0" disabled="#{myBean.firstChoice lt 1}" />
        <h:outputLabel id="l0" for="ch2Id0" value="Choice 2 0" /><br/>
        <p:radioButton  id="ch2Id1" for="choice2" itemIndex="1" disabled="#{myBean.firstChoice lt 3}" />
        <h:outputLabel id="l1" for="ch2Id1" value="Choice 2 1" /><br/>
        <p:radioButton id="ch2Id2" for="choice2" itemIndex="2" disabled="#{myBean.firstChoice lt 4}" />
        <h:outputLabel id="l2" for="ch2Id2" value="Choice 2 2" /><br/>
        <p:radioButton id="ch2Id3" for="choice2" itemIndex="3" disabled="#{myBean.firstChoice lt 5}" />
        <h:outputLabel id="l3" for="ch2Id3" value="Choice 2 3" /><br/>
        </p:outputPanel>
    </h:form>

使用,而不是仅仅感谢你的努力,但这并不能解决我的问题。对不起,但我确实不能弄清楚你的问题是什么!非常感谢,这个小细节似乎解决了我的问题。
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;

@ManagedBean(name = "myBean")
@SessionScoped
public class MyBean implements Serializable {
Integer firstChoice = 5;
Integer secondChoice = 0;

public void doSomething(){
    System.out.println("In doSomething");
}


public Integer getFirstChoice() {
    return firstChoice;
}
public void setFirstChoice(Integer firstChoice) {
    this.firstChoice = firstChoice;
}
public Integer getSecondChoice() {
    return secondChoice;
}
public void setSecondChoice(Integer secondChoice) {
    this.secondChoice = secondChoice;
}
}
<h:form id="prodForm" prependId="false">
        <p:selectOneRadio valueChangeListener="#{myBean.doSomething()}" id="choice1"  value="#{myBean.firstChoice}" >
            <f:selectItem itemLabel="0 choice" itemValue="0" />
            <f:selectItem itemLabel="1 choice" itemValue="1" />
            <f:selectItem itemLabel="2 choice" itemValue="2" />
            <f:selectItem itemLabel="3 choice" itemValue="3" />
            <f:selectItem itemLabel="4 choice" itemValue="4" />
            <f:selectItem itemLabel="5 choice" itemValue="5" />
            <p:ajax   update="choice2panel"  />
        </p:selectOneRadio>
        <h3>Choice 2</h3>
        <p:outputPanel  id="choice2panel">
        <p:selectOneRadio immediate="true" id="choice2" value="#{myBean.secondChoice}" layout="custom" >
            <f:selectItem itemLabel="Choice 2 0" itemValue="0" />
            <f:selectItem itemLabel="Choice 2 1" itemValue="1" />
            <f:selectItem itemLabel="Choice 2 2" itemValue="2" />
            <f:selectItem itemLabel="Choice 2 3" itemValue="3" />
        </p:selectOneRadio>
        <p:radioButton  id="ch2Id0" for="choice2" itemIndex="0" disabled="#{myBean.firstChoice lt 1}" />
        <h:outputLabel id="l0" for="ch2Id0" value="Choice 2 0" /><br/>
        <p:radioButton  id="ch2Id1" for="choice2" itemIndex="1" disabled="#{myBean.firstChoice lt 3}" />
        <h:outputLabel id="l1" for="ch2Id1" value="Choice 2 1" /><br/>
        <p:radioButton id="ch2Id2" for="choice2" itemIndex="2" disabled="#{myBean.firstChoice lt 4}" />
        <h:outputLabel id="l2" for="ch2Id2" value="Choice 2 2" /><br/>
        <p:radioButton id="ch2Id3" for="choice2" itemIndex="3" disabled="#{myBean.firstChoice lt 5}" />
        <h:outputLabel id="l3" for="ch2Id3" value="Choice 2 3" /><br/>
        </p:outputPanel>
    </h:form>