I have one template.xhtml file at /template/template.xhtml
<h:head>
</h:head>
<h:body>
<p:layout fullPage="true">
<p:layoutUnit position="north" size="100">
<h:outputText value="header"></h:outputText>
</p:layoutUnit>
<p:layoutUnit position="center">
<p:layout>
<p:layoutUnit position="north">
<h:outputText value="tabs"/>
<ui:include src="/tabs/tabs.xhtml"/>
</p:layoutUnit>
<p:layoutUnit position="west">
<h:outputText value="left menu"></h:outputText>
</p:layoutUnit>
<p:layoutUnit position="center">
<h:outputText value="main-content"></h:outputText>
</p:layoutUnit>
</p:layout>
</p:layoutUnit>
<p:layoutUnit position="south" size="100">
<h:outputText value="footer"></h:outputText>
</p:layoutUnit>
</p:layout>
</h:body>
</html>
I have tabs.xhtml file at /tabs/tabs.xhtml
<h:head>
</h:head>
<p:tabMenu activeIndex="#{param.i}">
<p:menuitem value="Overview" outcome="index">
<f:param name="i" value="0" />
</p:menuitem>
<p:menuitem value="Demos" outcome="index">
<f:param name="i" value="1" />
</p:menuitem>
<p:menuitem value="Documentation" outcome="index">
<f:param name="i" value="2" />
</p:menuitem>
<p:menuitem value="Support" outcome="index">
<f:param name="i" value="3" />
</p:menuitem>
<p:menuitem value="Social" outcome="index">
<f:param name="i" value="4" />
</p:menuitem>
</p:tabMenu>
I am getting the following exception because of the ui include tag in template.xhtml. Is the src attribute of ui include is wrong.:
javax.faces.FacesException: Could not resolve NavigationCase for outcome: index
at org.primefaces.renderkit.OutcomeTargetRenderer.getTargetURL(OutcomeTargetRenderer.java:86)
at org.primefaces.component.menu.BaseMenuRenderer.encodeMenuItem(BaseMenuRenderer.java:162)
at org.primefaces.component.tabmenu.TabMenuRenderer.encodeItem(TabMenuRenderer.java:89)
at org.primefaces.component.tabmenu.TabMenuRenderer.encodeMarkup(TabMenuRenderer.java:65)
at org.primefaces.component.menu.BaseMenuRenderer.encodeEnd(BaseMenuRenderer.java:108)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:85)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:68)
at org.primefaces.component.layout.LayoutUnitRenderer.encodeEnd(LayoutUnitRenderer.java:49)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:85)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:68)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:83)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:68)
at org.primefaces.component.layout.LayoutUnitRenderer.encodeEnd(LayoutUnitRenderer.java:49)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1651)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1651)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1651)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:395)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
The ui:include tag is working as expected. The problem is inside tabx.xhtml. For the menuitems your have outcome="index" and my money is on the index.xhtml not in the same folder as tab.xhtml. Either make sure the outcome is a relative link like ../index or make it absolute like /index.
For further assistance you should post your directory structure.
Related
I am using the tabs where active index is selected by passing request parameter to the page :
<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">
<p:tabMenu activeIndex="${param.i}" style="text-decoration: none">
<p:menuitem value="Home" outcome="/home.xhtml">
<f:param name="i" value="0"/>
</p:menuitem>
<p:menuitem value="Sign" outcome="/web/sign/SelectServer.xhtml">
<f:param name="i" value="1"/>
</p:menuitem>
<p:menuitem value="Certificate Management" outcome="/web/sign/FileUpload.xhtml">
<f:param name="i" value="2" />
</p:menuitem>
<p:menuitem value="Support" outcome="/web/sign/FileUpload.xhtml">
<f:param name="i" value="3" />
</p:menuitem>
<p:menuitem value="Admin" outcome="/web/sign/FileUpload.xhtml">
<f:param name="i" value="4" />
</p:menuitem>
</p:tabMenu>
</ui:composition>
The problem is that it shows in the URL like :
/CodesignWebApp/faces/web/sign/SelectServer.xhtml?i=1
which doesn't look good. Is there a way to pass this param as hidden. I dont see a option to do that in f:param. Or Do I have to use managed-bean to achieve that?
every time if an error occurs, I get the following error message in the error page.
This is my page.xhtml :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.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 http-equiv="X-UA-Compatible" content="EmulateIE8" />
<meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
<title>Esprit4Olap</title>
</f:facet>
<link type="text/css" rel="stylesheet" href="#{request.contextPath}/css/default.css" />
<link type="text/css" rel="stylesheet" href="#{request.contextPath}/css/syntaxhighlighter/syntaxhighlighter.css" />
<style type="text/css">
.nestedUnit {
border:0px none !important;
}
.ui-layout-center .ui-layout-resizer {
border:1px solid #A8A8A8 !important;
}
.ui-tree-item span {
float:left !important;
}
.ui-tree {
border:0px none !important;
}
.ui-tabs {
border:0px none !important;
}
</style>
</h:head>
<h:body>
<p:layoutUnit position="west" size="200" resizable="true" collapsible="true" header="TreeNode">
<h:form>
<p:tree value="#{SchemaMan.shemaBoxses}" var="SchemaMan" selectionMode="Singel" selection="#{SchemaMan.shemaBoxse}" style="width:170px">
<p:treeNode icon="ui-icon-mail-closed">
<h:outputText value="SchemaMan"/>
</p:treeNode>
<p:treeNode type="i" icon="ui-icon-mail-closed">
<h:outputText value="SchemaMan"/>
</p:treeNode>
<p:treeNode type="s" icon="ui-icon-transfer-e-w">
<h:outputText value="SchemaMan"/>
</p:treeNode>
<p:treeNode type="t" icon="ui-icon-trash">
<h:outputText value="SchemaMan"/>
</p:treeNode>
<p:treeNode type="j" icon="ui-icon-alert">
<h:outputText value="SchemaMan"/>
</p:treeNode>
</p:tree>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="center">
<p:layout>
<p:layoutUnit position="north" size="50%" resizable="true" styleClass="nestedUnit">
<p:tabView>
<p:tab title="Schema">
<h:form>
<p:panelGrid columns="2">
<p:inputText id="Schemaname" required="true" label="SchemaName" size="40" value="#{SchemaMan.nameSchema}" />
<p:inputText id="DescSchema" required="true" label="DescSchema" size="40" value="#{SchemaMan.descSchema}" />
<p:inputText id="RoleSchema" required="true" label="RoleSchema" size="40" value="#{SchemaMan.roleSchema}" />
<p:inputText id="CaptionSchema" required="true" label="CaptionSchema" size="40" value="#{SchemaMan.captionSchema}" />
</p:panelGrid>
<p:commandButton value="Add" type="button" ></p:commandButton>
</h:form>
</p:tab>
</p:tabView>
</p:layoutUnit>
</p:layout>
</p:layoutUnit>
</h:body>
</f:view>
</html>
The error itself, however, is not related to javax.faces.component.UIOutput. It can be just any error in one of the managed beans.
and i got this erros exception:
javax.servlet.ServletException: javax.faces.component.UIOutput cannot be cast to org.primefaces.component.layout.Layout
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
Any help is appreciated.
Thanks,
i make it like you told me :
<h:body>
<p:layout>
<p:layoutUnit position="west" size="200" resizable="true" collapsible="true" header="TreeNode">
<h:form>
<p:tree value="#{SchemaMan.shemaBoxses}" var="SchemaMan" selectionMode="Singel" selection="#{SchemaMan.shemaBoxse}" style="width:170px">
<p:treeNode icon="ui-icon-mail-closed">
<h:outputText value="SchemaMan"/>
</p:treeNode>
<p:treeNode type="i" icon="ui-icon-mail-closed">
<h:outputText value="SchemaMan"/>
</p:treeNode>
<p:treeNode type="s" icon="ui-icon-transfer-e-w">
<h:outputText value="SchemaMan"/>
</p:treeNode>
<p:treeNode type="t" icon="ui-icon-trash">
<h:outputText value="SchemaMan"/>
</p:treeNode>
<p:treeNode type="j" icon="ui-icon-alert">
<h:outputText value="SchemaMan"/>
</p:treeNode>
</p:tree>
</h:form>
</p:layoutUnit>
</p:layout>
<p:layout>
<p:layoutUnit position="center">
<p:layoutUnit position="north" size="50%" resizable="true" styleClass="nestedUnit">
<p:tabView>
<p:tab title="Schema">
<h:form>
<p:panelGrid columns="2">
<p:inputText id="Schemaname" required="true" label="SchemaName" size="40" value="#{SchemaMan.nameSchema}" />
<p:inputText id="DescSchema" required="true" label="DescSchema" size="40" value="#{SchemaMan.descSchema}" />
<p:inputText id="RoleSchema" required="true" label="RoleSchema" size="40" value="#{SchemaMan.roleSchema}" />
<p:inputText id="CaptionSchema" required="true" label="CaptionSchema" size="40" value="#{SchemaMan.captionSchema}" />
</p:panelGrid>
<p:commandButton value="Add" type="button" ></p:commandButton>
</h:form>
</p:tab>
</p:tabView>
</p:layoutUnit>
</p:layoutUnit>
</p:layout>
</h:body>
but i get this exception now :
exception
javax.servlet.ServletException: JBAS011048: Failed to construct component instance
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606) !!
You have two p:layout ? Every p:layoutUnit should be inside a whole p:layout. Take into account that you can nest a p:layout inside a p:layoutUnit to make more complex layouts (and of course, every p:layout HAS to have a p:layoutUnit position="center":
<p:layout>
<p:layoutUnit position="west" size="200">
...
</p:layoutUnit>
<p:layoutUnit position="center">
<p:layout>
<p:layoutUnit position="north" size="100">
...
</p:layoutUnit>
<p:layoutUnit position="center">
...
</p:layoutUnit>
</p:layout>
</p:layoutUnit>
...
</p:layout>
Remember that if you use a p:layout for your whole page, you might be better off with p:layout fullPage="true". Cheers!
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..
I've got a JSF layout and every time I start my server I got this error:
/ UI Initialization Error
The center-pane element does not exist
The center-pane is a required element
Here is my code
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition 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://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Meu Sistema</title>
<style type="text/css">
body {background-color: #eeeeee; font-size: 12px}
</style>
</h:head>
<h:body>
<div align="center">
<p:layout style="min-width:1200px;max-width:1020px;min-height:600px">
<p:layoutUnit position="north" size="250">
<h:graphicImage url="/images/funemac.png" />
</p:layoutUnit>
<p:layoutUnit position="west" size="220">
<h:form>
<p:menu style="width: 200px">
<p:submenu label="Menu">
<p:menuitem value="Início" action="index?faces-redirect=true"/>
</p:submenu>
<p:submenu label="Autor">
<p:menuitem value="Novo" action="NovoAutor?faces-redirect=true"/>
<p:menuitem value="Consulta" action="ConsultaAutor?faces-redirect=true"/>
</p:submenu>
<p:submenu label="Artigo">
<p:menuitem value="Novo" action="EnvioArtigo?faces-redirect=true"/>
<p:menuitem value="Consulta" action="ConsultaArtigo?faces-redirect=true"/>
<p:menuitem value="Avaliação" action="Avaliacoes?faces-redirect=true"/>
</p:submenu>
<p:submenu label="Revisor">
<p:menuitem value="Novo" action="NovoRevisor?faces-redirect=true"/>
<p:menuitem value="Consulta" action="ConsultaRevisor?faces-redirect=true"/>
</p:submenu>
<p:submenu label="Tema">
<p:menuitem value="Novo" action="NovoTema?faces-redirect=true"/>
<p:menuitem value="Consulta" action="ConsultaTema?faces-redirect=true"/>
</p:submenu>
<p:submenu label="Evento">
<p:menuitem value="Novo" action="NovoEvento?faces-redirect=true"/>
<p:menuitem value="Consulta" action="ConsultaEvento?faces-redirect=true"/>
</p:submenu>
<p:submenu label="Relatórios">
<p:menuitem value="Novo" action="Relatorios?faces-redirect=true"/>
</p:submenu>
<p:submenu label="Inscrições">
<p:menuitem value="Aluno" action="NovoParticipanteAluno?faces-redirect=true"/>
<p:menuitem value="Não Aluno" action="NovoParticipanteNaoAluno?faces-redirect=true"/>
<p:menuitem value="Palestrante" action="NovoParticipantePalestrante?faces-redirect=true"/>
<p:menuitem value="Inscrever-se em Evento" action="InscreverEmEvento?faces-redirect=true"/>
<p:menuitem value="Consulta" action="ConsultaInscricao?faces-redirect=true"/>
</p:submenu>
</p:menu>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="center">
<ui:insert name="centro">
Bem-Vindo!
</ui:insert>
</p:layoutUnit>
</p:layout>
</div>
</h:body>
</html>
And this is a odd fact: when I got this message I just wipe out this part of code:
<p:submenu label="Inscrições">
<p:menuitem value="Aluno" action="NovoParticipanteAluno?faces-redirect=true"/>
<p:menuitem value="Não Aluno" action="NovoParticipanteNaoAluno?faces-redirect=true"/>
<p:menuitem value="Palestrante" action="NovoParticipantePalestrante?faces-redirect=true"/>
<p:menuitem value="Inscrever-se em Evento" action="InscreverEmEvento?faces-redirect=true"/>
<p:menuitem value="Consulta" action="ConsultaInscricao?faces-redirect=true"/>
</p:submenu>
save it. And refresh the page so everything goes normal. Then, a put all back and when I refresh the page again it works.
The problem is every time I rerun my server this happens.
Can anyone tell me what is wrong?
You are not doing anything wrong. I have found that the MenuBar in PrimeFaces is rather picky about the number of items in the menu. Try putting a separator between menuItems.
<p:submenu label="Separated">
<p:menuitem value="Item1" url="#"/>
<p:menuitem value="Item2" url="#"/>
<p:separator />
<p:menuitem value="Item3" url="#"/>
<p:menuitem value="Item4" url="#"/>
</p:submenu>
I have the following view:
<ui:composition template="/templates/cmsLayout.xhtml">
<ui:define name="rightPane">
<div class="rightPane_header">
<p:tabMenu activeIndex="0">
<p:menuitem value="Home" url="/userHome.faces" />
...
</p:tabMenu>
</div >
<div class="rightPaneData">
<h:form>
<p:growl id="growl"/>
<p:accordionPanel activeIndex="0" dynamic="false" cache="false">
<p:tab title="My Document">
<f:event type="preRenderComponent" listener="#{documentController.getMyDocumentsForHome()}" />
<p:dataTable id="homeMyDocTable" var="myDocument" value="#{documentController.myDocuments}" rowKey="#{myDocument.docId}"
selection="#{documentController.selectedDocument}" selectionMode="single">
<p:ajax event="rowSelect" listener="#{documentController.viewDocumentDetailPage}" />
<p:column headerText="Document Number" id="homeMyDocNumber" styleClass="FixedcolumnWidth">
<h:outputText value="#{myDocument.docId}" />
</p:column>
...
</p:dataTable>
<p:commandLink value="More.." rendered="#{documentController.myDocMoreStatus}" action="#{documentController.viewMyDocumentPage}" />
</p:tab>
</p:accordionPanel>
</h:form>
</div>
</ui:define>
</ui:composition>
The <p:commandLink> with value of "More.." works fine in IE, but not in FF/Chrome. How is this caused and how can I solve it?