UI Layout Initialization Error-The center-pane element does not exist - jsf

I am using a Layout structure that has centerLayout, westLayout,northLayout
When i run the file, i take this following error:
"/UI Layout Initialization Error.
The center-pane element does not exist.
The-center pane is a required element."
my template is :
<p:layoutUnit position="north" size="100" collapsible="true">
<header>
<div class="logo1">
<img src="#{facesContext.externalContext.requestContextPath}/resources/images/logo1.png" alt="Gestion d'accès et de habilitations" />
</div>
<ul>
<li><h:link outcome="/profile" value="Profile"/></li>
<li>Se déconnecté</li>
</ul>
<div class="logo2">
<img src="#{facesContext.externalContext.requestContextPath}/resources/images/logo2.png" alt="Altijari Bank" />
</div>
</header>
</p:layoutUnit>
<p:layoutUnit position="west" size="210" header="Menus" collapsible="true">
<h:form id="frmMenu1">
<p:accordionPanel multiple="true" id="acc" activeIndex="0">
<p:tab title="Gestion des agences">
<p:menu style="width:100%" id="m1">
<p:menuitem value="Consulter" action="#{agenceController.prepareList()}"/>
<p:menuitem value="Ajouter" action="#{agenceController.prepareCreate()}" />
</p:menu>
</p:tab>
<p:tab title="Gestion des utilisateurs">
<p:menu style="width:100%" id="m2">
<p:menuitem value="Consulter" action="#{utilisateurController.prepareList()}"/>
<p:menuitem value="Ajouter" action="#{utilisateurController.prepareCreate()}" />
</p:menu>
</p:tab>
<p:tab title="Gestion des fonctions">
<p:menu style="width:100%" id="m3">
<p:menuitem value="Consulter" action="#{fonctionController.prepareList()}"/>
<p:menuitem value="Ajouter" action="#{fonctionController.prepareCreate()}" />
</p:menu>
</p:tab>
<p:tab title="Gestion des applications">
<p:menu style="width: 100%" id="m4">
<p:menuitem value="Consulter" action="#{applicationController.prepareList()}" />
<p:menuitem value="Ajouter" action="#{applicationController.prepareCreate()}"/>
</p:menu>
</p:tab>
<p:tab title="Gestion des fiches " >
<p:menu style="width: 100%" id="m5">
<p:menuitem value="Consulter" action="#{ficheController.prepareList()}"/>
<p:menuitem value="Ajouter" action="#{ficheController.prepareCreate()}" />
</p:menu>
</p:tab>
<p:tab title="Administration" >
<p:menu style="width: 100%" id="m6">
<p:menuitem value="Consulter" action="#{groupeController.prepareList()}" />
<p:menuitem value="Ajouter" action="#{groupeController.prepareCreate()}" />
</p:menu>
</p:tab>
<p:tab title="Traçabilité" >
<p:menu style="width: 100%" id="m7">
<p:menuitem value="Consulter" action="#{traceController.prepareList()}" />
<p:menuitem value="Ajouter" action="#{traceController.prepareCreate()}" />
</p:menu>
</p:tab>
</p:accordionPanel>
</h:form>
</p:layoutUnit>
I use primefaces 3.2, jsf 2.1, glassfish 3.1.2.1
Please help me.

As the error message suggests you are missing the center part of the layout.
It is a required element.
Define one similar to this:
<p:layoutUnit position="center">
YOUR CONTENT
</p:layoutUnit>

This happens when there is an error in the part of the page that is inside the center pane part. This can be an invalid xhtml tag, something wrong in a bean being called or whatever. Look in your server logging an see if there is anything there.

This seems to be a bug in Primefaces 6.2 and has been answered here: UI Layout Initialization Error PrimeFaces 6.2

On primefaces 5.1 I had the case when options ware set by controler bean
<pe:layout id="fullPage" options="#{layoutController.layoutOptions}" stateCookie="true">
and in that controler I was setting child layoutPanes that ware not defined
// options for nested center layout
LayoutOptions childCenterOptions = new LayoutOptions();
center.setChildOptions(childCenterOptions);
// options for center-north pane
LayoutOptions centerNorth = new LayoutOptions();
centerNorth.addOption("size", "50%");
childCenterOptions.setNorthOptions(centerNorth);
So if you are extending primefaces showcase, be sure to disable configuration on the unexsisting panes.
Since this error is not shown on other missing panes (east, west,..) this could be a big headache to solve.

Related

PrimeFaces menubar image

