Primefaces could not load PanelMenu component - jsf

I am using primefaces in my project. When I used the component in one of the .xhtml page I am getting the following error message :
" Tag Library supports namespace: http://primefaces.org/ui, but no tag was defined for name: panelMenu"
I am using the primefaces 3.3.1 jar .
Code snippet:
<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:p="http://primefaces.org/ui">
<h:head>
<title>Welcome to OTV_JSF_Spring_Hibernate_Project</title>
<style type="text/css">
h1{
font-family:"Times New Roman";
font-size:7px;
}
pre{
font-family:"Times New Roman";
font-size:25px;
font-style:bold;
align:center;
}
</style>
</h:head>
<h:body>
<h:form>
<p:layout style="min-width:300px;min-height:700px;" id="layout">
<p:layoutUnit position="east" resizable="true" size="300" minSize="40" maxSize="300">
<p:panelMenu style="width:200px">
<p:submenu label="Create Form">
<p:menuitem value="New Form" actionListener="" icon="ui-icon-disk" />
<p:menuitem value="Current Form" actionListener="" icon="ui-icon-arrowrefresh-1-w" />
<p:menuitem value="Form Templates" actionListener="" icon="ui-icon-arrowrefresh-1-w" />
</p:submenu>
<p:submenu label="Publish Form" >
<p:menuitem value="Home" actionListener="" ajax="false" icon="ui-icon-close"/>
<p:menuitem value="Docs" actionListener="" ajax="false" icon="ui-icon-close"/>
</p:submenu>
<p:submenu label="Users Profile">
<p:menuitem value="Add New User" actionListener="" ajax="false" icon="ui-icon-close"/>
<p:menuitem value="Edit User Profile" actionListener="" ajax="false" icon="ui-icon-close"/>
<p:menuitem value="Remove Users" actionListener="" ajax="false" icon="ui-icon-close"/>
<p:menuitem value="View Users Report" actionListener="" ajax="false" icon="ui-icon-close"/>
</p:submenu>
<p:separator />
</p:panelMenu>
</p:layoutUnit>
<p:layoutUnit position="center">
<h1><font size = "6"><h:outputLabel for="createform" value="Create New Form"/></font></h1>
<hr width="98%"></hr>
<table>
<tr>
<td width="30%"><pre><h:outputLabel for="name" value="Name of the form : " /></pre></td>
<td align="left"><p:inputText id="name" value="#{questionMB.formName}" label="Name of the form">
</p:inputText>
<p:message id="formMsg" for="name" display="icon"/>
</td>
</tr>
<tr>
<td width="30%"><pre><h:outputLabel for="desc" value="Description of the form : " /></pre></td>
<td align="left"><p:inputTextarea rows="4" cols="60" value="#{questionMB.formDesc}"/>
</td>
</tr>
<tr>
<td width="30%"><pre><h:outputLabel for="question" value="Question : " /></pre></td>
<td align="left">
<p:accordionPanel>
<p:tab title="Godfather Part I">
<h:panelGrid columns="2" cellpadding="10">
<p:inputText id="question" value="#{questionMB.questionText}">
<f:validateLength minimum="5" />
<p:ajax event="blur" update="questionMsg" />
</p:inputText>
<p:message id="questionMsg" for="question" display="icon"/>
</h:panelGrid>
</p:tab>
</p:accordionPanel>
</td>
</tr>
<tr>
<td width="30%"><pre><h:outputLabel for="answer" value="Answer Type : " /></pre></td>
<td align="center">
<h:panelGrid columns="2" rows="1" style="margin-bottom:10px" cellpadding="5">
<p:selectOneRadio id="options" value="#{questionMB.answerType}">
<f:selectItem itemLabel="Text field" itemValue="Text field" />
<f:selectItem itemLabel="Combo box" itemValue="Combo box" />
<f:selectItem itemLabel="Radio button" itemValue="Radio button" />
<f:selectItem itemLabel="Check box" itemValue="Check box" />
<f:selectItem itemLabel="Date box" itemValue="Date box" />
<f:selectItem itemLabel="Y/N Button" itemValue="Y/N Button" />
</p:selectOneRadio>
</h:panelGrid>
</td>
</tr>
<tr></tr><tr></tr><tr></tr>
<tr>
<td></td><td></td>
<td><p:commandButton id="addNewQuestion" value="Add New Question" action="#{questionMB.addNewQuestion}" ajax="true"/>
</td>
</tr>
<tr>
<td></td><td></td>
<td><p:commandButton id="addQuestion" value="Save" action="#{questionMB.addQuestion}" ajax="true"/>
<p:commandButton id="submitQuestion" value="Submit" action="#{questionMB.saveandsubmitForm}" ajax="false"/></td>
</tr>
</table>
</p:layoutUnit>
</p:layout>
</h:form>
</h:body>
</html>

