Reputation: 169
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>
Upvotes: 1
Views: 6371
Reputation: 163
Check the import package of @SessionScoped, it must be import javax.faces.bean.SessionScoped; and also give name to ManageBean @ManagedBean(name="Profile")
Upvotes: 0
Reputation: 37071
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{
}
Upvotes: 0
Reputation: 30025
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.
Upvotes: 2