2015-03-19 4 views
0

Я пытаюсь установить значение bean из xhtml-страницы. Но каждый раз при запуске страницы он показывает мне ошибку свойства, не найденное. Я добавил свойство в bean.I очистить & построить проект столько раз. но ничего не работает, пожалуйста, помогите мне.Свойство 'isPermutation' не найдено в jsf

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> 

ответ

3

Когда свойство boolean называется isPermutation, геттер должен быть назван isIsPermutation().

Если вы переименовали свою собственность на permutation, вы можете оставить геттер по имени isPermutation().

Также обратите внимание, что этот префикс getter не будет работать, если для вашего типа свойства установлено значение Boolean (а также имя свойства isPermutation). В этом случае геттер должен иметь имя getIsPermutation().

Резюмируя:

  • Газопоглотители для boolean свойств должны начинаться с is.
  • Геттеры для Boolean (и другие подтипы Object) должны начинаться с get.
  • Независимо от того, префикс, суффикс имени получателя должен быть UpperCamelCased версией названия свойства.

Подробнее:

+0

Почему isPermutaion не работает? – TechGuy

+0

, потому что это должно быть 'isIsPermutation'. –

+0

i chnaged isPermutation to Permutation, но все еще не работает? – TechGuy

Смежные вопросы