You get that error because p:panelMenu is not in 3.3.1 version. It is introduced in 3.4.
Check the documention of 3.3.1 here

Related

JSF Form Validation

I am trying to persist a form in JSF page with many inputs. in parallel I added client side validation to process before entering to the actionLisner method.
The issus is that if I make the commandbutton inside <h:form> and outside <p:panel> the validation is OK but the action does not do anything (if all the fiels are validated). If I make the commandbutton inside <p:panel> the opposite happens, the validation does not work anymore and even if some fiels are empty, the method in actionListner is called.
<?xml version="1.0" encoding="UTF-8" ?>
<!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:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="/template.xhtml">
<ui:define name="title">
<h:outputText value="Entretien annuel - Personnel d'Agence">
</h:outputText>
</ui:define>
<ui:define name="body">
<div align="center">
<h:form id="CollaborateurViewForm">
<h:panelGroup id="display">
<p:panel header="Détails du Collaborateur">
<p:panelGrid columns="2" rendered="#{collaborateurController.selected !=
null}">
<h:outputText value="#{bundle.ViewCollaborateurLabel_idCollaborateur}"/>
<h:outputText value="#{collaborateurController.selected.idCollaborateur}"
title="#{bundle.ViewCollaborateurTitle_idCollaborateur}"/>
</p:panelGrid>
</p:panel>
</h:panelGroup>
</h:form>
</div>
<h:form id="testForm" >
<p:panel id="entretienFormPa" header="Entretien annuel - Personnel d'Agence">
<div align="center">
<p:panelGrid columns="2">
<p:panel header="Détails de l'entretien">
<p:outputLabel for="collaborateursItem" value="Entretien mené par :"/>
<p:selectManyMenu id="collaborateursItem" filter="true" filterMatchMode="contains"
showCheckbox="true"
value="#{entretienController.entretienMenePar}">
<p:ajax process="#this"/>
<f:selectItems id="entretienMenePar" value="#
{collaborateurController.itemsAvailableSelectMany}"
var="entretienMeneParItem"
itemValue="#{entretienMeneParItem}"/>
</p:selectManyMenu>
</p:panel>
</p:panelGrid>
<p:panel header="Saisie des notes de l'entretien">
<p:tabView>
<p:tab title="#{bundle.Personnel_Organisation_Commerciale}">
<h:panelGrid columns="2" cellpadding="10" cellspacing="10">
<p:outputLabel value="#
{bundle.Personnel_Organisation_Commerciale_Comprehension}" for="noteItem11"/>
<p:selectOneButton id="noteItem11" value="#
{entretienController.note11}"
required="true"
requiredMessage="#
{bundle.NoteEntretien_Requise}">
<f:selectItems value="#
{entretienController.listeNotesPossibles}"
var="noteItem"
itemValue="#{noteItem}"/>
<p:ajax process="#this"/>
</p:selectOneButton>
<p:outputLabel
value="#{bundle.Personnel_Organisation_Commerciale_Actions}" for="noteItem12"/>
<p:selectOneButton id="noteItem12" value="#
{entretienController.note12}"
required="true"
requiredMessage="#
{bundle.NoteEntretien_Requise}">
<f:selectItems value="#
{entretienController.listeNotesPossibles}"
var="noteItem"
itemValue="#{noteItem}"/>
<p:ajax process="#this"/>
</p:selectOneButton>
<p:outputLabel for="commentaireOrgaCom" value="Commentaire de suivi : " style="font-weight: bold"/>
<p:inputTextarea id="commentaireOrgaCom" value="#{entretienController.commentaireOrgaCom}"
rows="4" cols="50">
<p:ajax process="#this"/>
</p:inputTextarea>
</h:panelGrid>
</p:tab>
</p:tabView>
</p:panel>
<p:tabView>
<p:tab title="#{bundle.Da_Divers}">
<div align="center">
<p:outputLabel for="diagnosticItem" value="Diagnostic : " />
<p:inputTextarea id="diagnosticItem" value="#
{entretienController.diagItem}" rows="8" cols="67" required="true"
requiredMessage="#{bundle.Diagnostic_Requis}">
<p:ajax process="#this"/>
</p:inputTextarea>
</h:panelGrid>
</div>
</p:tab>
</p:tabView>
</div>
</p:panel>
<div align="right">
<p:commandButton id="saveEntretienButton" value="Enregistrer"
process="entretienFormPa" update="entretienFormPa" immediate="true"
actionListener="#
{noteEntretienController.saveEntretienActionPa(entretienController,
collaborateurController)}">
<p:confirm header="Confirmation" message="Etes-vous sûr de vouloir
enregistrer l'entretien ?" />
</p:commandButton>
<p:commandButton value="Retour" action="Details"
ajax="false" />
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
<p:commandButton value="Oui" type="button" styleClass="ui-confirmdialog-yes" />
<p:commandButton value="Non" type="button" styleClass="ui-confirmdialog-no" />
</p:confirmDialog>
</div>
</h:form>
</ui:define>
</ui:composition>
</html>
I also tried to add validateClient="true" on the commandButton
Thank in advance !
UPDATE :
I resolved the issue without knowing what was the source. I go back to the initial example given on primefaces showcase, I added my fields one by one. Know all is good

