Migration of jsf 2.0 app to JSF 2.2 and WAS9 Composite Component Not firing event - primefaces

I have an app that has been running fine until we migrated to WAS9 app server(which uses jsf2.2 by default).
The app has a composite component which contains a primefaces:autosuggest widget. The widget stopped "firing" the itemSelect event. The ajaxListener is never firing.
Everything I see says that it is coded correctly, but nothing.
I have tried adding the "change" event, but that event also never fires.
The only thing I have been able to make work is to make it a regular listener
<cc:attribute name="ajaxLocationListener" method-signature="void listener()"/>
but then I do not have access to the data on the event that I need.
This is the implementation of the composite component:
<com:stopComponent id="Origin"
customerKey="#{templateController.ordrBeanUI.orderHeaderUI.customerUniqueKey}"
stop="#{templateController.ordrBeanUI.orderStopListUI.orderStopList[0]}"
options="#{templateController.custOptionsBean.countryCodesBean}"
mode="#{templateController.ordrBeanUI.orderHeaderUI.shippingMode}"
intlModeFlag="#{templateController.ordrBeanUI.orderHeaderUI.intlModeFlag}"
docType="#{templateController.ordrBeanUI.orderHeaderUI.documentType}"
addressBookAction="#{templateController.addressBookLookUp}"
saveAddressAction="#{templateController.saveAddressBook}"
lookAheadAction="#{templateController.obtainLocationList}"
ajaxListener="#{templateController.handleSelect}"
>
<f:ajax execute="Origin" render="originPanel" onevent="setOrderFieldFlagsAjax"/>
</com:stopComponent>
The actual StopComponent is here:
<html xmlns:x="http://www.w3.org/1999/xhtml"
xmlns:cc="http://xmlns.jcp.org/jsf/composite"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:lf="http://websphere.landstar.com/jsf"
xmlns:com="http://xmlns.jcp.org/jsf/composite/components">
<cc:interface displayName="locationSection">
<cc:attribute name="customerKey" type="java.lang.Integer" />
<cc:attribute name="stop" type="com.landstar.cust.orders.beans.OrderStopUI" required="true" />
<cc:attribute name="options" type="com.landstar.cust.orders.beans.CountryCodesSelectOptionsBean" required="true" />
<cc:attribute name="mode" type="java.lang.String" required="true" />
<cc:attribute name="intlModeFlag" type="java.lang.Boolean" required="true" />
<cc:attribute name="docType" type="java.lang.String" />
<cc:attribute name="addressBookAction" method-signature="void actionListener(javax.faces.event.AjaxBehaviorEvent)" required="true"/>
<cc:attribute name="saveAddressAction" method-signature="void actionListener(javax.faces.event.ActionEvent)" />
<cc:attribute name="lookAheadAction" method-signature="java.util.List obtainAddress(java.lang.String)" />
<cc:attribute name="ajaxListener" method-signature="void actionListener(javax.faces.event.AjaxBehaviorEvent)" />
<cc:clientBehavior name="click" event="action" targets="saveLink" />
<cc:clientBehavior name="itemSelect" event="itemSelect" targets="stopLocationID stopLocationName" />
<cc:clientBehavior name="dateSelect" event="dateSelect" targets="#{cc.clientId}_fromDate #{cc.clientId}_toDate" />
</cc:interface>
<p:autoComplete id="stopLocationName" value="#{cc.attrs.stop.selectedLocationName}" minQueryLength="3"
completeMethod="#{cc.attrs.lookAheadAction}" forceSelection="false"
var="p" itemLabel="#{p.locationText}" itemValue="#{p}" size="32" maxlength="30"
converter="locationConverter">
<f:attribute name="customerKey" value="#{cc.attrs.customerKey}" />
<f:attribute name="searchType" value="locationName" />
<f:attribute name="mode" value="#{cc.attrs.mode}" />
<f:attribute name="geoType" value="#{cc.attrs.stop.stopInternational}" />
<f:attribute name="stopType" value="#{cc.clientId}"/>
<p:ajax event="itemSelect" listener="#{cc.attrs.ajaxLocationListener}" update="stopComponent" oncomplete="setOrderFieldFlagsPrimeFaces(xhr,status,args)" />
</p:autoComplete>
The Backing Bean is here:
#ManagedBean(name="orderController")
#ViewScoped
public class OrderController extends DocumentController implements Serializable {
}
public class DocumentController extends DateTimeConversions implements Serializable {
...
public void handleSelect(SelectEvent event) {
String stopType = event.getComponent().getClientId();
String calledFrom = "lookAhead";
populateLocationFromAddressBook(stopType, calledFrom,
((LocationLookAheadBean) event.getObject()).getLocationAddressUniqueKey());
String stopTypeStr = "";
if (stopType != null && !stopType.trim().equals("")) {
stopTypeStr = stopType.trim().substring(0, stopType.trim().indexOf(":"));
}
RequestContext context = RequestContext.getCurrentInstance();
context.addCallbackParam("location", stopTypeStr);
}
}

