managed-property

Difference between @ManagedProperty and FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(“bean”)

混江龙づ霸主 提交于 2020-01-06 20:10:00
问题 What's the difference between: public class GameController implements Serializable{ @ManagedProperty(value="#{Gamebean}") private Game game; and public class GameController implements Serializable{ private Game game; public GameController(){ game =(Game)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("Gamebean"); } and if there's no difference what method is better ? Cheers. 回答1: The @ManagedProperty way will autocreate bean if it doesn't exist yet. The

@ManagedProperty does not work in a CDI managed bean

▼魔方 西西 提交于 2019-12-30 10:34:47
问题 I try to learn JSF and encountered on a problem connected with ManagedProperty. However I have tried to use it, it always failed - null exception pointer. What am I doing wrongly? I have read some "similar posts" on stackoverflow, but they did not helped to me. (I use GlassFish 4.0, JSF 2.2, JDK 1.7, Netbeans 7.3.1 (Java EE pack) and Java EE 6.0) <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1

@Inject to pass params to a CDI @Named bean via URL

廉价感情. 提交于 2019-12-17 06:14:41
问题 If I cannot use the @ManagedProperty annotation with @Named, because @ManagedProperty doesn't work in CDI(?), then how do you pass params in the URL to the facelets client? In my code, I want to pass javax.mail.getMessageNumber() to details.xhtml through the "back" and "forward" buttons. I understand that @Inject should be used, but what is being injected and how, please? From the glassfish logs, id is always 0, which is quite odd. Even when "forward" is clicked, id never gets above 1 no

ManagedBeanCreationException: cannot set property for managed bean with ManagedProperty

微笑、不失礼 提交于 2019-12-11 21:10:06
问题 i get this error : "com.sun.faces.mgbean.ManagedBeanCreationException: No se puede definir la propiedad procesos para el bean administrado procesos" when i run my web app. Roughly translated "cannot define property procesos for the managed property procesos" this is my managed bean with the issue: @ManagedBean(name = "procesos") @ViewScoped public class ProcesosBean implements Serializable { @ManagedProperty(value="#{user}") private List<VistaProcesosEntity> procesos; private LoginBean

Can @ManagedPropery and @PostConstruct be placed in a base class?

喜夏-厌秋 提交于 2019-12-06 03:36:17
问题 I'm using a hierarchy of classes and what I would optimally try to do is have @ManagedBean 's that inherit a class that have @ManagedProperty members and @PostConstruct methods. Specifically, will this work? : public class A { @ManagedProperty private C c; @PostConstruct public void init() { // Do some initialization stuff } public C getC() { return c; } public void setC(C c) { this.c = c; } } @ManagedBean @SessionScoped public class B extends A { // Content... } Thanks in Advance! 回答1: The

Can @ManagedPropery and @PostConstruct be placed in a base class?

南楼画角 提交于 2019-12-04 08:49:58
I'm using a hierarchy of classes and what I would optimally try to do is have @ManagedBean 's that inherit a class that have @ManagedProperty members and @PostConstruct methods. Specifically, will this work? : public class A { @ManagedProperty private C c; @PostConstruct public void init() { // Do some initialization stuff } public C getC() { return c; } public void setC(C c) { this.c = c; } } @ManagedBean @SessionScoped public class B extends A { // Content... } Thanks in Advance! The @ManagedProperty is inherited and will just work that way. The @PostConstruct will also be inherited,

@ManagedProperty does not work in a CDI managed bean

試著忘記壹切 提交于 2019-12-01 09:28:29
I try to learn JSF and encountered on a problem connected with ManagedProperty. However I have tried to use it, it always failed - null exception pointer. What am I doing wrongly? I have read some "similar posts" on stackoverflow, but they did not helped to me. (I use GlassFish 4.0, JSF 2.2, JDK 1.7, Netbeans 7.3.1 (Java EE pack) and Java EE 6.0) <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html"> <h

@ManagedProperty does not reflect changes and keeps returning null

北城以北 提交于 2019-12-01 08:53:30
I'm trying to inject the value of one sessionscoped bean into a viewscoped bean but it keeps returning null, here's a snippet: import javax.faces.application.FacesMessage; import javax.faces.bean.SessionScoped; import javax.faces.bean.ManagedBean; import javax.faces.context.FacesContext; //Class for managing the current logged-in user @ManagedBean(name="user") @SessionScoped public class User implements Serializable{ private String userName; public void setUserName(String userName) { this.userName = userName; } public String getUserName() { return this.userName; } And it's used in:

@ManagedProperty does not reflect changes and keeps returning null

99封情书 提交于 2019-12-01 06:37:42
问题 I'm trying to inject the value of one sessionscoped bean into a viewscoped bean but it keeps returning null, here's a snippet: import javax.faces.application.FacesMessage; import javax.faces.bean.SessionScoped; import javax.faces.bean.ManagedBean; import javax.faces.context.FacesContext; //Class for managing the current logged-in user @ManagedBean(name="user") @SessionScoped public class User implements Serializable{ private String userName; public void setUserName(String userName) { this

@ManagedProperty with request parameter not set in a @Named bean

﹥>﹥吖頭↗ 提交于 2019-11-30 20:41:47
I've a CDI managed bean wherein I'd like to set request parameters as managed properties: import javax.inject.Named; import javax.enterprise.context.RequestScoped; @Named @RequestScoped public class ActivationBean implements Serializable { @ManagedProperty(value="#{param.key}") private String key; @ManagedProperty(value="#{param.id}") private Long id; // Getters+setters The URL is domain/activate.jsf?key=98664defdb2a4f46a527043c451c3fcd&id=5 , however the properties are never set and remain null . How is this caused and how can I solve it? I am aware that I can manually grab them from