p:selectOneMenu keeps deselecting

I have a bug, I have in a page, 3 <p:selectOneMenu>s and 1 <p:selectManyMenu>
They work in order, I select the first, it fills the second, the secon fill the third and the third fill s the <p:selectManyMenu>. When I start to Select the values in the <p:selectManyMenu>(holding the ctrl button) the third <p:selectOneMenu> deselects. Executing the function that fills the <p:selectManyMenu>.
Anyone have ever seen this?
I'have a lot of experience with java, but just started with JSF and PrimeFaces.
Thank you all in advance.
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:form id="formPatch">
<table border="">
<tr>
<td height="180p" valign="top">
<p:panel header="Configurar diretórios para extrair Objetos do Patch" style="width: 500px; height: 170px">
<h:panelGrid columns="2">
<p:outputLabel value="Arquivo: " styleClass="format_label"
for="nomePatch" />
<p:inputText id="nomePatch" value="#{patchMB.patchBean.fileName}" styleClass="format_input" required="true"
requiredMessage="Favor preencher o campo nome do arquivo ex: confg.txt">
</p:inputText>
<p:outputLabel value="Repositórios:" styleClass="format_label" for="dirRep" />
<p:selectOneMenu id="dirRep" value="#{patchMB.patchBean.directoryRepositorio}"
style="width: 350px">
<p:message for="dirRep" />
<f:selectItem itemLabel="Selecione" itemValue="Selecione" />
<f:selectItems value="#{patchMB.directoryRepCli}" />
<f:ajax event="change" listener="#{patchMB.carregaDirProdCli}" render="dirProdCli" />
</p:selectOneMenu>
<p:outputLabel value="Prod/Clientes: " for="dirProdCli" />
<p:selectOneMenu id="dirProdCli" value="#{patchMB.patchBean.directoryProdCli}"
style="width: 350px">
<p:message for="dirGap" />
<f:selectItem itemLabel="Selecione" itemValue="Selecione" />
<f:selectItems value="#{patchMB.dirProdCli}" />
<f:ajax event="change" listener="#{patchMB.carregaDirObjetos}" render="dirObj" />
</p:selectOneMenu>
<p:outputLabel value="Dir objetos: " for="dirObj" />
<p:selectOneMenu id="dirObj" value="#{patchMB.patchBean.directoryObjetos}"
style="width: 350px">
<p:message for="dirObj" />
<f:selectItem itemLabel="Selecione" itemValue="Selecione" />
<f:selectItems value="#{patchMB.dirObjetos}" />
<f:ajax event="change" listener="#{patchMB.carregarFiles}" render="pickListArq" />
<f:ajax event="change" listener="#{patchMB.carregarSelectMany}" render="objSelectMany" />
</p:selectOneMenu>
</h:panelGrid>
</p:panel>
</td>
<td>
<p:panel header="Escolha os arquivos para criação do patch" style="width: 500px">
<p:tab id="pickListTab" title="Transformadores">
<h:panelGrid columns="1">
<p:pickList id="pickListArq" value="#{patchMB.objetos}" var="pickListObj"
itemLabel="#{pickListObj}" itemValue="#{pickListObj}">
<f:facet name="sourceCaption">Selecione os objetos</f:facet>
<f:facet name="targetCaption">Objetos do Patch</f:facet>
</p:pickList>
</h:panelGrid>
</p:tab>
</p:panel>
</td>
</tr>
</table>
</h:form>
</ui:composition>