I have a problem consisting of not being able to put an icon to the left of the menubar and the menu items to the right, can anyone help me?
<h:body>
<h:form>
<p:menubar>
<f:facet name="options" >
<h:link outcome="index.xhmtl">
<p:graphicImage styleClass="a" name="img/logoGovernoTO.png"/>
</h:link>
</f:facet>
<p:menuitem value="NOTÍCIA" url="#"/>
<p:menuitem value="FÓRUM" url="#"/>
<p:menuitem value="EXPLORE" url="#"/>
<p:menuitem value="SOBRE" url="#"/>
<p:menuitem value="CONTATO" url="#"/>
</p:menubar>
</h:form>
</h:body>
I would have to stay like this
Have you tried with:
<p:graphicImage styleClass="a" name="img/logoGovernoTO.png" style="float: left" />
<p:menuitem value="NOTÍCIA" url="#" style="float: right" />

Process primefaces menu before show

I have a primefaces menu which items are disabled on a condition from backing bean.
The problem is, that the conditions are processed after the update.
If I select a node which has every item enabled and switch to a node where everything is disabled,
the menu is reloaded but shows everything enabled for a second before the items are disabled.
Is there a way to process the disabled-conditions before the menu is shown?
<h:form id="form">
<p:tree id="tree" ...>
<p:ajax event="select" update=":form:tree:menu" listener...>
<p:treeNode id="treenode">
<p:commandButton id="btn" type="button" />
<p:overlayPanel for="btn">
<p:menu id=menu">
<p:menuitem .... disabled="#{bean.condition1}" />
<p:menuitem .... disabled="#{bean.condition2}" />
...
</p:menu>
</p:overlayPanel>
</p:treenode>
</p:tree>
EDITED
Hide the menu items at the beggining of the ajax call and show them when it is completed. The source code in the page would be:
<p:tree id="tree" value="#{bean.root}" var="node" selectionMode="checkbox">
<p:treeNode id="treenode">
<p:commandButton id="btn" value="#{node}"
onstart="$('.ui-overlaypanel-content').css('display','none');"
oncomplete="$('.ui-overlaypanel-content').css('display','block');"
actionListener="#{bean.processAndUpdateConditions}" update="mymenu"/>
<p:overlayPanel for="btn">
<p:menu id="mymenu" >
<p:menuitem value="Condition 1" disabled="#{bean.condition1}" />
<p:menuitem value="Condition 2" disabled="#{bean.condition2}" />
</p:menu>
</p:overlayPanel>
</p:treeNode>
</p:tree>

p:dialog appears on bottom when p:blockUI targets it

I have a PrimeFaces dialog, that has two command buttons that executes some code in the backing bean. I want to block the dialog within the action.
I managed to do it using blockUI, but when the blockUI is present, and I open the dialog, it appears at the bottom of the page.
If I remove the blockUI component, the dialog opens at the center of the page, as I want. But I want it to be centered and with the blockUI.
<p:dialog header="Attention" id="dialog" position="center"
widgetVar="dialog" modal="true" closable="false"
dynamic="true" closeOnEscape="false">
<div class="internal-margin-top">
<h:outputText value="Location" styleClass="ui-outputtext" />
<p:inputText value="#{activityBean.location}"
id="inputLocation" maxlength="15">
</p:inputText>
</div>
<div class="internal-margin-bottom">
<p:commandButton id="closureYes" value="Yes"
styleClass="btn-green"
onstart="PF('block').show();"
oncomplete="PF('dialog').hide(); PF('block').hide();"
action="#{activityBean.processItem()}" process="#all">
</p:commandButton>
<p:commandButton id="closureNo" value="No"
styleClass="btn-red"
onstart="PF('block').show();"
oncomplete="PF('dialog').hide(); PF('block').hide();"
action="#{activityBean.processActivity()}" process="#all" />
</div>
</p:dialog>
<p:blockUI block="scrapDialog" widgetVar="block">
<p:graphicImage library="images" name="loading_bar.gif" />
</p:blockUI>
Thanks in advance.
Example with a centered modal dialog:
<p:dialog header="Header" position="center" widgetVar="wv_dialog" modal="true" closable="false" dynamic="true" closeOnEscape="false">
<h:form id="dialogform">
<p:panelGrid columns="1">
<p:inputText value="test"/>
<p:inputText value="test"/>
<p:inputText value="test"/>
<p:inputText value="test"/>
</p:panelGrid>
<p:commandButton id="closebutton"
value="Close"
oncomplete="PF('wv_dialog').hide();"
action="#{testBean.actionTest()}"
process="#form"/>
<p:blockUI block="dialogform" trigger="closebutton"/>
</h:form>
</p:dialog>

Exception thrown as Fieldset cannot be cast to UIData

