view-scope

CDI ViewScope & PrettyFaces: Multiple calls to @PostConstruct (JSF 2.2)

对着背影说爱祢 提交于 2019-12-06 03:04:50
I'v already check similar questions which declare that JSF 2.1 had this bug, but I'm using JSF 2.2 Let's detail: My environment: CDI: 1.1 Dynamic Web Module: 3.0 Java: 1.7 JSF: 2.2 PrettyFaces: 2.0.12.Final My Bean: @Named(value = "home") @javax.faces.view.ViewScoped public class HomeBean implements Serializable { @Inject private HomeController controller; private List<Store> myPopularStores; @PostConstruct public void postConstruct() { myPopularStores = controller.getStores(); LOG.log(Level.FINE, "HomeBean: initialized"); } public String buttonClicked() { // whatever } } That controller,

Re-execute f:viewAction when ViewScoped bean is recreated following a POST request

╄→尐↘猪︶ㄣ 提交于 2019-12-05 16:54:33
Environment: JSF 2.2 with Mojarra 2.2.12 & CDI ViewScoped beans & javax.faces.STATE_SAVING_METHOD set to client . In order to properly initialize my bean thanks to <f:viewParam ... /> , I would like to (re-)execute <f:viewAction action="#{bean.onLoad}" /> when my ViewScoped bean is recreated (view was pushed out from the LRU, cf. com.sun.faces.numberOfLogicalViews ) following a POST request. <f:metadata> <f:viewParam maxlength="100" name="name" value="#{bean.file}" /> <f:viewAction action="#{bean.onLoad}" /> </f:metadata> <o:form includeRequestParams="true"> <!-- action can only work if onLoad

Viewscoped JSF and CDI bean

岁酱吖の 提交于 2019-12-05 05:34:53
I'm using Java EE 6 on JBoss EAP 6, and my JSF beans are annotated like this: @ManagedBean @ViewScoped (both from javax.faces.bean package) However, they are also CDI beans (default constructor, use of @Inject , @PreDestroy etc). I'm reading all the time that you can't mix these annotations (JSF and CDI), but it's apparently working fine: Injections are working, preDestroy is called on view change etc). Am I missing something? What is the problem? Why not use? The CDI @Inject works "everywhere" and thus also inside JSF @ManagedBean . The JSF counterpart @ManagedProperty works inside

Destroying view-scoped beans when session ends

两盒软妹~` 提交于 2019-12-05 02:50:30
问题 My question is related to this one (and probably others): @PreDestroy never called on @ViewScoped As stated there, there's no trivial solution to either have view-scoped beans destroyed upon navigation and the same seems to hold true for when the session expires. What would a non-trivial approach to release (calling the @PreDestroy method) JSF view-scoped beans look like, or more specifically as soon as the session expires? I'm using Java EE 6 and Mojarra 2.1.x on GlassFish 3.1.2. 回答1: Create

Serialization of ManagedProperty

我只是一个虾纸丫 提交于 2019-12-04 17:43:40
We have the following problem with JSF's @ViewScoped and @ManagedProperty : we have ManagedBean s that basically look as follows: @ManagedBean @SessionScope public class SessionConfig implements Serializable { // ... } and @ManagedBean @ViewScope public class SomeController implements Serializable { @ManagedProperty( value="#{sessionConfig}" ) private SessionConfig sessionConfig; // public getter and setter // ... } The controller is serialized after the request has been processed, as expected. I expected that the @ManagedProperty sessionConfig would be handled specially in serialization, in

Restoring request parameters in @ViewScoped bean after session expires

夙愿已清 提交于 2019-12-04 11:56:24
I have a page that has the setup as below with url like my.page.com/table.xhtml?id=123 : +----------------------------------------------+ |Meta information | |----------------------------------------------| | Search Fields Submit btn | |----------------------------------------------| | | | | | Big p:dataTable | | with rowExpansion | | | |----------------------------------------------| | Pager | +----------------------------------------------+ id=123 is the request parameter that controls the content on the result table. All actions only reload the data table using AJAX . id is loaded throught

How to pass objects from one page to another page in JSF without writing a converter

痴心易碎 提交于 2019-12-04 08:39:33
first of all sorry for my english. I have two pages in JSF2, one to list Passengers and another one to create/update passengers. I have also two @ViewScoped beans, one with the list of passengers and one for hold in pageB the selected passenger. I see the ways to pass the passenger through viewParam or @ManagedProperty but i don´t want to write a converter. What i want to know if there is a way to pass the object from pageA to pageB without passing the id of the passenger and write a converter or without passing the id and then go to the DB to retrieve the passenger. What i do and works is the

Inject CDI bean into JSF @ViewScoped bean

只愿长相守 提交于 2019-12-04 07:50:18
I have a problem with JSF, CDI project. I did a lot of research and I found that in CDI there is no @ViewedScoped annotation. I solving problem with ajax based page with dialog. I want to pass variable to dialog from datatable. For this purpose, I can't use @RequestedScoped bean because value is discard after end of request. Can anyone help me to solve it? I can't use @SessionScoped but it's a bad practice IMHO. Or maybe save only this one variable into session who knows. Can you guys give me any hints how to solve this problem elegantly? import javax.enterprise.context.ApplicationScoped;

java.io.NotSerializableException when @ViewScoped is used

流过昼夜 提交于 2019-12-04 07:30:33
If I use @ViewScoped in JSF, then the following exception occurs: java.io.NotSerializableException: com.solv.basics.Basics java.io.ObjectOutputStream.writeObject0(Unknown Source) java.io.ObjectOutputStream.writeObject(Unknown Source) java.util.HashMap.writeObject(Unknown Source) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) java.lang.reflect.Method.invoke(Unknown Source) java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) java.io.ObjectOutputStream

Memory implications of OmniFaces ViewScoped bean?

别来无恙 提交于 2019-12-04 04:17:03
问题 From what I understand, ViewScoped beans only get destroyed when one of the following take place: 1) JSF sends a POST request to another page with something like a <h:commandLink...> 2) The number of open beans exceeds the maximum threshold setting (default of 15) 3) The user's session expires Here is my confusion: Does #1 mean that if a user navigates away from the page with a GET request, the bean will stay open, even if eventually a JSF POST happens in the same browser tab on another page?