Questions tagged [view-scope]

The View Scope means that you can keep the object alive as long as you are staying on the view (page).

The @ViewScoped has been introduced by JSF 2.0 specification. In a nutshell the data which is @ViewScoped will keep living as long as you don't navigate to another page to itself. The view scope is very convenient, since it allows the pattern of initializing data when you first access a page (via a non-faces request, which is typically a GET request) and then keep that data when you work on the page, doing post-backs, AJAX requests, etc.

258 questions
3
votes
1 answer

recreates @ViewScoped bean on every request

I am using Primefaces fileUpload component in advanced mode to upload multiple images. When i select few files and press upload button, my @ViewScoped managed bean recreates multiple times. That is a problem for me, because i want to store…
duytsev
  • 31
  • 3
3
votes
0 answers

Why we need Serializable for ViewScoped bean and don't need it for SessionScoped?

We have a RequestScoped managed bean working fine. We want to convert it to ViewScoped so that we can reduce initializing the bean every time we call listener method. But when we changed the scope we got NotSerializable error, because we have…
nani21984
  • 911
  • 2
  • 13
  • 21
3
votes
1 answer

p:remoteCommand destroys @ViewScoped managed bean

I am having trouble adding a p:remoteCommand to a form. It looks something like:
Jürgen Simon
  • 876
  • 1
  • 12
  • 35
3
votes
3 answers

how to use ViewScoped bean in SesionScoped bean?

I have Three managed bean: One session scoped (S) and Two view scoped (A,B). I want to use A's functionality in both S and B. but the problem is that injecting view scoped bean in session scoped one is impossible. The scope of the object referenced…
Farvardin
  • 5,336
  • 5
  • 33
  • 54
3
votes
1 answer

Memory implications of OmniFaces ViewScoped bean?

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 2) The number of open beans exceeds the maximum threshold setting…
Greg H
  • 445
  • 4
  • 12
3
votes
1 answer

jsf2 ViewScoped bean initialization

I'm new to jsf technology and I'm trying to understand when and how the ViewScoped jsf bean is initialized. I have a sample app with 2 beans ApplicationScopedBean.java @ManagedBean @ApplicationScoped public class ApplicationScopedBean implements…
ivstas
  • 1,203
  • 1
  • 16
  • 31
3
votes
1 answer

JSF's javax.faces.ViewState antipatterns

This question probably does not fit SO rules, but I'll ask it anyway. Answers might help other people struggling with JSF. We are using JSF (MyFaces, PrettyFaces, PrimeFaces and Spring) on one of our biggest project for two years now (migrated from…
Pavel Horal
  • 17,782
  • 3
  • 65
  • 89
3
votes
0 answers

Why is my @ViewScoped bean being referenced on browser refresh after bean destroyed and POST to render new page?

First of all, I am using OmniFaces CDI @ViewScoped which was recently added to and released in OmniFaces 1.6. I am very pleased to use OmniFaces CDI @ViewScoped in my app, but I have a question. I noticed some NullPointerException's in my (TomEE 1.6…
Howard
  • 792
  • 8
  • 43
3
votes
2 answers

ViewExpiredException when i use @ViewScoped

I have problem with my h:commandButton "Login": when I use @ViewScoped and push this button there is ViewExpiredException, but when I use @SessionScoped, there isn't any error. Stack Trace: javax.faces.application.ViewExpiredException:…
kuba44
  • 1,838
  • 9
  • 34
  • 62
3
votes
2 answers

Does f:viewParam only pass query string in url when first page uses the same managed bean as the second page?

Let's use a search page and a results page for example. If i have a ViewScoped bean that handles my search page and my results page, i'm able to pass parameters through the url using something like this: search.xhtml
Catfish
  • 18,876
  • 54
  • 209
  • 353
3
votes
2 answers

Persisting ViewScoped beans across multiple views

Ok I know scope questions come up all the time but I'm interested in a slightly different approach to the solution. The @ViewScope is a fantastic bridge between the @RequestScope and the @SessionScope. However there is still a common use case (at…
tarka
  • 5,289
  • 10
  • 51
  • 75
3
votes
1 answer

Destroying view-scoped beans when session ends

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…
Kawu
  • 13,647
  • 34
  • 123
  • 195
2
votes
3 answers

@ViewScoped creating new instance on every postback

I am having the below managed bean. But every time I do a post back to the same bean ie while calling updateFileList. I get a new instance of FileDAO. How can I prevent this? Is it safe to have a DAO inside a managed bean, if not what changes can…
user1109536
  • 97
  • 3
  • 6
2
votes
2 answers

@ManagedProperty on #{param} does not work in @ViewScoped

My bean has this: @ManagedBean @ViewScoped public class BookBean implements Serializable { @ManagedProperty(value = "#{param.id}") // does not work with @ViewScoped private String id; public void init() { id =…
ChuongPham
  • 4,761
  • 8
  • 43
  • 53
2
votes
0 answers

EJB in ViewScoped CDI bean in clustered environment (Hazelcast on Payara) - gives NotSerializableException WARN

After activating HA on Payara (Hazelcast) I have noticed the following WARN messages in the log: [2017-12-12T15:12:31.266+0800] [Payara 4.1] [WARNING] [] [javax.enterprise.web.core] [tid: _ThreadID=63…
AndrewG10i
  • 661
  • 1
  • 6
  • 21