0

我有我认为是一些简单的代码:

<ui:composition template="/templates/webflow.xhtml"
            xmlns="http://www.w3.org/1999/xhtml"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:p="http://primefaces.org/ui"
            xmlns:f="http://java.sun.com/jsf/core">

<ui:define name="flowTitle">Page One</ui:define>
<ui:define name="pageTitle">Page 1 of 5: Please select a type</ui:define>

<ui:define name="content">
    <h:form id="page1Form">
        <div class="flow_main">
            <div class="controls">
                <p:selectOneRadio id="customRadio" value="#{flowState.selectedOption}" layout="custom">
                    <f:selectItem itemValue="-1" />
                    <f:selectItem itemValue="1" />
                    <f:selectItem itemValue="2" />
                    <f:selectItem itemValue="3" />
                    <f:selectItem itemValue="4" />
                    <f:selectItem itemValue="5" />
                    <f:selectItem itemValue="6" />
                </p:selectOneRadio>

                <!-- these to go into a datatable -->
                <p:radioButton id="opt2" for=":page1Form:customRadio" itemIndex="1"/>
                <p:radioButton id="opt3" for=":page1Form:customRadio" itemIndex="2"/>
                <p:radioButton id="opt4" for=":page1Form:customRadio" itemIndex="3"/>
                <p:radioButton id="opt5" for=":page1Form:customRadio" itemIndex="4"/>
                <p:radioButton id="opt6" for=":page1Form:customRadio" itemIndex="5"/>
                <p:radioButton id="opt1" for=":page1Form:customRadio" itemIndex="6"/>

            </div>
        </div>
        <div style="text-align:right" class="flow_footer" >
            <p:commandButton id="cancel" value="Cancel" ajax="true" action="cancel" onsuccess="javascript:parent.dlg.hide();"/>
            <p:commandButton id="next" action="next" value="Next" onclick="return validate(1)" update="@form" />
        </div>
    </h:form>
</ui:define>

但是,在渲染时,底部的 3 个单选按钮被禁用。我尝试更改几乎所有属性以使其启用,但无济于事。

我设法使它们启用的唯一方法是添加以下行:

<h:inputHidden value="#{flowState.selectedOption}" id="hiddenId" />

即使这样也不能完全奏效;选择一个单选按钮并转到下一页正确绑定。但是,当我返回一个页面时,单选按钮再次被禁用!

4

1 回答 1

0

以防万一它对其他人有用,我的单选按钮被禁用的原因是由于看似不相关的代码部分引发了 javascript 错误:

<ui:define name="content">
    <script>
        jQuery(document).ready(function() {
            var selected = document.getElementById("page1Form:hiddenId").value;
            if(selected != -1) {
                document.getElementById("page1Form:typeTable:" + selected + ":chkType").checked = true;
            }
        });
    </script>
于 2013-06-11T08:55:58.053 回答