2011-10-24 36 views
1

我正在使用3.0 M3。當我在faces-config.xml中聲明我的託管bean時,它完美地工作,但是當我使用 註釋@Managed bean @Request Scoped嘗試相同的代碼時,它表示目標UN-reachable。Primefaces @managedBean

我也試過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> 

回答

2

檔案應該是小寫,並檢查密碼行

2

語法如果你不使用@ManagedBean註釋的名稱屬性,必須引用第一個字母轉換爲小寫字母的bean。

@ManagedBean javadoc

()的名稱屬性的值被取爲所述 託管bean-名稱。如果名稱屬性的值未指定爲 或爲空字符串,則從 獲取全限定類名 和的非限定類名稱部分,並將第一個字符轉換爲小寫,從而派生出管理bean名稱。例如,如果ManagedBean註釋位於具有完全限定類 名稱com.foo.Bean的類上,並且在註釋 上沒有名稱屬性,則將managed-bean名稱視爲bean。此註釋附加到的類的名稱 被視爲受管bean類的 。

0

由於您使用JSF2

,你可以做以下 - 提供一個名稱豆...

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

檢查@SessionScoped的導入包,它必須是進口的javax .faces.bean.SessionScoped; 並命名爲ManageBean @ManagedBean(name =「Profile」)