[英]Picky on Getter/Setter name? JSF/Jboss Seam
I'm working on a JBoss seam application (JSF 1.1 and MyFaces Tomahawk) which runs on tomcat 5.0.28. 我正在开发一个运行在tomcat 5.0.28上的JBoss接缝应用程序(JSF 1.1和MyFaces Tomahawk)。
What is bugging me is that at times when i create a variable and the setter and getter for it they don't get picked up resutling in me getting errors like: 让我感到烦恼的是,有时我创建变量,setter和getter时,它们不会被重新整理,而出现如下错误:
javax.faces.el.PropertyNotFoundException: Bean: com.sportsMed.Util , property: mappingUID
I have to try and change the Setter/Getter name repeatedly and test until it passes through without errors and this can be going through 5-6 different names and becomes such a waste of time. 我必须尝试反复更改Setter / Getter的名称,并进行测试,直到它通过而没有错误为止,这可能要经过5-6个不同的名称,并且变得如此浪费时间。
Am i doing something wrong? 难道我做错了什么? Just 10 minutes ago i had to change: 就在10分钟前,我不得不更改:
private String UserName;
public void setUserName(String s)...
public String getUserName()....
that didn't work resulting in Property not found so i changed the above to: 无法正常工作,导致找不到Property,因此我将以上内容更改为:
private String user_Name;
public void setuser_Name(String s)...
public String getuser_Name()....
Nope and finally tried: 不,终于尝试了:
private String nUser;
public void setnUser(String s)...
public String getnUser()....
Somehow that works fine! 以某种方式可以正常工作! and as mentioned at times it won't work until 5-6 name changes! 而且有时会提到,直到5-6名更改,它才起作用! Can someone tell me what I'm doing wrong or why its happening. 有人可以告诉我我在做什么错或为什么会这样。 Thanks 谢谢
set
+ capitalized field (same for getter) 必须set
setter +大写字段(与getter相同) So: 所以:
private String userName;
public void setUserName(..);
public String getUserName(..);
Reference: javabeans spec , java naming conventions 参考: javabeans spec , java命名约定
Using an IDE (Eclipse, NetBeans, IntelliJ) to generate the setters and getters would make things easier. 使用IDE(Eclipse,NetBeans,IntelliJ)生成设置器和获取器将使事情变得容易。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.