This page calls for XML namespace declared with prefix br but no taglibrary exists - jsf

I just finished the Netbeans introduction to Hibernate tutorial ( http://netbeans.org/kb/docs/web/hibernate-webapp.html#01 ) and I am getting the following error:
"This page calls for XML namespace declared with prefix br but no taglibrary exists"
Now, I have seen a similar question somewhere else:
http://forums.sun.com/thread.jspa?threadID=5430327
but the answer is not listed there. Or, if it is, then I am clearly missing it -- line one of my index.xhtml file reads "http://www.w3.org/1999/xhtml". It also does not explain why, when I reload localhost:8080, the message disappears.
Here is my index.xhtml file:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="./template.xhtml">
<ui:define name="body">
<h:form>
<h:commandLink action="#{filmController.previous}" value="Previous #{filmController.pageSize}" rendered="#{filmController.hasPreviousPage}"/>
<h:commandLink action="#{filmController.next}" value="Next #{filmController.pageSize}" rendered="#{filmController.hasNextPage}"/>
<h:dataTable value="#{filmController.filmTitles}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
<h:column>
<f:facet name="header">
<h:outputText value="Title"/>
</f:facet>
<h:outputText value="#{item.title}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Description"/>
</f:facet>
<h:outputText value="#{item.description}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value=" "/>
</f:facet>
<h:commandLink action="#{filmController.prepareView}" value="View"/>
</h:column>
</h:dataTable>
<br/>
</h:form>
</ui:define>
</ui:composition>
</html>

The problem clearly comes from the <br/> tag, and facelets is trying to interpret it as a JSF/facelets tag with a prefix.
If we follow the standards, this tag should look like this <br /> (with a space before the slash). Try it that way, and if it doesn't work, try removing it.

I'm a few years late, but I have just done the same Hibernate tutorial, and faced exactly the same error. However, I do not think that the problem is related to the file index.xhtml. And while another poster is correct that the break tags should have a space, that change does not prevent the error "This page calls for XML namespace declared with prefix br but no taglibrary exists"
The problem lies in another xhtml file in the tutorial named browse.xhtml. You can see the content of that file using the tutorial link in the opening post. It contains an unmatched trailing </html> tag, and no reference to the http://www.w3.org/1999/xhtml namespace.
Pasting the content of that file into a HTML validator (e.g. validator.w3.org ) highlights the problems.
The solution that worked for me was to add the missing opening <html> tag:
<html xmlns="http://www.w3.org/1999/xhtml">
Alternatively, remove that unmatched trailing </html> tag, and add
xmlns="http://www.w3.org/1999/xhtml" to the opening <ui:composition> tag.

Related

JSF 2.3 Facet in Composite Component with wrong ID

I have the following simple code in a composite component (using Mojarra 2.3.9 / Primefaces 7):
<composite:implementation>
<h:form id="form">
<composite:insertChildren />
<ui:fragment rendered="#{!empty cc.facets.actions}">
<div class="actions">
<composite:renderFacet name="actions" />
</div>
</ui:fragment>
</div>
</h:form>
</composite:implementation>
And the following part is used in a page, trying to fill the composite form with life:
<cc:compForm id="mySpecialForm">
<f:facet name="actions">
<p:commandButton
id="myBtn"
value="Submit"
process="#form"
update="#form">
</p:commandButton>
</f:facet>
</cc:compForm>
The form and all the children are rendered correctly and working quite well. But the button in the renderFacet block has - in my opinion - a wrong client ID, because instead of:
mySpecialForm:form:myBtn
the button only gets the following clientId:
mySpecialForm:myBtn
This leads to an error rendering the page:
Cannot find component for expression "#form" referenced from
"mySpecialForm:myBtn".:
org.primefaces.expression.ComponentNotFoundException: Cannot find
component for expression "#form" referenced from
"mySpecialForm:myBtn".
Am i doing something wrong or is this a bug in JSF/Primefaces? I also tried to configure the componentType to an #FacesComponent extending from UIForm, but in this case no form will be rendered at all.
Update 1:
I tried to create a "minimal, reproducible example (reprex)" like mentioned by Kukeltje. All what is needed are those 2 Parts in a web application (both files under resources):
cc/compForm.xhtml:
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:composite="http://xmlns.jcp.org/jsf/composite">
<composite:interface name="compForm" displayName="A composite form">
<composite:facet name="actions" />
</composite:interface>
<composite:implementation>
<h:form id="form">
<composite:insertChildren />
<composite:renderFacet name="actions" />
</h:form>
</composite:implementation>
</html>
compFormTest.xhtml:
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:cc="http://xmlns.jcp.org/jsf/composite/cc">
<cc:compForm id="mySpecialForm">
<h:inputText id="inputParam" value="" />
<f:facet name="actions">
<h:commandButton id="myBtn" value="Test" />
</f:facet>
</cc:compForm>
</html>
All todo is call the .xhtml page: http:localhost/YOUR_APP/compFormTest.xhtml.
After using it (at least with Mojarra JSF implementation), the input field has the following correct client ID mySpecialForm:form:inputParam. But the command button retrieves another client ID outside the form: mySpecialForm:myBtn, what is a bug from my point of view, regarding the JSF VDL: " ... will be rendered at this point in the composite component VDL view.".
But as i downstriped the example files, it is clearly not a primefaces problem, because the wrong client ID is also included, if using the standard h:commandButton component.
Perhaps someone can use the mentioned 2 files above in a MyFaces environment to check if the behaviour differs or is the same?
Or has someone a workaround in mind? Using an additional #FacesComponent and moving the button from facet to the right spot under the form leads to the following "funny" duplicate ID error:
"Cannot add the same component twice: mySpecialForm:form:myBtn" (at least the client ID was what i expected in the first place)

Using <ui:include> in center facet of <af:decorativeBox>

I moved from JSF 1.2 using JSP to JSF 2.1 using Facelets.
I use oracle ADF Faces as component library.
The layout of my main page doesn't work anymore with Facelets.
Here is my layout :
<af:form id="mainForm">
<af:decorativeBox theme="medium" styleClass="AFVisualRoot">
<f:facet name="center">
<!-- Main page -->
<af:panelStretchLayout topHeight="35" bottomHeight="20" >
<!-- Top menu -->
<f:facet name="top">
<af:panelStretchLayout endWidth="255" startWidth="100%">
<f:facet name="end">
</f:facet>
<f:facet name="start">
</f:facet>
</af:panelStretchLayout>
</f:facet>
<!-- Page footer -->
<f:facet name="bottom">
<af:region id="footerRegion" showHeader="never"
value="#{main.footerModel}" />
</f:facet>
<!-- Page body -->
<f:facet name="center">
<af:panelSplitter orientation="horizontal"
splitterPosition="450">
<f:facet name="first">
<af:region id="browserRegion" showHeader="never"
value="#{main.browserModel}" />
</f:facet>
<f:facet name="second">
<af:region id="contentRegion" showHeader="never"
value="#{main.contentModel}" />
</f:facet>
</af:panelSplitter>
</f:facet>
</af:panelStretchLayout>
</f:facet>
</af:decorativeBox>
</af:form>
As it says in the documentation for the center facet of the decorativeBox "multiple facet components in facelets are not supported by this facet"
How to do the layout of the page and still benefit from the decorativeBox if I still want to use Facelets ?
UPDATE:
my problems comes from using <ui:include> inside facets :
<!-- Top menu -->
<f:facet name="top">
<af:panelStretchLayout endWidth="255" startWidth="100%">
<f:facet name="end">
</f:facet>
<f:facet name="start">
<ui:include src="/components/menu.xhtml" />
</f:facet>
</af:panelStretchLayout>
</f:facet>
Here is part of menu.xhtml:
<?xml version='1.0' encoding='UTF-8'?>
<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:trh="http://myfaces.apache.org/trinidad/html"
xmlns:tr="http://myfaces.apache.org/trinidad"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
xmlns:afh="http://myfaces.apache.org/trinidad/html">
<af:menuBar id="headerMenuBar">
<!-- Menu Item -->
</af:menuBar>
</ui:composition>
What is the right way to include a page using Facelet inside ADF components ?
I've tested your layout with both facelets and jspx and I get the same result : both are working.
Your problem is elsewhere.
UPDATE after the question was updated:
<ui:include> tag should be avoided in ADF, please see Programming Best Practices - ADF Faces & JavaScript

NullPointerException when editing ICEFaces ace:datatable using ace:cellEditor

I was using code similar to this stripped down example:
<h:form id="form">
<ace:dataTable id="carTable"
value="#{dataTableRowEditing.cars}"
var="car">
<ace:column id="name" headerText="Name">
<ace:cellEditor>
<f:facet name="output">
<h:outputText id="nameCell" value="#{car.name}"/>
</f:facet>
<f:facet name="input">
<h:inputText id="nameInput" value="#{car.name}"/>
</f:facet>
</ace:cellEditor>
</ace:column>
<ace:column id="options" headerText="Options">
<ace:rowEditor id="editor"/>
</ace:column>
</ace:dataTable>
</h:form>
I was then getting the following error upon loading the JSF page:
com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException SEVERE: Error Rendering View[/index.xhtml]
When searching for this error, one solution I found was to make sure I had the two <f:facet> elements for input and output, but I already had these elements.
The solution that worked for me was double checking my xmlns attributes in my <html> tag. I had the following:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ace="http://www.icefaces.org/icefaces/components"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/composite"
>
However, xmlns:f="http://java.sun.com/jsf/composite" was incorrect. It should instead be xmlns:f="http://java.sun.com/jsf/core. The corrected <html> tag is shown below:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ace="http://www.icefaces.org/icefaces/components"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
>
After fixing this, the error was resolved and editing functionality worked correctly.

JSF rendered and fragments

I'm facing a a problem with JSF, i have a fragment that is rendered on all pages, and displays the latest entries of a table (~ 10 items). And i want to reuse it on a page that lists all entries.
I put a rendered rule to prevent the all pages version of the element to appear on this page specifically, but still no go, I aways get a "duplicate id found in view" error. The problem seems to lay on the fact that the JSF processor validate the IDs before validating which ones will really be rendered.
Just for information, I'm using the end of the request URI to determine if rendered is True or False.
Ah, and I tried using c:if, but it was useless too.
Edit:
Sample code requested...
i have this xhtml fragment ("tableInclude.xhtml"):
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
<ui:fragment>
<p:dataTable var="item" value="#{bean.items}"
emptyMessage="#{msg['table.empty']}"
widgetVar="table" id="listItems" styleClass="tableItems">
<p:column styleClass="span1" style="text-align: center;">
<f:facet name="header">
<i class='fa-icon-picture'/>
</f:facet>
<p:commandLink action="#{bean.itemSelected(item)}" value="#{item.name}"/>
</p:column>
</p:dataTable>
</ui:fragment>
</ui:composition>
Then i run on every page this:
<ui:include src="./tableInclude.xhtml">
i tried to do this:
<ui:fragment rendered="#{request.requestURI != '/context/don't_render_here.xhtml'}">
<ui:include src="./tableInclude.xhtml">
</ui:fragment>
But i still get the duplicated id error even so when i access the "don't_render_here.xhtml" page.
not the best solution, but a quick and dirty: replace ui:fragment with f:subView

Jsf 2.0-<ui:include>xhtml included always even if rendered is false

I have a home page xhtml where i am including 3 child xhtml based on conditions.
The issue i am facing is , whatever be the scenario,Book.xhtml always gets invoked.
I changed the rendered condition to false or move out to another condition, but the file always gets invoked Due to which its backing bean also is invoked causing unwanted overhead.
Please provide me a solution
<ui:composition template="/xhtml/baseLayout.xhtml">
<ui:define name="browserTitle">
<h:outputText value="HOME PAGE" />
</ui:define>
<ui:define name="header">
<ui:include src="/xhtml/header.xhtml" />
</ui:define>
<ui:define name="bodyContent">
<h:panelGrid width="100%"
rendered="#{pogcore:isRoleAuthorized(BUNDLE.SUPER)}" >
<ui:include src="/xhtml/SuperUser.xhtml" />
</h:panelGrid>
<h:panelGrid width="100%"
rendered="#{pogcore:isRoleAuthorized(BUNDLE.MAINTENANCE)}" >
<ui:include src="/xhtml/Maintenance.xhtml" />
</h:panelGrid>
<h:panelGrid width="100%"
rendered="#{pogcore:isRoleAuthorized(BUNDLE.PRINT)}">
<ui:include src="/xhtml/Book.xhtml" />
</h:panelGrid>
</ui:define>
</ui:composition>
This is happening due to lifecycle of jsf. JSF UIComponents are evaluated during view render time where as jstl tags are evaluated at build time.
So when you use rendered attribute of h:panelGrid it is too late to not invoke managed beans under the included page. To resolve this try having conditions using jstl tag, the following should work for you.
<c:if test="#{bean.yourCondition}">
<h:panelGrid width="100%">
<h:outputText value="#{bean.yourCondition}"/> <!--if this is not getting printed there is smtg wrong with your condition, ensure the syntax, the method signature is correct-->
<ui:include src="/xhtml/Book.xhtml" />
</h:panelGrid>
</c:if>
<c:if test="#{!bean.yourCondition}">
<h:outputText value="#{bean.yourCondition}"/> <!--This should print false-->
</c:if>
The document below describes the details of jstl and jsf lifecycle.
http://www.znetdevelopment.com/blogs/2008/10/18/jstl-with-jsffacelets/
Check the following document to see another way to solve this without using jstl tags.
http://pilhuhn.blogspot.com/2009/12/facelets-uiinclude-considered-powerful.html
Do this:
Always include the sub pages
Put the panelGrid (with the rendered) inside the page that you always include
Why ? Because the inclusion is performed before the rendered is evaluated.

Resources