Related

TomEE Plume 7 - JSF 2.2 navigation rules and redirects don't work - primefaces 6.1 + omnifaces 2.6.4

I have the following jsf login page:
<h:form id="frmAdmLogin" styleClass="form-horizontal">
<div class="ui-layout-center" style="margin-left: 15px;">
<p:messages id="messagesLogin" autoUpdate="true" closable="true" />
<h:panelGrid cellpadding="5">
<p:inputText id="txtUsuario" required="true" value="#{loginDataManager.usuario}" />
<p:password id="pssClave" required="true" value="#{loginDataManager.password}" />
<h:selectOneMenu id="lstSucursales" required="true" value="# {loginDataManager.idSucursal}">
<f:selectItem itemLabel="" itemValue="" />
<f:selectItems value="#{loginController.listadoCatalogos()}" var="sucursal" itemLabel="#{sucursal.nomCatalogo}" itemValue="#{sucursal.id}" />
</h:selectOneMenu>
<p:commandButton id="loginButton" value="Ingresar" action="#{loginController.login()}" />
</h:panelGrid>
</div>
<div id="barras">
<ui:include src="/templates/main/barras.xhtml" />
</div>
</h:form>
After user logs in the application, it should redirect to the main page. But It doesn't work.
For navigate I use the following navigation rules:
<navigation-rule>
<from-view-id>/login/login.xhtml</from-view-id>
<navigation-case>
<from-action>#{loginController.login()}</from-action>
<from-outcome>login</from-outcome>
<to-view-id>/login/login.xhtml</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-action>#{loginController.login()}</from-action>
<from-outcome>exito</from-outcome>
<to-view-id>/login/main.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
I have a CDI bean which has the login method:
public String login() {
validarUsuario();
try {
obtenerMenu(sessionDataManagerBase.getUserDto());
return "exito";
} catch (Exception e) {
log.error("", e);
MessagesController.addError(null, "Error al consultar las opciones de menĂº para el usuario");
FacesContext.getCurrentInstance().validationFailed();
return "login";
}
}
Tomee starts with no errors, and when I click the login button nothing happens: no navigation, no errors in the browser and no errors in Tomee log.
There's something I'm missing in my configuration.
Thanks.

Very slow network response times for TomEE/Primefaces App

