在我的一些价值观下,我得到了黄线说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: #{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.selectedPaper
,printerSettings.selectedPaperValue
并且printerSettings.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 位下得到一条黄线,表示在初始化期间使用了非静态变量