属性 'isPermutation' 未在 jsf 中找到

Property 'isPermutation' not found in jsf

我试图从 xhtml page.But 为 bean 设置一个值,每次 运行 页面显示错误 属性 而不是 found.I 添加了属性 在 bean.I 中多次清理和构建项目。但没有任何效果请帮帮我。

豆子

 package com.loteria.controller;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;


@SuppressWarnings("serial")
@ManagedBean(name="userDraw")
@RequestScoped
public class UserDrawController implements Serializable {

    boolean isPermutation;
    boolean isCombination;
    boolean isBoth;
    long per_amount;
    long per_num;
    long com_num;
    long com_amount;
    public boolean isPermutation() {
        return isPermutation;
    }
    public void setPermutation(boolean isPermutation) {
        this.isPermutation = isPermutation;
    }
    public boolean isCombination() {
        return isCombination;
    }
    public void setCombination(boolean isCombination) {
        this.isCombination = isCombination;
    }
    public boolean isBoth() {
        return isBoth;
    }
    public void setBoth(boolean isBoth) {
        this.isBoth = isBoth;
    }
    public long getPer_amount() {
        return per_amount;
    }
    public void setPer_amount(long per_amount) {
        this.per_amount = per_amount;
    }
    public long getPer_num() {
        return per_num;
    }
    public void setPer_num(long per_num) {
        this.per_num = per_num;
    }
    public long getCom_num() {
        return com_num;
    }
    public void setCom_num(long com_num) {
        this.com_num = com_num;
    }
    public long getCom_amount() {
        return com_amount;
    }
    public void setCom_amount(long com_amount) {
        this.com_amount = com_amount;
    }
    public void onChange()
    {
        System.out.print("Per is"+isPermutation);
        System.out.print("com is"+isCombination);

    }

}

XHTML

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">

<h:head>
    <title><ui:insert name="title">Loteria-Play Smart</ui:insert></title>
    <link rel="stylesheet" href="css/style.css" media="screen" type="text/css" />
    <script>
    function tb_enableDisable()
    {
        alert("heoo");
         document.getElementById('play_form:txt_per').disabled= true;
    }
</script>

</h:head>

<h:body>

    <div class="home-card">

        <div id="home-top">
            <h:form>
                <p:outputLabel style="color:white;padding-right:8px">Welcome</p:outputLabel>
                <p:outputLabel value="#{loginController.email}"></p:outputLabel>
                <p:commandLink action="#{loginController.logout}" value="Logout" styleClass="logout"></p:commandLink>
            </h:form>
        </div>
        <div id="play-center">
            <h:form id="play_form">
            <p:inputText value="#{userDraw.per_num}"></p:inputText>
                <p:outputLabel>What you want to play?</p:outputLabel>
                    <div style="margin-top: 10px">
                        <h:panelGrid columns="6" cellpadding="2" cellspacing="5"  style="margin:0 auto">
                            <p:selectBooleanCheckbox value="#{userDraw.isPermutation}">
                            <p:ajax update="play_form" listener="#{userDraw.onChange}"></p:ajax>
                            </p:selectBooleanCheckbox>
                            <h:outputText value="Permutation:" />

                            <p:selectBooleanCheckbox value="#{userDraw.isCombination}">
                            <p:ajax update="play_form" listener="#{userDrawDataController.onChange}"></p:ajax>
                            </p:selectBooleanCheckbox>
                            <h:outputText value="Combination:" />

                            <p:selectBooleanCheckbox value="#{userDraw.isBoth}" >
                            <p:ajax update="play_form" listener="#{userDraw.onChange}"></p:ajax>
                            </p:selectBooleanCheckbox>
                            <h:outputText value="Both:" />
                        </h:panelGrid>

                    </div>
                    <div style="margin-top:30px">
                    <h:panelGrid columns="1" cellpadding="2" cellspacing="2">
                        <p:outputLabel>Permuation:</p:outputLabel>
                            <h:panelGrid columns="2" cellpadding="2" cellspacing="2">
                            <p:inputText id="txt_per" placeholder="Permutation amount:" disabled="#{userDraw.isPermutation}"></p:inputText>
                            <p:inputText id="txt_pnum" placeholder="Number" disabled="#{userDraw.isPermutation}"></p:inputText>
                            <p:message for="txt_per"></p:message>
                            <p:message for="txt_pnum"></p:message>
                            </h:panelGrid>
                    </h:panelGrid>
                    <h:panelGrid columns="1" cellpadding="2" cellspacing="2">
                        <p:outputLabel>Combination:</p:outputLabel>
                            <h:panelGrid columns="2" cellpadding="2" cellspacing="2">
                            <p:inputText id="txt_comb" placeholder="Permutation amount:" disabled="#{userDraw.isCombination}"></p:inputText>
                            <p:inputText id="txt_cnum" placeholder="Number " disabled="#{userDraw.isCombination}"></p:inputText>
                            <p:message for="txt_comb"></p:message>
                            <p:message for="txt_cnum"></p:message>
                            </h:panelGrid>
                    </h:panelGrid>

                    </div>

                <h:panelGrid columns="2" cellpadding="5" cellspacing="5"
                    style="margin:0 auto;">


                    <p:commandButton value="Enter" style="width:100px"></p:commandButton>
                    <p:commandButton value="Cancel" style="width:100px"></p:commandButton>

                </h:panelGrid>

            </h:form>

        </div>






    </div>
</h:body>

</html>

当您的 boolean 属性 被命名为 isPermutation 时,getter 应该被命名为 isIsPermutation().

如果您将 属性 重命名为 permutation,那么您可以将 getter 保留为 isPermutation()

另请注意,如果您的 属性 类型设置为 Boolean(并且 属性 名称为 isPermutation,则此 getter 前缀将不起作用).在这种情况下,getter 必须命名为 getIsPermutation()

总结一下:

  • boolean 属性的 getter 应以 is 开头。
  • Boolean(以及 Object 的其他子类型)的 getter 应该以 get 开头。
  • 无论前缀如何,getter 名称的后缀都应该是 属性 名称的 UpperCamelCased 版本。

更多信息:

  • boolean property starting with is is not found.