在Primefaces中使用selectBooleanCheckbox禁用/启用inputText

时间:2018-06-26 18:18:16

标签: html jsf primefaces

嘿,当选择/未选择selectBooleanCheckbox时,尝试基于更改事件禁用/启用inputText。但是,当前,无论是否选中该复选框,inputText始终将被禁用。我是否需要将侦听器附加到复选框?在这种情况下,inputText似乎永远不会重新呈现。

HTML:

    def new
        @parent = Parent.new
        @parent.secondaryparents.build
        add_breadcrumb "Home", :root_path
        add_breadcrumb "Sign up"
    end

    def addusers
        @parent=Parent.new
    end

    def create_users
        @parent=Parent.new(parent_params)
        @parent.admin = true
        if @parent.save
            ParentMailer.registration_confirmation(@parent).deliver
            flash[:success] = "Please ask user to confirm email address to continue"
            redirect_to main_admin_path
        else
            flash[:danger] = "There was an error with registering. Try again"
            redirect_to main_admin_path
        end
    end

def create
        @parent = Parent.new(parent_params)
        if @parent.save
            ParentMailer.registration_confirmation(@parent).deliver
            flash[:success] = "Please confirm your email address to continue"
            redirect_to root_path(@parent)
        else
            flash[:danger] = "There was an error with registering. Try again"
            redirect_to signup_path
        end
    end

1 个答案:

答案 0 :(得分:0)

在PrimFaces 6.0、6.1和6.2上测试

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:p="http://primefaces.org/ui"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:fn="http://java.sun.com/jsp/jstl/functions">

<h:head>
    <title>PrimeFaces Test</title>

</h:head>
<h:body>
    <h:form>
        <div>
            <p:outputLabel for="@next" value="Additional Time: " />
            <p:selectBooleanCheckbox value="#{dialogView.additionalTime}">
                <p:ajax update="hour"></p:ajax>
            </p:selectBooleanCheckbox>
        </div>

        <div>
            <p:outputLabel for="hour" value="Hour:" />
            <p:inputText id="hour" value="#{dialogView.hour}" disabled="#{!dialogView.additionalTime}" label="Hour" />
        </div>
    </h:form>
</h:body>
</html>