We have developed a web application using TomEE 1.5.2 Plus (myfaces 2.1.13) and Primefaces 3.5. Performance is acceptable with typical server response times of about 70ms. When moving to TomEE 7.0.0-M3 Plus (myfaces 2.2.9) and Primefaces 5.3, these response times are now up to 900ms. Using the Firefox Web Console on the Network tab, these timings are all Waiting with 0ms Receive time. These appear to be p:remoteCommand server requests. Our app has many p:dialog user interfaces with managed View Scoped Beans. The more dialogs with p:remoteCommands the worse the performance.
I have tried TomEE 7.0.1 Plus (myfaces 2.2.10 and Primefaces 6.0 with no better results. Test apps have shown that a simple dialog using a button and a p:remoteCommand to increment a counter and update the form and scaled from 20 dialogs, beans and buttons to 40 doubles the wait times (50ms to 100ms) using TomEE 7.0.0 and Primefaces 5.3. The same code run on TomEE 1.5.2 and Primefaces 3.5 shows no difference (30ms).
When building with facesContext.application.projectStage = Development or Production in the TomEE 1.5.2/Primefaces 3.5 environment there is no difference. Production times are about 10% better in Production mode using TomEE 7.0.0/Primefaces 5.3. Sample test app code below:
Main App
<!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:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:cc="http://java.sun.com/jsf/composite/components">
<h:head>
<title>COUNTER</title>
</h:head>
<h:body>
<ui:include src="/Dialogs/counterDialog.xhtml" />
<ui:include src="/Dialogs/counterDialog2.xhtml" />
<ui:include src="/Dialogs/counterDialog3.xhtml" />
<ui:include src="/Dialogs/counterDialog4.xhtml" />
<ui:include src="/Dialogs/counterDialog5.xhtml" />
<ui:include src="/Dialogs/counterDialog6.xhtml" />
<ui:include src="/Dialogs/counterDialog7.xhtml" />
<ui:include src="/Dialogs/counterDialog8.xhtml" />
<ui:include src="/Dialogs/counterDialog9.xhtml" />
<ui:include src="/Dialogs/counterDialog10.xhtml" />
<ui:include src="/Dialogs/counterDialog11.xhtml" />
<ui:include src="/Dialogs/counterDialog12.xhtml" />
<ui:include src="/Dialogs/counterDialog13.xhtml" />
<ui:include src="/Dialogs/counterDialog14.xhtml" />
<ui:include src="/Dialogs/counterDialog15.xhtml" />
<ui:include src="/Dialogs/counterDialog16.xhtml" />
<ui:include src="/Dialogs/counterDialog17.xhtml" />
<ui:include src="/Dialogs/counterDialog18.xhtml" />
<ui:include src="/Dialogs/counterDialog19.xhtml" />
<ui:include src="/Dialogs/counterDialog20.xhtml" />
<h:form id="countForm">
<input id="clickMe" type="button" value="clickMe" onclick="openCounterDialog();" />
<h:outputText id="count" value="#{counter.count}" />
<input id="clickMe2" type="button" value="clickMe2" onclick="openCounterDialog2();" />
<h:outputText id="count2" value="#{counter2.count}" />
<input id="clickMe3" type="button" value="clickMe3" onclick="openCounterDialog3();" />
<h:outputText id="count3" value="#{counter3.count}" />
<input id="clickMe4" type="button" value="clickMe4" onclick="openCounterDialog4();" />
<h:outputText id="count4" value="#{counter4.count}" />
<input id="clickMe5" type="button" value="clickMe5" onclick="openCounterDialog5();" />
<h:outputText id="count5" value="#{counter5.count}" />
<input id="clickMe6" type="button" value="clickMe6" onclick="openCounterDialog6();" />
<h:outputText id="count6" value="#{counter6.count}" />
<input id="clickMe7" type="button" value="clickMe7" onclick="openCounterDialog7();" />
<h:outputText id="count7" value="#{counter7.count}" />
<input id="clickMe8" type="button" value="clickMe8" onclick="openCounterDialog8();" />
<h:outputText id="count8" value="#{counter8.count}" />
<input id="clickMe9" type="button" value="clickMe9" onclick="openCounterDialog9();" />
<h:outputText id="count9" value="#{counter9.count}" />
<input id="clickMe10" type="button" value="clickMe10" onclick="openCounterDialog10();" />
<h:outputText id="count10" value="#{counter10.count}" />
<div>
<input id="clickMe11" type="button" value="clickMe11" onclick="openCounterDialog11();" />
<h:outputText id="count11" value="#{counter11.count}" />
<input id="clickMe12" type="button" value="clickMe12" onclick="openCounterDialog12();" />
<h:outputText id="count12" value="#{counter12.count}" />
<input id="clickMe13" type="button" value="clickMe13" onclick="openCounterDialog13();" />
<h:outputText id="count13" value="#{counter13.count}" />
<input id="clickMe14" type="button" value="clickMe14" onclick="openCounterDialog14();" />
<h:outputText id="count14" value="#{counter14.count}" />
<input id="clickMe15" type="button" value="clickMe15" onclick="openCounterDialog15();" />
<h:outputText id="count15" value="#{counter15.count}" />
<input id="clickMe16" type="button" value="clickMe16" onclick="openCounterDialog16();" />
<h:outputText id="count16" value="#{counter16.count}" />
<input id="clickMe17" type="button" value="clickMe17" onclick="openCounterDialog17();" />
<h:outputText id="count17" value="#{counter17.count}" />
<input id="clickMe18" type="button" value="clickMe18" onclick="openCounterDialog18();" />
<h:outputText id="count18" value="#{counter18.count}" />
<input id="clickMe19" type="button" value="clickMe19" onclick="openCounterDialog19();" />
<h:outputText id="count19" value="#{counter19.count}" />
<input id="clickMe20" type="button" value="clickMe20" onclick="openCounterDialog20();" />
<h:outputText id="count20" value="#{counter20.count}" />
</div>
</h:form>
</h:body>
</html>
Dialog
<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:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:cc="http://java.sun.com/jsf/composite/components">
<p:dialog
id="counterDialog1"
header="Counter Form"
widgetVar="counterWidget"
closeOnEscape="true" >
<p:ajax
event="close"
listener="#{counter.buttonHit()}"
update="counterForm"
resetValues="true" />
<h:form id="counterForm">
<p:panel id="counterPanel">
<input id="countMe" type="button" value="countMe" onclick="customfunction();" />
<p:remoteCommand name="increment" actionListener="#{counter.increment}" update=":countForm" />
</p:panel>
<div
align="center"
style="padding: 5px">
<p:commandButton
id="counterOK"
value="Ok"
cache="false"
ajax="true"
style="valign:bottom;float:left;padding-left:10px"
onclick="closeCounterDialog()" />
<p:commandButton
id="counterCancel"
value="Cancel"
style="valign:bottom;float:center;padding-right:10px"
onclick="closeCounterDialog()"
process="#this">
</p:commandButton>
<p:commandButton
id="counterHelp"
value="Help"
style="valign:bottom;float:right;padding-right:10px"
disabled="true">
</p:commandButton>
<p:defaultCommand
target="counterOK" />
</div>
</h:form>
</p:dialog>
<script type="text/javascript">
//<![CDATA[
// Keep script tag outside of any component tag that may need to get updated
// so JavaScript objects are not recreated. E.g. removing event handlers
// won't work after update since handler function is a different intance
function openCounterDialog ( event )
{
counterWidget.show();
}
/**
* Remove all the relevant event listeners, re-enable normal behavior and
* hide the dialog
*/
function closeCounterDialog ()
{
counterWidget.hide();
}
function customfunction()
{
//your custom code
increment(); //makes a remote call
}
//]]>
</script>
</ui:composition>
Managed Bean Class
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.primefaces.context.RequestContext;
#ManagedBean(name = "counter")
#ViewScoped
public class Counter implements Serializable
{
/** Prevents compiler generating brittle one */
private static final long serialVersionUID = -2L;
int count;
public Counter()
{
count = 0;
}
public void increment()
{
count++;
}
public int getCount()
{
return count;
}
public void buttonHit()
{
RequestContext.getCurrentInstance ().execute ( "closeCounterDialog()" );
}
}
Any ideas? Thank you in advance!
Some versions of primefaces creates one bean validation Validator per request. If it is customized - it is often the case for JSF environments - it will really slow down the application. Ensure you use one version which doesn't have this issue.
Here is the related issue: https://github.com/primefaces/primefaces/issues/1119

Control on Calendar Primefaces component

I am using p:calendar Primefaces component for specifying 2 dates : start and end.
An evident control is to verify if end date is not before start date.
Is there a way to do it ?
I found the solution :
<p:outputLabel for="startDate" value="#{msg.StartDate}" />
<p:calendar id="startDate" value="#{employeeBean.employee.startDate}" required="true" pattern="dd-MM-yyyy" language="#{msg.CalendarLanguage}" mask="true"
requiredMessage="#{msg.required}">
<p:ajax event="dateSelect" update="endDate" />
</p:calendar>
<p:message for="startDate" />
<p:outputLabel for="endDate" value="#{msg.EndDate}" />
<p:calendar id="endDate" mindate="#{employeeBean.employee.startDate}" value="#{employeeBean.employee.endDate}" required="false" pattern="dd-MM-yyyy"
language="#{msg.CalendarLanguage}" mask="true">
</p:calendar>
<p:message for="endDate" />

Make the outline of a input "red" if field is empty

I use primefaces 4, template : cupertino.
I want to make the outline of a input "red" if field is empty.
I upgraded to type field required = "true", but the outline remain in their original state if they are empty.
But for fields of type HTML 5 all goes well.
Thank you.
<form id="form_inscri_pp" name="form_inscri_pp">
<h:panelGrid columns="2" cellpadding="5" >
<h:outputText value="Nom:" styleClass="label_inscri_pp"/>
<input id="nom_pp" class='inscription_candidat'
placeholder='Saisissez votre nom' type='text' name="nom_pp"
pattern="^[A-Za-z ]+$" maxlength="25" required="required"
autocomplete="on"/>
<h:outputText value="Date de naissance: " styleClass="label_inscri_pp"/>
<p:calendar name="DN_pp" id="DN_pp" value="#{calendrier.date}"
locale="fr" showOn="button" navigator="true"
pattern="dd/MM/yyyy" mindate="1/1/1950" maxdate="31/12/1993"
mask="true" required="true" readonly="true" size="20" />
</h:panelGrid>
<input class='button_inscri' type='submit' value="S'inscrire" />
<input class='button_inscri' type='button' value='RĂ©initialiser' />
</form>
According the code you post, the input text with id nom_pp get red-outlined when I input nothing. The only thing that won't work is p:calendar, which is because you put a readonly attribute in it.
So the solution is simply remove the readonly attribute of the p:calendar.
And BTW, there is no name attribute in p:calendar, so remove it, too.
What's more, you need to use <h:form> instead of <form>. And there is also no name parameter in <h:form>.
So you code should looks like:
<h:form id="form_inscri_pp" >
<h:panelGrid columns="2" cellpadding="5" >
<h:outputText value="Nom:" styleClass="label_inscri_pp"/>
<input id="nom_pp" class='inscription_candidat'
placeholder='Saisissez votre nom' type='text' name="nom_pp"
pattern="^[A-Za-z ]+$" maxlength="25" required="required"
autocomplete="on"/>
<h:outputText value="Date de naissance: " styleClass="label_inscri_pp"/>
<p:calendar id="DN_pp" value="#{inputValidateBean.date}"
locale="fr" showOn="button" navigator="true"
pattern="dd/MM/yyyy" mindate="1/1/1950" maxdate="31/12/1993"
mask="true" required="true" size="20" />
</h:panelGrid>
<input class='button_inscri' type='submit' value="S'inscrire" />
<input class='button_inscri' type='button' value='RĂ©initialiser' />
</h:form>
UPDATE
Since the solution above doesn't work in your environment, try to replace all HTML5 components to primeface/jsf components.
I tried that and it also works in my environment.
Take a look at this:
<h:form id="form_inscri_pp" >
<h:panelGrid columns="2" cellpadding="5" >
<h:outputText value="Nom:" styleClass="label_inscri_pp"/>
<p:inputText id="nom_pp" styleClass="inscription_candidat"
placeholder="Saisissez votre nom" maxlength="25"
required="true" autocomplete="on" value="#{inputValidateBean.nom}">
<f:validateRegex pattern="^[a-zA-Z]+$" />
</p:inputText>
<h:outputText value="Date de naissance: " styleClass="label_inscri_pp"/>
<p:calendar id="DN_pp" value="#{inputValidateBean.date}"
locale="fr" showOn="button" navigator="true"
pattern="dd/MM/yyyy" mindate="1/1/1950" maxdate="31/12/1993"
mask="true" required="true" size="20" />
</h:panelGrid>
<p:commandButton styleClass="button_inscri" value="S'inscrire"
validateClient="true" update="form_inscri_pp"
action="#{inputValidateBean.doSubmit()}"/>
</h:form>
In the backing bean:
#ManagedBean
#ViewScoped
public class InputValidateBean implements Serializable{
private Date date;
private String nom;
public void doSubmit(){
System.out.println("Do something!");
}
//getters and setters below...

Changing ActiveIndex in TabMenu

I'm using Primefaces 3.5 and have run into an issue with changing the ActiveIndex. ActiveIndex doesn't change when going between tabs. This is my TabMenu code:
<h:form id="formMenu">
<p:tabMenu id="tabMenu" activeIndex="#{toolbarBean.currentTab}">
<p:menuitem value="Main" action="#{toolbarBean.changeActiveIndex(0)}" />
<p:menuitem value="Page2" action="#{toolbarBean.changeActiveIndex(1)}" />
<p:menuitem value="Page3" actionListener="#{toolbarBean.changeActiveIndex(2)}" />
<p:menuitem value="Page4" action="#{toolbarBean.changeActiveIndex(3)}" />
</p:tabMenu>
</form>
toolbarBean.java
#Named
#SessionScoped
public class toolbarBean implements Serializable {
private int currentTab;
public int getCurrentTab() {
return currentTab;
}
public void setCurrentTab(int currentTab) {
this.currentTab = currentTab;
}
public String changeActiveIndex(int currentTab) {
this.currentTab = currentTab;
switch (currentTab) {
case 0:
return "/main";
case 1:
return "/page2";
case 2:
return "/page3";
case 3:
return "/page4";
default:
return "/page5";
}
}
}
The action part works properly where the variable currentTab gets assigned the right value. However, once it is running the page redirect part, toolbarBean is being reset and activeIndex starts off at 0 again. Does anyone have any ideas on what I'm doing wrong?
Have a look at my answer in this question:
How to change activeindex in TabMenu
I think it's what you are looking for.
Edit:
Here is the complete answer:
I have found a solution in the PrimeFaces showcase. You can add a request parameter to the menuitem and append this parameter to your url. So no backing bean is needed to keep the active index:
<p:tabMenu activeIndex="#{param.i}">
<p:menuitem value="Home" icon="ui-icon-home" url="page1.xhtml?i=0">
<f:param name="i" value="0" />
</p:menuitem>
<p:menuitem value="Search" icon="ui-icon-search" url="page2.xhtml?i=1">
<f:param name="i" value="1" />
</p:menuitem>
...
</p:tabMenu>
I've unsuccessfully tried to reproduce the error.
I believe that the code sample I used has the features you need. Check it out:
*The View
<p:layout fullPage="true">
<p:layoutUnit position="north" size="100" header="Top" resizable="true" closable="true" collapsible="true">
<h:form id="formMenu">
<p:tabMenu id="tabMenu" activeIndex="#{toolbarBean.currentTab}">
<p:menuitem value="Main" action="#{toolbarBean.changeActiveIndex(0)}" />
<p:menuitem value="Page2" action="#{toolbarBean.changeActiveIndex(1)}" />
<p:menuitem value="Page3" action="#{toolbarBean.changeActiveIndex(2)}" />
<p:menuitem value="Page4" action="#{toolbarBean.changeActiveIndex(3)}" />
</p:tabMenu>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="south" size="100" header="Bottom" resizable="true" closable="true" collapsible="true">
<h:outputText value="South unit content." />
</p:layoutUnit>
<p:layoutUnit position="west" size="200" header="Left" resizable="true" closable="true" collapsible="true">
<h:outputText value="West unit content." />
</p:layoutUnit>
<p:layoutUnit position="east" size="200" header="Right" resizable="true" closable="true" collapsible="true" effect="drop">
<h:outputText value="Right unit content." />
</p:layoutUnit>
<p:layoutUnit position="center">
MAIN
</p:layoutUnit>
</p:layout>
The Managed Bean
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
#ManagedBean
#SessionScoped
public class ToolbarBean implements Serializable {
private int currentTab;
public int getCurrentTab() {
return currentTab;
}
public void setCurrentTab(int currentTab) {
this.currentTab = currentTab;
}
public String changeActiveIndex(int currentTab) {
this.currentTab = currentTab;
switch (currentTab) {
case 0:
return "main";
case 1:
return "page2";
case 2:
return "page3";
case 3:
return "page4";
default:
return "page5";
}
}
}
Note that the ToolbarBean is almost the same. As you are using #Named, see if the ManagedBean is indeed in session scope.
Another thing worth mentioning is that main.xhml, page1.xhtml, page2.xhtml and etc, has the same content except for the center layout unit content.