0

I am trying to set a value to bean from xhtml page.But every time run the page it is showing me error of property not found.I have added the property in bean.I have clean & build the project so many times. but nothing is working please help me out.

Bean

 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>
Tiny
  • 27,221
  • 105
  • 339
  • 599
TechChain
  • 8,404
  • 29
  • 103
  • 228

1 Answers1

3

When your boolean property is named isPermutation, the getter is supposed to be named isIsPermutation().

If you rename your property to permutation, then you can leave the getter named isPermutation().

Also note that this getter prefix won't work if your property type is set to Boolean (and the property name is isPermutation). In this case the getter has to be named getIsPermutation().

To summarize:

  • The getters for boolean properties should start with is.
  • The getters for Boolean (and other subtypes of Object) should start with get.
  • No matter the prefix, the suffix of the getter name should be a UpperCamelCased version of the property name.

More info:

Community
  • 1
  • 1
Konstantin Yovkov
  • 62,134
  • 8
  • 100
  • 147