managed-property

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

て烟熏妆下的殇ゞ 提交于 2019-11-30 05:15:00
问题 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

@ManagedProperty in a Spring managed bean is null

*爱你&永不变心* 提交于 2019-11-27 14:31:46
I've some trouble with injecting one managedbean in another by defining a managedproperty. I'm googling and stackoverflowing now for 3 days, but with no result... I'm developing with eclipse 4.2 and deploying to an integrated Tomcat 7 So, can anybody tell me, why my property is null? pom.xml <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring.version>3.0.5.RELEASE</spring.version> <java.version>1.6</java.version> </properties> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> <

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

与世无争的帅哥 提交于 2019-11-26 22:55:29
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 matter how many times the button is clicked. Of course, that's merely a symptom of the problem. The desired

@ManagedProperty in a Spring managed bean is null

对着背影说爱祢 提交于 2019-11-26 16:47:38
问题 I've some trouble with injecting one managedbean in another by defining a managedproperty. I'm googling and stackoverflowing now for 3 days, but with no result... I'm developing with eclipse 4.2 and deploying to an integrated Tomcat 7 So, can anybody tell me, why my property is null? pom.xml <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring.version>3.0.5.RELEASE</spring.version> <java.version>1.6</java.version> </properties> <dependency> <groupId>org

Accessing injected dependency in managed bean constructor causes NullPointerException

左心房为你撑大大i 提交于 2019-11-26 16:45:15
I'm trying to inject a DAO as a managed property. public class UserInfoBean { private User user; @ManagedProperty("#{userDAO}") private UserDAO dao; public UserInfoBean() { this.user = dao.getUserByEmail("test@gmail.com"); } // Getters and setters. } The DAO object is injected after the bean is created, but it is null in the constructor and therefore causing NullPointerException . How can I initialize the managed bean using the injected managed property? Injection can only take place after construction simply because before construction there's no eligible injection target. Imagine the

Accessing injected dependency in managed bean constructor causes NullPointerException

痴心易碎 提交于 2019-11-26 06:03:31
问题 I\'m trying to inject a DAO as a managed property. public class UserInfoBean { private User user; @ManagedProperty(\"#{userDAO}\") private UserDAO dao; public UserInfoBean() { this.user = dao.getUserByEmail(\"test@gmail.com\"); } // Getters and setters. } The DAO object is injected after the bean is created, but it is null in the constructor and therefore causing NullPointerException . How can I initialize the managed bean using the injected managed property? 回答1: Injection can only take

ViewParam vs @ManagedProperty(value = “#{param.id}”)

℡╲_俬逩灬. 提交于 2019-11-25 21:53:09
问题 What is the difference between defining View Params like this: <f:metadata> <f:viewParam name=\"id\" value=\"#{someBean.id}\"/> </f:metadata> And defining the property in the ManagedBean like this: @ManagedProperty(value = \"#{param.id}\") private Integer id; 回答1: <f:viewParam>: Sets the value during update model values phase only (since it extends UIInput). The set value is not available during @PostConstruct, so you need an additional <f:event type="preRenderView" listener="#{bean.init}" />