@ViewScoped behaves like @SessionScoped

Locked
sdguna
Posts: 41
Joined: 06 May 2010, 17:42

20 Jun 2016, 18:21

Hi,

I was using p:layout and menu items. No we are migrating to PF sentinel. The problems is we are loading the pages dynamically through backing bean with ui:include. These were working properly now during the migration we found that @viewScoped beans are behaving like @SessionScoped basically the beans are not destroyed.

Is there I can do diffrently to get it to work

Code: Select all

 
<ui:composition 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ps="http://primefaces.org/sentinel"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">

    <div id="layout-menubar" class="Unselectable fontRegular">
        <div class="layout-menubarinner-box" id="buttonArea">
            <a href="#" id="layout-menubar-resize" class="BordRad3" title="Menu Resize"><i class="icon-th-list-2"></i></a>
            <a href="#" id="layout-menubar-resize2" class="BordRad3" title="Open Menu"><i class="icon-menu"></i></a>
        </div>

        <div class="layout-menubarinner-box" id="searchArea">
            <i class="icon-search floatLeft gray"></i>
            <input type="text" class="layout-menubar-search floatLeft Animated05" placeholder="Search Here"/>
        </div>

        <h:form id="menuform">
            <ps:menu id="sm_leftmenu">
                <p:submenu id="sm_master" label="#{bundle.Master}" icon="icon-database" >
                    <p:menuitem value="#{bundle.Company}" action="#{homePageBean.handleCommandLink()}" update=":content" icon="">
                        <f:param name="centerSrc" value="/master/Company.xhtml" />
                    </p:menuitem>
                    <p:menuitem value="#{bundle.Customer}" action="#{homePageBean.handleCommandLink()}" update=":content" icon="">
                        <f:param name="centerSrc" value="/master/Customer.xhtml" />
                    </p:menuitem>
                    <p:menuitem value="#{bundle.Supplier}" action="#{homePageBean.handleCommandLink()}" update=":content" icon="">
                        <f:param name="centerSrc" value="/master/Supplier.xhtml" />
                    </p:menuitem>
                    <p:menuitem value="#{bundle.Employee}" action="#{homePageBean.handleCommandLink()}" update=":content" icon="">
                        <f:param name="centerSrc" value="/master/Employee.xhtml" />
                    </p:menuitem>
</p:submenu>
</ps:menu>
basically the homePagebean takes the param and send it back.

Code: Select all

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/WEB-INF/template.xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:p="http://primefaces.org/ui">

    <ui:define name="content">
        <p:outputPanel id="content">
            <ui:include src="#{homePageBean.centerSrc}"/>
        </p:outputPanel>
    </ui:define>

</ui:composition>
Template .xhtml

Code: Select all

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
 
    <h:head>
        <f:facet name="first">
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
            <meta name="apple-mobile-web-app-capable" content="yes" />
        </f:facet>
        <title>Bati EKKO LACHIVER</title>
        <h:outputScript name="js/layout.js" library="sentinel-layout" />
        <ui:insert name="head" />
    </h:head>

    <h:body>        
        <ui:include src="topbar.xhtml" />

        <ui:include src="leftmenu.xhtml" />

        <div id="layout-portlets-cover" class="fontRegular">
            <ui:insert name="content">
               Template
            </ui:insert>
        </div>
        
        <p:ajaxStatus style="width:32px; height:32px; position:fixed; right:12px; bottom:10px">
            <f:facet name="start">
                <p:graphicImage name="images/preloader.gif" library="sentinel-layout"/>
            </f:facet>

            <f:facet name="complete">
                <h:outputText value="" />
            </f:facet>
        </p:ajaxStatus>

        <h:outputStylesheet name="css/font-icon-layout.css" library="sentinel-layout" />
        <h:outputStylesheet name="css/sentinel-layout.css" library="sentinel-layout" />
        <h:outputStylesheet name="css/core-layout.css" library="sentinel-layout" />
    </h:body>

</html>
A navigation rule is set in the faces-config.xml, I tested it by removing the rule but the same behavior

Code: Select all

<managed-bean>
        <managed-bean-name>HomePageBean</managed-bean-name>
        <managed-bean-class>Utility.HomePageBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <from-view-id>/Home.xhtml</from-view-id> 
        <navigation-case>
            <from-action>#{homePageBean.handleCommandLink}</from-action>
            <to-view-id>>/Home.xhtml</to-view-id>
            <redirect></redirect>
        </navigation-case>
    </navigation-rule>

Locked

Return to “Sentinel”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests