managed-bean

Can @ManagedBean and @XxxScope be placed in a base class?

萝らか妹 提交于 2019-12-10 17:28:28
问题 I have two @ManagedBean (javax.faces.bean.ManagedBean), parent and child. The parent managed bean is not abstract because we have to give liberty to the developer to use the parent if enough or inherit it with a child that holds specifically funcionality. I have problems with the injections bean and the @PostConstruct annotated method in the parent bean. The following code is the only way I found it works. @ManagedBean(name = "myBean") @SessionScoped public class BaseBean implements

Are both getters and setters mandatory in JSF's managed beans?

a 夏天 提交于 2019-12-10 17:26:24
问题 I have a JSF component which is initialized from a managed bean's getter getProperty() . Is it mandatory to also have a setter setProperty() in that managed bean? 回答1: It depends. Some property bindings must be read-write. For example, if you bind the value of a component that implements EditableValueHolder. Other properties can be read-only. If you use the binding attribute for dynamically creating component instances, this must also be read-write as per the contract defined in the

Remove/destroy session scoped CDI managed bean

血红的双手。 提交于 2019-12-10 16:48:29
问题 I have a session scoped CDI managed bean: @Named @SessionScoped public class SampleBean implements Serializable { // ... } I need to remove this bean from the session after a certain flow for which I used the following code like as seen in this answer: ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext(); ec.getSessionMap().remove("sampleBean"); However, it does not work and the SampleBean remains in the session. Am I missing something? 回答1: In contrary to JSF managed

immediate vs deferred evaluation for reading bean properties

限于喜欢 提交于 2019-12-10 15:44:17
问题 I am still unclear about the use of JSF immediate evaluation vs deferred evaluation , mainly because the online examples almost never seem to use the former method. I have seen a fair amount of JSF Examples, including those contained in http://docs.oracle.com/javaee/6/tutorial/doc/, and I am a bit puzzled by the fact that I almost only ever see examples with #{} instead of ${} , even when all we're doing is reading a bean property. From my understanding of these two uses, ${} can only be used

Retrieving value of JSF input field without managed bean property [closed]

梦想的初衷 提交于 2019-12-10 10:02:10
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I would like to retrieve the value of JSF input box in a managed bean action method, without it being associated with any managed bean property. E.g. <p:inputText id="txtuserid" value="" /> My use case is that in my application I will like to prompt user here and there for passwords for every DML operations, and

Binding a Xpage DominoDocument to a Bean

一笑奈何 提交于 2019-12-09 06:56:25
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! 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 = "document1"; Object o = ExtLibUtil.resolveVariable(FacesContext.getCurrentInstance(), documentName); // Double check

Expire specific managed bean instance after time interval

谁说我不能喝 提交于 2019-12-09 06:25:24
问题 I have 2 JSF managed beans A and B and I need to expire/destruct/destroy A after 2 minutes and B after 5 minutes. I checked this related question Timing out from a bean, but it is expiring whole session. I do not want to expire whole session. How can I achieve this with a custom scope? 回答1: Given that you're using JSF bean management facility (and thus not CDI, which would require a completely different answer), you can achieve this with @CustomScoped. The @CustomScoped value must refer a Map

UnserializableDependencyException: WELD-001413: The bean declares a passivating scope but has a non-passivation-capable dependency

对着背影说爱祢 提交于 2019-12-08 17:11:59
问题 I have the below CDI managed bean: @Named @SessionScoped public class InfoPageController implements Serializable { @Inject private InfoPageMapper mapper; } It throws the below exception during deployment to GlassFish 4.1: Exception while loading the app : CDI deployment failure:WELD-001413: The bean Managed Bean [class de.triaconsulting.cashyourgame.fe.controller.InfoPageController] with qualifiers [@Default @Any @Named] declares a passivating scope but has a non-passivation-capable

How to NOT initialize beans on page load associated with conditionally rendered content

旧巷老猫 提交于 2019-12-08 09:41:18
问题 I have a single page with conditionally rendered content controlled by several links in a sidemenu. All of that content has a datatable that is rendered false by default. Everything is working, except that when the page loads all of the beans are being executed and all beans are doing expensive database work. I would like that when a sidemenu is clicked by user, the corresponding datatable will render and only then the associated managed bean will be initialized. How can I achieve this? 回答1:

Java class name convention with respect to managed been usage in Primefaces

蓝咒 提交于 2019-12-08 09:04:31
I am using Eclipse Indigo and whenever I create a new class starting with lower case then a warning is shown as displayed below (" Type name is discouraged. By convention, Java type names usually start with an uppercase letter"). Now in my xHTML / JSF file, if i try to access the class with first letter in caps then it is not accessible e-g; '#{MyClass.variableName}' is NOT accessible nor the class constructor is called whereas '#{myClass.variableName}' works fine. Note: class has an annotation "@ManagedBean" Thanks This is edited part: It only works if class is created with first letter as