Reputation: 23
I am getting yellow lines under a few of my values saying 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
works perfectly fine, they are printerSettings.selectedPaper
, printerSettings.selectedPaperValue
and printerSettings.timeToPrint
that have these yellow lines under them, the strange thing is it pulls the information from the bean, so i get a default value of 2000 for time to print and the menu displays three options, why is this doing this? Is there something wrong ?
Here is my faces-config
<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>
And this is my 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;
}
}
I also notice in the bean I get a yellow line under the paperValue.put bit that says usage of non static variable during initialization
Upvotes: 1
Views: 2681
Reputation: 6073
I think you get warning "unknown property in value"
because of wrong getter and setter names for your PrinterSettings bean's properties. For selectedPaper property getter name should be getSelectedPaper and setter name should be setSelectedPaper. For selectedPaperValue property getter name should be getSelectedPaperValue and setter name should be setSelectedPaperValue. For timeToPrint property getter name should be getTimeToPrint and setter name should be setTimeToPrint.
The name of the setter should start from set + the name of the property with first uppercase letter. The name of the getter should start from get + name of the property with first uppercase letter.
JSF uses getters and setters to access properties of the POJOs.
Upvotes: 2