Primefaces @managementBean

发布于 2024-12-12 00:02:43 字数 1230 浏览 0 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

無心 2024-12-19 00:02:43

配置文件应小写,并检查密码行的语法

Profile should be lowercase, and check the syntax on password line

情魔剑神 2024-12-19 00:02:43

如果不使用@ManagedBean注解的name属性,则必须将第一个字母转换为小写来引用bean。

来自 @ ManagedBean javadoc

name() 属性的值被视为
托管 bean 名称。如果未指定 name 属性的值
或者是空字符串,托管 bean 名称源自取
完全限定类名的非限定类名部分
将第一个字符转换为小写。例如,如果
ManagedBean 注释位于具有完全限定类的类上
name com.foo.Bean,并且注释上没有 name 属性,
托管 bean-name 被视为 bean。完全合格的班级
附加此注释的类的名称被视为
托管 bean 类。

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:

The value of the name() attribute is taken to be the
managed-bean-name. If the value of the name attribute is unspecified
or is the empty String, the managed-bean-name is derived from taking
the unqualified class name portion of the fully qualified class name
and converting the first character to lower case. For example, if the
ManagedBean annotation is on a class with the fully qualified class
name com.foo.Bean, and there is no name attribute on the annotation,
the managed-bean-name is taken to be bean. The fully qualified class
name of the class to which this annotation is attached is taken to be
the managed-bean-class.

假装不在乎 2024-12-19 00:02:43

由于您使用的是 jsf2,

您可以执行以下操作 - 为 bean 命名......

@ManagedBean(name="Profile")
@SessionScoped
public class Profile implements Serializable{
}

Since you are using jsf2

you can do the following - give a name to the bean...

@ManagedBean(name="Profile")
@SessionScoped
public class Profile implements Serializable{
}
游魂 2024-12-19 00:02:43

检查@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")

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文