view-scope

JSF: Mojarra vs. OmniFaces @ViewScoped: @PreDestroy called but bean can't be garbage collected

柔情痞子 提交于 2019-11-28 10:33:54
This question is specific to the OmniFaces @ViewScoped bean (however of interest to wider discussion about memory leakage and resource disposal with JSF @ViewScoped). It is based on the results of this NetBeans8.1 test web app available on GitHub: Investigation of undesirable holding of references to various forms of JSF @ViewScoped beans by navigation type https://github.com/webelcomau/JSFviewScopedNav That test web app has a comprehensive README with complete instructions, as well as annotated test web pages comparing obsolete JSF2.0-style @ManagedBean @ViewScoped , JSF2.2-style CDI-friendly

ViewScoped bean getting constructed on every request… part 99 [duplicate]

丶灬走出姿态 提交于 2019-11-28 05:09:11
问题 This question already has an answer here : @ViewScoped calls @PostConstruct on every postback request (1 answer) Closed 3 years ago . ARGH... This seems to have a hundred answers and I haven't found one that works for me, so I guess I will actually ask it again. Here is my scenario: My site technically has a single page whose contents get swapped out rather than having multiple pages that you navigate to. The starting point is this chunk: <?xml version="1.0" encoding="UTF-8"?> <f:view xmlns:f

PrimeFaces p:media not working with StreamedContent in a @ViewScoped bean

可紊 提交于 2019-11-28 01:51:42
问题 I have an issue related to Primefaces4 meida type rendering pdf file in browser. I have successfully tried the example in showcase from primefaces website. Now I want to get a new feature, which offers an tree structure with document nodes in the left panel. User could select one document to display it in the center panel. That means it generates pdf media field in backbean once user selects on one document on the tree. related code is shown below: backbean: @ManagedBean @ViewScoped public

Why are expired @ViewScoped beans not destroyed until the session expires

回眸只為那壹抹淺笑 提交于 2019-11-28 01:08:27
I'm using Mojarra 2.2.4 on GlassFish 4 with Java 7. As I understand from BalusC's answer to How and when is a @ViewScoped bean destroyed in JSF? , @ViewScoped beans should be destroyed in three cases: Post-back with non-null outcome Session expiration Maximum number of logical views in session exceeded My beans are being destroyed in the first two cases, but not when the maximum number of logical views is exceeded. I have verified that the beans do expire when the maximum is exceeded (I get a ViewExpiredException), but they are still not destroyed until the session itself expires. For memory

Memory leak with ViewScoped bean?

≡放荡痞女 提交于 2019-11-27 21:38:45
In our JavaEE6 project ( EJB3 , JSF2 ) on JBoss 7.1.1 , it seems we have a memory leak with SeamFaces @ViewScoped . We made a little prototype to check the fact : we use JMeter to call a page 200 times; the page contains and calls a viewscoped bean which injects a stateful EJB; we fix the session timeout at 1 minute. At the end of the test, we check the content of the memory with VisualVM, and here what we got: with a @ViewScoped bean, we still get 200 instances of the stateful MyController - and the @PreDestroy method is never called; with a @ConversationScoped bean, @preDestroy method is

How detect and remove (during a session) unused @ViewScoped beans that can't be garbage collected

一笑奈何 提交于 2019-11-27 20:17:13
EDIT: The problem raised by this question is very well explained and confirmed in this article by codebulb.ch, including some comparison between JSF @ViewScoped , CDI @ViewSCoped , and the Omnifaces @ViewScoped , and a clear statement that JSF @ViewScoped is 'leaky by design': May 24, 2015 Java EE 7 Bean scopes compared part 2 of 2 EDIT: 2017-12-05 The test case used for this question is still extremely useful, however the conclusions concerning Garbage Collection in the original post (and images) were based on JVisualVM, and I have since found they are not valid. Use the NetBeans Profiler

@PostConstruct method is called even if the ManagedBean has already been instantiated (e.g. on AJAX-calls) [duplicate]

跟風遠走 提交于 2019-11-27 15:14:09
问题 This question already has an answer here: @ViewScoped calls @PostConstruct on every postback request 1 answer I have a @ViewScope ManagedBean and a @PostConstruct initialisation method. This method is called when a new instance is created, but also on every ajax call. Why is this so? On an AJAX-call the init-Method is called and executed, but no changes are visible. For example if I change a property in the init-Method, this is only visible on instatiation and not for AJAX-calls. For AJAX

JSF View scope in Spring

点点圈 提交于 2019-11-27 04:26:47
Is there any scope like JSF @ViewScoped in Spring 3.0? I have an application using JSF+Spring where backing beans are managed by Spring. I didn't find any scope like JSF wiew scope in Spring. I saw the blog Porting JSF 2.0’s ViewScope to Spring 3.0 , but it didn't work for me. Here's my attempt on the custom Spring scope: import java.util.Map; import javax.faces.context.FacesContext; import org.springframework.beans.factory.ObjectFactory; import org.springframework.beans.factory.config.Scope; /** * Implements the JSF View Scope for use by Spring. This class is registered as a Spring bean with

Why does @PostConstruct callback fire every time even though bean is @ViewScoped? JSF

℡╲_俬逩灬. 提交于 2019-11-27 03:34:44
I am using datatable on page and using binding attribute to bind it to my backing bean. This is my code :- <?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://java.sun.com/jsf/html" xmlns:p="http://primefaces.prime.com.tr/ui"> <h:head> <title>Facelet Title</title> </h:head> <h:body> <h:form prependId="false"> <h:dataTable var="item" value="#{testBean.stringCollection}" binding="#{testBean.dataTable}"> <h:column> <h:outputText

Why are expired @ViewScoped beans not destroyed until the session expires

故事扮演 提交于 2019-11-26 21:50:40
问题 I'm using Mojarra 2.2.4 on GlassFish 4 with Java 7. As I understand from BalusC's answer to How and when is a @ViewScoped bean destroyed in JSF?, @ViewScoped beans should be destroyed in three cases: Post-back with non-null outcome Session expiration Maximum number of logical views in session exceeded My beans are being destroyed in the first two cases, but not when the maximum number of logical views is exceeded. I have verified that the beans do expire when the maximum is exceeded (I get a