Jsf 价值未知的财产

Jsf 价值未知的财产,jsf,Jsf,我的一些值下面有黄线,表示未知属性值 <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: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>
这是我的豆子

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;
    }
}
公共类打印机设置{
//@NotNull(message=“请输入打印时间”)
私有int timeToPrint=2000;
private int p=1;//设置默认值
私人整数时间;
公共字符串selectedPaper=“A4”;//将参数设置为A4
public int gettimeToPrint(){
返回(timeToPrint);
}
公共无效settimeToPrint(int-timeToPrint1){
this.timeToPrint=timeToPrint1;
}
公共int getP(){
回报率(p);
}
公共无效setP(int p1){
这个p=p1;
}
公共int gettime(){
返回(时间);
}
公共无效设置时间(整数时间){
这个时间=时间;
}
公共字符串getselectedPaper(){
返回所选纸张;
}
私有静态映射值;
静止的{
paperValue=新建LinkedHashMap();
paperValue.put(“A5”、“A5”);//右侧是值,以后可能需要更改此值以使其与打印机兼容
纸面价值。投入(“A4”、“A4”);
纸面价值。看跌期权(“A3”、“A3”);
}
公共地图getselectedPaperValue(){
返回值;
}
}

我还注意到,在bean中,paperValue.put位下有一条黄线,表示在初始化过程中使用了非静态变量。我认为,由于PrinterSettings bean的属性的getter和setter名称错误,您会收到警告“值中的属性未知”。对于selectedPaper属性,getter名称应为getSelectedPaper,setter名称应为setSelectedPaper。对于selectedPaperValue属性,getter名称应为getSelectedPaperValue,setter名称应为setSelectedPaperValue。对于timeToPrint属性,getter名称应为getTimeToPrint,setter名称应为setTimeToPrint

setter的名称应以set+第一个大写字母的属性名称开头。getter的名称应以get+属性的名称开头,并带有第一个大写字母


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

您的项目中有所有必要的引用吗?通常你不能实例化静态对象,所以你可能想检查一下修改你的代码。是的,我想我用过,我使用了教程中的MAP函数,奇怪的是他们从中得到了值,但仍然有这个错误“奇怪的是它从bean中提取了信息”-这是一个正确的行为,如果您将例如
p:inputText
附加到bean的属性,它将在默认情况下显示属性值,并且您可以修改它。“下面有这些黄线”我不明白你在这里的意思,但我看到你在做糟糕的设计实践,使用了大量的

标记。请改用[|
h:panelGrid
]谢谢你关于br标签和黄线的建议,我已经安装了netbeans,它们在下面用黄线显示这些错误,这是我为地图列表@user2054949遵循的教程,不要依赖可以检查代码的工具,相反,你必须确定你在做什么。将工具警告视为不正确的东西(或者可能不适合工具的作者)。我在Juno上使用JBoss工具时经常遇到这种情况,但是一旦代码开始运行,就没有问题了。谢谢你的解释
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;
    }
}