Problem in creation of Request scoped MB on click of Menu

UI Components for JSF
Post Reply
sandyam
Posts: 1
Joined: 27 Sep 2014, 12:34

25 Nov 2015, 06:51

Hi,

am using Primefaces 5.3 version with JEE7 Wildfly 8.2 app server.

I have a main menu "Test" which has 2 sub menu items "Test1" and Test2".
I also have 2 RequestScoped managed beans namely "Test1MB.java" and "Test2MB.java".

Everytime i click a "Test1" menu item "Test1MB" managed bean is geeting created which as expected. But the same is not happenning (Test2MB is not getting created) when i click on "Test2" menu item

My main page is as follows.

<!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">

<f:view contentType="text/html">
<h:head>
<f:facet name="first">
<meta content='text/html; charset=UTF-8' http-equiv="Content-Type" />
<title>NMS</title>
</f:facet>
<f:facet name="last">
<style type="text/css">
.ui-layout-pane-north .ui-layout-unit-content {
overflow: visible;
padding: 0;
margin: 0 auto;
}

.ui-layout-pane-north {
z-index: 30 !important;
}

.ui-layout, .ui-layout-doc, .ui-layout-unit, .ui-layout-wrap,
.ui-layout-bd, .ui-layout-hd {
border: none;
}

.ui-layout-pane-north .ui-layout-unit-content {
overflow: visible;
padding: 0;
}

</style>
</f:facet>


</h:head>
<h:body>





<p:growl id="growl" showDetail="true" />

<p:layout stateful="false" fullPage="true"
style="font-size: 100%;min-height: 300px;height: 680px;">

<p:layoutUnit position="north" resizable="false" closable="true"
size="92" collapsible="false" style="border: none">




<h:form>
<ui:include src="/test1.xhtml" />
<ui:include src="/test2.xhtml" />

<p:megaMenu>
<p:submenu label=" Test ">
<p:column>
<p:submenu style="height:0px;">

<p:menuitem value="Test 1" style=""
onclick="PF('test1Widget').show()" />
<p:menuitem value="Test 2" style=""
onclick="PF('test2Widget').show()" />
</p:submenu>

</p:column>
</p:submenu>
</p:megaMenu>
</h:form>

</p:layoutUnit>




<p:layoutUnit position="center" size="480" closable="false"
resizable="true" collapsible="false" style="border:none"
id="topologySectionUnit">
</p:layoutUnit>



</p:layout>



</h:body>
</f:view>
</html>



My test1.xhtml is as follows

<!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">
<p:dialog id="test1ID" widgetVar="test1Widget">

<h:form>
<p:outputLabel lang="Test 1"></p:outputLabel>
<p:inputText value="#{test1MB.strText}"></p:inputText>


</h:form>



</p:dialog>


</html>




My test2.xhtml is as follows

<!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">
<p:dialog id="test2ID" widgetVar="test2Widget">

<h:form>
<p:outputLabel lang="Test 2"></p:outputLabel>
<p:inputText value="#{test2MB.strText}"></p:inputText>


</h:form>



</p:dialog>


</html>



My Test1MB is as follows.

Test1MB.java

@RequestScoped
@ManagedBean
public class Test1MB {


String strText;

public String getStrText() {
return strText;
}

public void setStrText(String strText) {
this.strText = strText;
}

public Test1MB() {
super();
System.out.println("Test1MB Constructor");

}



}

Test2MB.java
@RequestScoped
@ManagedBean
public class Test2MB {


String strText;

public String getStrText() {
return strText;
}

public void setStrText(String strText) {
this.strText = strText;
}

public Test2MB() {
super();
System.out.println("Test2MB Constructor");

}



}

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 47 guests