managed-bean

CDI beans injection

不想你离开。 提交于 2020-01-21 19:14:30
问题 Is this a correct approach to inject @ApplicationScoped bean in @SessionScoped bean? will this lead my application scoped bean to be stored in the session of every user? I have an application scoped bean that contains some values we share among all the system users, and now I need to get that values within a method in a session bean. 回答1: Injecting a bean of the same or a broader scope in another bean is completely legal and correct either in JSF or CDI beans, like the example you provided.

How to create and use a generic bean for enums in f:selectItems?

大憨熊 提交于 2020-01-20 06:52:45
问题 I have generic class with this signature: public abstract class EnumListBean<E extends Enum<E>> { public List<E> getEnumList() { //implementation details } } Currently I have to define a empty subclass in order to access the enumList property for a concrete generic parameter: @ManagedBean @ApplicationScoped public class ItemRarityBean extends EnumListBean<Item.Rarity>{ } This makes its possible to access the property e.g: <f:selectItems value="#{itemRarityBean.enumList}" var="rarity"

managed bean EJB injection

南笙酒味 提交于 2020-01-15 18:51:57
问题 i'm having many managed beans and was wondering if i could create a UtilClass where i put my services calls (@EJB). I've already tried it but i'm having a NullPointerException. this is how my UtilClass and my managed bean look like: public class UtilClass{ @EJB private static MyFirstEjbLocal myFirstService; @EJB private static MySecondEjbLocal mySecondService; //other services //getters } public class MyManagedBean{ public String myMethod(){ UtilClass.getMyFirstService.doSomethingInDB();

managed bean EJB injection

扶醉桌前 提交于 2020-01-15 18:47:55
问题 i'm having many managed beans and was wondering if i could create a UtilClass where i put my services calls (@EJB). I've already tried it but i'm having a NullPointerException. this is how my UtilClass and my managed bean look like: public class UtilClass{ @EJB private static MyFirstEjbLocal myFirstService; @EJB private static MySecondEjbLocal mySecondService; //other services //getters } public class MyManagedBean{ public String myMethod(){ UtilClass.getMyFirstService.doSomethingInDB();

Listening to when the user session is ended in a JSF managed bean

旧时模样 提交于 2020-01-09 07:59:46
问题 Is it possible to do something like this: When a user session starts I read a certain integral attribute from the database. As the user performs certain activities in this session, I update that variable(stored in session) & when the session ends, then I finally store that value to the DB. My question is how do I identify using the JSF framework if the user session has ended & I should then store the value back to DB? 回答1: Apart from the HttpSessionListener, you can use a session scoped

Undefined component type javax.faces.ViewRoot in JSF 2.3 startup

流过昼夜 提交于 2020-01-06 05:37:07
问题 This is a new twist from my earlier issues found here. I'm upgrading from MyFaces 2.1 to 2.3.5, and from PrimeFaces 6.1 to 7. This has also included migrating from managed beans to CDI. At this point, the server starts up and it appears that MyFaces, PrimeFaces, and CDI are being initialized. However, when I attempt to load my first page I get " Undefined component type javax.faces.ViewRoot ". Note, this is a "component type" not a class. Tracing into the MyFaces code, I can see that the

Importance of Serializable interface while creating a session scoped managed bean

好久不见. 提交于 2020-01-04 14:52:47
问题 I can't understand how serialization works in session scoped JSF managed beans. Why is implementation of Serializable interface important while creating a session scoped JSF managed bean? 回答1: @SessionScoped beans are ultimately stored in the user's HTTP session. This means that when a Java EE deployment implements a session preservation scheme (for example, tomcat will attempt to save current sessions to a .ser file on server shutdown, if the deployer so chooses), those session-scoped beans

Importance of Serializable interface while creating a session scoped managed bean

本秂侑毒 提交于 2020-01-04 14:52:34
问题 I can't understand how serialization works in session scoped JSF managed beans. Why is implementation of Serializable interface important while creating a session scoped JSF managed bean? 回答1: @SessionScoped beans are ultimately stored in the user's HTTP session. This means that when a Java EE deployment implements a session preservation scheme (for example, tomcat will attempt to save current sessions to a .ser file on server shutdown, if the deployer so chooses), those session-scoped beans

Injecting a managedBean in a converter [duplicate]

牧云@^-^@ 提交于 2020-01-04 08:03:34
问题 This question already has answers here : How to inject @EJB, @PersistenceContext, @Inject, @Autowired, etc in @FacesConverter? (5 answers) Closed 3 years ago . I'm trying to write a converter for my selectonemenu list so the list that i want to display can be retrieved from a managedBean's getter getDatasetList() . My managedBean is viewScoped. here's the code of the converter: @FacesConverter(value = "datasetConverter") public class DatasetConverter implements Converter{ @ManagedProperty

Binding a Xpage DominoDocument to a Bean

懵懂的女人 提交于 2020-01-03 04:18:09
问题 is it possible to bind a DominoDocument directly to a Managed Bean. So that I can have a property in my Bean which holds a reference to the DominoDocument all the time? Appreciating any suggestions/advices! 回答1: As Per mentioned above, the simplest way to do what you want is instead of binding it to a property in your bean, just access it using a method in your bean. public DominoDocument getDominoDocument() { // Whatever the data source name is you want to get String documentName =