view-scope

ViewScoped CDI bean recreated after some AJAX requests

假如想象 提交于 2019-12-10 11:56:21
问题 I have a CDI ViewScoped bean and a JSF page. After a couple of AJAX requests the bean somehow recreated. Here is the full code of the application: index.xhtml <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> <h:head> <title>Facelet Title</title> </h:head> <h:body> Hello from Facelets <h:form> <h:inputText value="#{questionBean.newTag}"></h:inputText> <h:commandButton value=

Injected Session Scoped Bean in View Scoped bean duplicating

大城市里の小女人 提交于 2019-12-10 11:28:49
问题 I have a ViewScoped bean and in this bean I am injecting a SessionScoped bean. A lot of information is found on this and is pretty straight forward. Session bean import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; @ManagedBean @SessionScoped public class Following implements Serializable { private HashMap<Integer, ArrayList<String>> followingThese; //Constructors and getters+setters ...

Why PostConstruct method is called several times inside an RichFaces 4.3 component with a ViewScoped?

倖福魔咒の 提交于 2019-12-08 13:34:41
问题 I 'm facing a problem with JSF 2.2, richfaces 4.3.2 on Tomcat 7 . My page is annoted ViewScoped . I display a first form. When i change the value and select a specific one , i display by ajax a rich:panel element inside an a4j:outputPanel . Inside this a4j:outputPanel and rich:panel component, i have a h:commandButton who execute the forms. I want to retrieve messages error for the form if the fields are empty for example (or other stuffs) But when i click h:commandButton , the view is re

Managed beans with custom ViewScope

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 06:22:12
问题 I'm doing a Web application using Spring 3.1.0.RELEASE, JSF 2.x, JPA 2 with Hibernate Provider. I use PrettyFaces 3.3.2 for friendly URL. The application run on Tomcat 6.35 . I wanted to use the Jsf ViewScope so I decided to follow the implementation found on the web : http://comdynamics.net/blog/109/spring3-jsf2-view-scope/ public class ViewScope implements Scope { private static final Logger logger = LoggerFactory.getLogger(ViewScope.class); @Override public Object get(String name,

@org.omnifaces.cdi.ViewScoped invokes @PostConstruct on unload of an already destroyed view

你离开我真会死。 提交于 2019-12-07 11:33:25
I have a problem working with @org.omnifaces.cdi.ViewScoped and multiple tabs: I have a link in TestPage.xhtml that opens another page (ShowValuePage.xhtml) with a request parameter "someValue". If I open this link 10 times in a new tab and navigate away in the first opened tab, PostConstruct will be called again instead of just navigating away. Same happens if I navigate back from ShowValuePage to TestPage multiple times. (To test this, we must click the links "Show Value" and "Home" multiple times). This only happens if more tabs are opened than defined in the web.xml values

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

我的未来我决定 提交于 2019-12-07 08:39:05
问题 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="#

Managed beans with custom ViewScope

怎甘沉沦 提交于 2019-12-06 16:49:35
I'm doing a Web application using Spring 3.1.0.RELEASE, JSF 2.x, JPA 2 with Hibernate Provider. I use PrettyFaces 3.3.2 for friendly URL. The application run on Tomcat 6.35 . I wanted to use the Jsf ViewScope so I decided to follow the implementation found on the web : http://comdynamics.net/blog/109/spring3-jsf2-view-scope/ public class ViewScope implements Scope { private static final Logger logger = LoggerFactory.getLogger(ViewScope.class); @Override public Object get(String name, ObjectFactory objectFactory) { final Map<String, Object> viewMap = FacesContext.getCurrentInstance()

@ViewScoped creating new instance on every postback

眉间皱痕 提交于 2019-12-06 12:36:31
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 I make to better it. @ManagedBean(name = "file") @ViewScoped public class FileController implements Serializable { private static final long serialVersionUID = 1L; private List<LoadFileLog> fileList = null; private Date selectedDate; FileDAO fileDAO; public FileController() { System.out.println(" In file Controller constructor"); ServletContext

Restoring request parameters in @ViewScoped bean after session expires

不想你离开。 提交于 2019-12-06 07:06:51
问题 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

Inject CDI bean into JSF @ViewScoped bean

落花浮王杯 提交于 2019-12-06 03:44:24
问题 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