Primefaces @managementBean
我正在使用 3.0 M3 。当我在 faces-config.xml 中声明我的托管 bean 时,它工作得很好,但是当我尝试使用相同的代码时 注释 @Managed bean @Request Scoped,它表示目标 UN-reachable。
我也尝试过 2.2,但它又说同样的问题。 我正在使用玻璃鱼 v3
@ManagedBean
@SessionScoped
public class Profile implements Serializable{
private String userId;
private String password;
private int code;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
这是我如何称呼它们
<h:form>
<p:panel style="margin-top: 200px;margin-left: 300px;margin-right: 300px;" header="Welcome">
<h:outputText value="Your Code ? "/>
<h:inputText required="true" requiredMessage="Enter user id" value="#{Profile.userId}"/>
<h:outputText value="Password "/>
<h:inputSecret required="true" requiredMessage="Enter password id" value="#Profile.password}"/>
<h:commandButton action="#{Profile.varify}" value="Next"/>
</p:panel>
</h:form>
i am working with 3.0 M3 . when i declare my managed beans in faces-config.xml, it works perfectly, but when i try the same codes with
annotations @Managed bean @Request Scoped, it says target UN-reachable.
i tried on 2.2 also, but it says same issue again.
I am using glass fish v3
@ManagedBean
@SessionScoped
public class Profile implements Serializable{
private String userId;
private String password;
private int code;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
Here is how i call them
<h:form>
<p:panel style="margin-top: 200px;margin-left: 300px;margin-right: 300px;" header="Welcome">
<h:outputText value="Your Code ? "/>
<h:inputText required="true" requiredMessage="Enter user id" value="#{Profile.userId}"/>
<h:outputText value="Password "/>
<h:inputSecret required="true" requiredMessage="Enter password id" value="#Profile.password}"/>
<h:commandButton action="#{Profile.varify}" value="Next"/>
</p:panel>
</h:form>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
配置文件应小写,并检查密码行的语法
Profile should be lowercase, and check the syntax on password line
如果不使用@ManagedBean注解的name属性,则必须将第一个字母转换为小写来引用bean。
来自 @ ManagedBean javadoc:
If you don't use the name attribute of the @ManagedBean annotation, you have to refer to the bean with the first letter converted to lower case.
From the @ManagedBean javadoc:
由于您使用的是 jsf2,
您可以执行以下操作 - 为 bean 命名......
Since you are using jsf2
you can do the following - give a name to the bean...
检查@SessionScoped的导入包,必须是import javax.faces.bean.SessionScoped;
并给 ManageBean @ManagedBean(name="Profile") 命名
Check the import package of @SessionScoped, it must be import javax.faces.bean.SessionScoped;
and also give name to ManageBean @ManagedBean(name="Profile")