JSF-Primefaces Two Forms Interfering

I am aware that nesting is a problem with form tags. However, my page does not have nested forms. I have one form (id="menuForm") to enclose the p:menu. Next, I have a form (id="locationForm") lower in the page. I have checked the html source that is output, and there is no nesting happening.
I have one p:commandButton that I want to use to submit the form. It works occasionally, but not all of the time. Sometimes, the method fires and other times it doesn't. Can anyone poing out what I'm doing wrong?
Also--If I comment out the menu form completely it works as intended.
Thanks.
Action Method:
public String insertLocationAction(){
System.out.println("******* Method Fired.");
DatabaseManager.insertLocation(newLocation);
return "locations";
}
XHTML Page:
<?xml version="1.0" encoding="UTF-8"?>
<!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://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<f:view>
<ui:debug rendered="#{facesContext.application.projectStage eq 'Development'}"/>
<h:head />
<p:messages />
<p:layout fullPage="true">
<p:layoutUnit position="west" size="260" header="Menu" resizable="false" closable="false">
<h:form id="menuForm">
<p:menu style="width: 240px;" >
<p:submenu label="Locations" style="width: 240px;">
<p:menuitem value="All Locations" outcome="/pages/locations.xhtml" style="width: 240px;" />
<p:menuitem value="Create New" action="#{locationBackingBean.addLocationAction}" style="width: 240px;" />
</p:submenu>
<p:submenu label="Queries" style="width: 240px;">
<p:menuitem value="Product Group Sales" outcome="/pages/productGroupSales.xhtml" style="width: 240px;" />
<p:menuitem value="Product Line Sales" outcome="/pages/productLineSales.xhtml" style="width: 240px;" />
</p:submenu>
</p:menu>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="center">
<h:form id="locationform" enctype="multipart/form-data">
<p:growl id="growl" showDetail="true" />
<p:panelGrid columns="2">
<f:facet name="header">Enter New Location Details</f:facet>
<h:outputLabel for="locationName" value="Location Name:" /> <p:inputText id="locationName" value="#{locationBackingBean.newLocation.locationName}" size="100" />
<h:outputLabel for="street1" value="Street Address1:" /> <p:inputText id="street1" value="#{locationBackingBean.newLocation.street1}" size="100"/>
<h:outputLabel for="street2" value="Street Address2:" /><p:inputText id="street2" value="#{locationBackingBean.newLocation.street2}" size="100"/>
<h:outputLabel for="city" value="City:" /><p:inputText id="city" value="#{locationBackingBean.newLocation.city}" size="40" />
<h:outputLabel for="state" value="State:" /><p:inputText id="state" value="#{locationBackingBean.newLocation.state}" size="2" />
<h:outputLabel for="country" value="Country:" /><p:inputText id="country" value="#{locationBackingBean.newLocation.country}" size="20" />
<h:outputLabel for="phone" value="Phone:" /><p:inputText id="phone" value="#{locationBackingBean.newLocation.phone}" size="15" />
<h:outputLabel for="locationType" value="Type:" /><p:inputText id="locationType" value="#{locationBackingBean.newLocation.locationType}" />
</p:panelGrid>
<p:commandButton action="#{locationBackingBean.insertLocationAction}" ajax="false" value="Save" />
</h:form>
</p:layoutUnit>
</p:layout>
</f:view>
</html>
Refer to: http://www.primefaces.org/docs/vdl/4.0/primefaces-p/commandButton.html
By default the p:commandButton processes the whole 'view'.
Add process=":locationform" to the commandButton might just need "locationform" (depends on your selector working and nested jsf components etc..

Update list size in real time with PF Poll

In my JEE application, I have an emails list extraction process. I need to display a counter which be incremented after adding a mail to the list. The idea is to display the size of this list and update it every 1 seconde using primeface poll. I procced like this:
EmailsExtraction.xhtml:
<h:body>
<h:form>
<h:panelGroup id="formblock" style="margin-top: 40px" layout="block" >
<p:panelGrid columns="2">
<p:outputLabel for="Keyword" value="Keywords: " />
<p:inputText id="Keyword" type="search" requiredMessage="Keyword is required" style="width: 600px"
value="#{mailMB.keyword}" required="true" label="Keyword">
</p:inputText>
<p:outputLabel for="Emailsnbr" value="Emails amount:" />
<p:inputText id="Emailsnbr" requiredMessage="Emails number is required" style="width: 590px"
value="#{mailMB.number}" required="true" label="Emailsnbr">
</p:inputText>
</p:panelGrid>
</h:panelGroup>
<p:spacer height="5px" />
<p:commandButton value="Start" style="width: 12%;height: 100%" id="extractbutton" ajax="true" widgetVar="ButtonExtract"
actionListener="#{mailMB.searchEmailsRym()}"
styleClass="ui-priority-primary"
onstart="blockUIWidget1.show();" oncomplete="play(); blockUIWidget1.hide(); if (args && !args.validationFailed) freeMails();">
</p:commandButton>
</h:form>
<p:dialog widgetVar="blockUIWidget1" header="Hitonclick" modal="true" resizable="false" closable="false" >
<table border="0" style="width: 500px">
<tbody >
<tr>
<td>
<p:graphicImage url="pictures/loading81.gif" width="200" height="200" alt="animated-loading-bar"/>
</td>
<td>
<h:form >
<p:outputLabel value="#{mailMB.count}" id="countOutPut"/>
<p:poll interval="1" update="countOutPut" listener="#{mailMB.increment}"/>
<div id="countdown_text">0</div>
<br></br>
<p:commandButton ajax="false" style="width: 100px;height: 40px" actionListener="#{mailMB.abortSearch()}" value="Cancel" styleClass="ui-priority-primary" title="Cancel" oncomplete="clearForm('formcounter'), clearForm('searchForm')"/>
</h:form>
</td>
</tr>
<div align="right">
</div>
</tbody>
</table>
</p:dialog>
</h:body>
ManagedBean.java:
private int count=0;
public void increment(){
count=mails.size();
}
// count getter & setter
But the count value is not updated.

command button doesn't work in p:tabView

i have three tab that invoke separate composite Component. my problem is, when i click on button, there is no action happend. but when i open my composite component page separately my buttons work clearly.my Buttons Are in Tab3. when in invoke ""bizbiz:inviteRequest"" in Tab3, my buttons dosnot work.
could you please see my code ?
<h:body>
<h:form>
<p:tabView >
<p:tab id="tab1" title="#{businessPartner_msg.supplier}">
<h:panelGrid columns="2" cellpadding="10">
<bizbiz:supplier/>
</h:panelGrid>
</p:tab>
<p:tab id="tab2" title="#{businessPartner_msg.customer}">
<h:panelGrid columns="2" cellpadding="10">
<bizbiz:customer/>
</h:panelGrid>
</p:tab>
<p:tab id="tab3" title="#{businessPartner_msg.inviteRequest}">
<h:panelGrid columns="2" cellpadding="10">
<bizbiz:inviteRequest/>
</h:panelGrid>
</p:tab>
</p:tabView>
</h:form>
</h:body>
my buttons in tab3 . here is Tab3
<composite:implementation>
<table style="width: 100%" id="tabell">
<p:selectOneButton value="#{inviteRequestManagedBean.filterType}">
<f:selectItem itemLabel="#{inviteRequest_msg.request}" itemValue="request" />
<f:selectItem itemLabel="#{inviteRequest_msg.archive}" itemValue="archive" />
<f:ajax event="change" execute="#form" render="#form" />
<tr>
<td>
<p:panel></p:panel>
<p:dataGrid id="requestDataGrid" var="tBusinessPartnerRequestInfo"
value="#{inviteRequestManagedBean.filterBusinessRequest()}" columns="1" >
<p:column>
<div>
<table border="0" width="100%">
<tr>
<td>
<p:graphicImage value="#{tBusinessPartnerRequestInfo.partySender_imageUrl}"/>
</td>
<td>
<div>
<table border="0" width="100%">
<tr>
<td>
<h:outputLabel value="#{tBusinessPartnerRequestInfo.requestDate}"/>
</td>
</tr>
<tr>
<td>
<h:outputLabel value="#{tBusinessPartnerRequestInfo.partySender_fullName}"/>
</td>
</tr>
</table>
</div>
</td>
<td>
<p:commandButton id="acceptCommonButton" value="#{inviteRequest_msg.accept}"
actionListener="#{inviteRequestManagedBean.acceptRequest(tBusinessPartnerRequestInfo.id)}"
update="#form"/>
</td>
<td>
<p:commandButton id="noNowCommonButton" value="#{inviteRequest_msg.notnow}"
actionListener="#{inviteRequestManagedBean.notNowRequest(tBusinessPartnerRequestInfo.id)}"
update="#form"/>
</td>
<p:blockUI block="acceptCommonButton" trigger="acceptCommonButton"/>
<p:blockUI block="noNowCommonButton" trigger="acceptCommonButton"/>
<p:blockUI block="acceptCommonButton" trigger="noNowCommonButton"/>
<p:blockUI block="noNowCommonButton" trigger="noNowCommonButton"/>
<td>
<p:panel>
<p:ajaxStatus>
<f:facet name="start">
<p:graphicImage value="../resources/img/loading.gif"/>
</f:facet>
<f:facet name="complete">
<h:outputLabel value=""/>
</f:facet>
</p:ajaxStatus>
</p:panel>
</td>
</tr>
</table>
</div>
<hr/>
</p:column>
</p:dataGrid>
</td>
</tr>
</p:selectOneButton>
</table>
</composite:implementation>

Resources