view-scope

Memory leak with ViewScoped bean?

喜欢而已 提交于 2019-11-26 20:45:01
问题 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 -

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

五迷三道 提交于 2019-11-26 20:15:28
问题 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

How to replace @ManagedBean / @ViewScope by CDI in JSF 2.0/2.1

三世轮回 提交于 2019-11-26 19:53:57
I'm currently evaluating Java EE 6 / JSF 2.1 with RichFaces. A bean which is declared as @ManagedBean @ViewScoped Gets an ID set (to prepare e.g. a delete operation). Via JSF a confirmation popup is displayed. If the user confirms, the delete method is invoked and removes the row for which the ID was stored in step 1. Since CDI beans don't have a ViewScope I tried to declare the bean as: @Named @ConversationScoped Now the processing fails in step 3. because the value that was set in step 1 (checked that) is no longer available. Do I have to use Conversation.begin() and Conversation.end()

@ViewScoped bean recreated on every postback request when using JSF 2.2

China☆狼群 提交于 2019-11-26 13:46:57
I'm having an issue similar to this post and the answer from @BalusC with 3 solutions but: I'm not using of the mentioned EL expressions I don't want to go with the second solution (it's complex enough for me like this) and partial state saving is set to false. My code is as follows: index.xhtml : <?xml version="1.0" encoding="windows-1256" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun

Pass an object between @ViewScoped beans without using GET params

情到浓时终转凉″ 提交于 2019-11-26 10:29:25
I have a browse.xhtml where I browse a list of cars and I want to view the details of the car in details.xhtml when a "View more" button is pressed. Their backing beans are @ViewScoped and are called BrowseBean and DetailsBean , respectively. Now, I wouldn't like the user/client to see the car ID in the URL, so I would like to avoid using GET params, as presented here and here . Is there any way to achieve this? I'm using Mojarra 2.2.8 with PrimeFaces 5 and OmniFaces 1.8.1. BalusC Depends on whether you're sending a redirect or merely navigating. If you're sending a redirect, then put it in

How to replace @ManagedBean / @ViewScope by CDI in JSF 2.0/2.1

旧城冷巷雨未停 提交于 2019-11-26 08:07:30
问题 I\'m currently evaluating Java EE 6 / JSF 2.1 with RichFaces. A bean which is declared as @ManagedBean @ViewScoped Gets an ID set (to prepare e.g. a delete operation). Via JSF a confirmation popup is displayed. If the user confirms, the delete method is invoked and removes the row for which the ID was stored in step 1. Since CDI beans don\'t have a ViewScope I tried to declare the bean as: @Named @ConversationScoped Now the processing fails in step 3. because the value that was set in step 1

@ViewScoped calls @PostConstruct on every postback request

风格不统一 提交于 2019-11-25 22:38:44
问题 This doesn\'t seem right. I was doing some cleanup of my code and I just noticed this. Every ajax request is firing the constructor and @PostConstruct of my @ViewScoped bean. Even a simple database pagination is firing it. I understood that @ViewScoped is longer than @RequestScoped and that it shouldn\'t be reconstructed on every request. Only after a complete page reload by GET. 回答1: In other words, your @ViewScoped bean behaves like a @RequestScoped bean. It's been recreated from scratch on