Trying to develop a drag and drop functionality. A fieldSet in a layout has to be dragged and imitate user as if it is being dropped into another layout. Below is the xhtml code for the same :-
<h:head>
<script type="text/javascript">
function handleDrop(event, ui) {
var dropped = ui.draggable;
dropped.fadeOut('fast');
}
</script>
</h:head>
<h:body>
<h:form>
HI
<h1>Primefaces Basic Config</h1>
<p:layout style="min-width:400px;min-height:200px;">
<p:layoutUnit id="first" position="west">
<p:fieldset id="ppl" legend="Builder" toggleable="true" toggleSpeed="500" style="width:300px">
<h:panelGrid columns="2" cellpadding="5">
<h:outputText value="Bla bla bla"></h:outputText>
</h:panelGrid>
</p:fieldset>
<p:draggable for="ppl" revert="true" />
</p:layoutUnit>
<p:layoutUnit id="second" position="center">
<p:tabView id="dropdownpanel">
<p:tab title="Edit">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText
value="Add question details" />
</h:panelGrid>
</p:tab>
<p:tab title="Option">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText value="addtional options required" />
</h:panelGrid>
</p:tab>
<p:tab title="Logic">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText value="addd logic to this tab" />
</h:panelGrid>
</p:tab>
</p:tabView>
</p:layoutUnit>
<p:droppable for="second" tolerance="touch" datasource="ppl" onDrop="handleDrop" >
<p:ajax update="first second" />
</p:droppable>
</p:layout>
</h:form>
</h:body>
</h:form>
Following is the screen shot of what i'm trying to achieve where builder fieldset can be dragged into edit area:-
But when i'm trying to drag BUILDER then following Exception is thrown :-
15:53:05,497 INFO
[javax.enterprise.resource.webcontainer.jsf.context]
(http-0.0.0.0-0.0.0.0-8081-1) java.lang.ClassCastException:
org.primefaces.component.fieldset.Fieldset cannot be cast to
javax.faces.component.UIData: java.lang.ClassCastException:
org.primefaces.component.fieldset.Fieldset cannot be cast to
javax.faces.component.UIData at
org.primefaces.component.dnd.Droppable.findDatasource(Droppable.java:231)
[primefaces-4.0.jar:4.0] at
org.primefaces.component.dnd.Droppable.queueEvent(Droppable.java:189)
[primefaces-4.0.jar:4.0] at
org.primefaces.component.behavior.ajax.AjaxBehaviorRenderer.decode(AjaxBehaviorRenderer.java:44)
[primefaces-4.0.jar:4.0] at
javax.faces.component.behavior.ClientBehaviorBase.decode(ClientBehaviorBase.java:132)
[jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] at
org.primefaces.renderkit.CoreRenderer.decodeBehaviors(CoreRenderer.java:395)
[primefaces-4.0.jar:4.0] at
org.primefaces.component.dnd.DroppableRenderer.decode(DroppableRenderer.java:32)
[primefaces-4.0.jar:4.0] at
javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787)
[jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final] at
javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1181)
[jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
And i've no clue to resolve.
The datasource attribute in your p:droppable element needs to refer to a UIData. Fieldset is not a UIData. If you look at the UIData Javadoc you will see that HtmlDatatable is a known subclass
I had the same problem and resolved by referencing my datatable instead of the fieldset. In your case you are using a h:panelGrid, so change
<h:panelGrid columns="2" cellpadding="5" >
to a datatable, give it an ID. Say "datasrc1".
And change your droppable's datasource to:
<p:droppable for="second" tolerance="touch" datasource="datasrc1" onDrop="handleDrop" >

Displaying menu with panelgrid rendered

My Below code display menu based on if not database is empty, my problem is, it displays the second submenu but does not display the first one. i have got same validation on both
<h:panelGrid rendered="#{not empty dataBase}" width="100%">
<h:form>
<p:menubar style="height: 25px;background-color: #9999ff" >
<h:panelGrid rendered="#{not empty rights}" >
<p:submenu label="Master" >
<p:menuitem value="Client" url="test.xhtml" />
<p:menuitem value="TaxMaster" url="test.xhtml" />
<p:menuitem value="Quotation" url="test.xhtml" />
<p:separator />
<p:menuitem value="Area" url="test.xhtml" />
</p:submenu>
</h:panelGrid>
<p:submenu label="Back Office" icon="ui-icon-pencil">
<p:submenu label="Book Issue" icon="ui-icon-contact">
<p:menuitem value="Add" url="BookIssue_Add.xhtml" />
<p:menuitem value="Edit" url="BookIssue_Edit.xhtml" />
<p:menuitem value="View" url="test.xhtml" />
</p:submenu>
</p:submenu>
</p:menubar>
</h:form>
</h:panelGrid>
<p:submenu/> must be child of <p:menubar/> otherwise it wont be rendered

Resources