值中的未知属性

  • 本文关键字:属性 未知 jsf
  • 更新时间 :
  • 英文 :


我的一些值下面有黄线,表示unkown property values

<p:spinner min="1" max="50" value="#{printerSettings.p}" size ="1"> <!-- allows the user a choice of up to 50, this is more than enough for any situation, if needed this can be removed or raised -->
                        <p:ajax update="p"/>
                    </p:spinner>
                    <br></br>
                    <br></br>
                    <h:outputText value="Copies that will be printed: &nbsp; #{printerSettings.p}" id="p"/>
                    <br></br>
                    <br></br>

                    Double sided?: 
                    <br></br>
                    <br></br>
                    Paper Size : 
                    <h:selectOneMenu value="#{printerSettings.selectedPaper}">
                        <f:selectItems value="#{printerSettings.selectedPaperValue}" />
                    </h:selectOneMenu> 
                    <br></br>
                    <br></br>
                    What time would you like the printer to print out your work ?, please enter the minutes after midnight :  
                    <br></br>
                    <br></br>
                    <p:inputText id="timeToPrint" value="#{printerSettings.timeToPrint}" />
                    <br></br>

printerSettings.p工作得很好,它们是printerSettings.selectedPaperprinterSettings.selectedPaperValueprinterSettings.timeToPrint,下面有这些黄线,奇怪的是它从bean中提取信息,所以我得到了打印时间的默认值2000,菜单显示了三个选项,为什么要这样做?有什么问题吗?

这是我的人脸配置

   <managed-bean>
        <managed-bean-name>printerSettings</managed-bean-name>
        <managed-bean-class>richard.fileupload.PrinterSettings</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>

这是我的豆

public class PrinterSettings {
//@NotNull(message = "Please enter a time to print ")
    private int timeToPrint = 2000;
    private int p = 1; //sets default value
    private int time;
    public String selectedPaper = "A4"; // defualts to A4
    public int gettimeToPrint() {
        return (timeToPrint);
    }
    public void settimeToPrint(int timeToPrint1) {
        this.timeToPrint = timeToPrint1;
    }
    public int getP() {
        return (p);
    }
    public void setP(int p1) {
        this.p = p1;
    }
    public int gettime() {
        return (time);
    }
    public void settime(int time) {
        this.time = time;
    }
    public String getselectedPaper() {
        return selectedPaper;
    }
    private static Map<String, Object> paperValue;
    static {
        paperValue = new LinkedHashMap<String, Object>();
        paperValue.put("A5", "A5"); //right hand side is value, may need to change this later on to make compatable with the printers
        paperValue.put("A4", "A4");
        paperValue.put("A3", "A3");
    }
    public Map<String, Object> getselectedPaperValue() {
        return paperValue;
    }
}

我还注意到,在bean中,我在paperValue.put位下有一条黄线,上面写着在初始化期间使用非静态变量

我认为您收到警告"unknown property in value"是因为PrinterSettings bean属性的getter和setter名称错误。对于selectedPaper属性,getter名称应为>getSelectedPaperem>setSelectedPaper。对于selectedPaperValue属性getter名称应为>getSelectedPaperValue,setter名称应该为setSelectedPaper Value。对于timeToPrint属性,getter名称应为>getTimeToPrint,setter名称应该为setTimeToPrint。

setter的名称应该从set+属性的名称开始,并使用第一个大写字母。getter的名称应该从get+属性的名称开始,并使用第一个大写字母。

JSF使用getter和setter来访问POJO的属性。

相关内容

  • 没有找到相关文章

最新更新