Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
947 views
in Technique[技术] by (71.8m points)

jsf - Warning: This page calls for XML namespace declared with prefix [tagname] but no taglibrary exists for that namespace

I've declared the Facelet view template as follows:

<ui:composition template="./templates/master.xhtml"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.prime.com.tr/ui">

  <ui:define name="content">
    <h:panelGroup rendered="#{!current.hasLoggedIn()}">      
      <h:panelGroup layout="block" styleClass="warningBox">
        <h:outputText value="#{app.youHaveNotLoggedIn}"/>
        <br/>
        <h:link value="#{lbls.login}" outcome="login"/>
      </h:panelGroup>      
    </h:panelGroup>

    <h:panelGroup rendered="#{current.hasLoggedIn()}">
      <p:panel>
        <f:facet name="header">
          <h:outputText value="#{lbls.requestWaggon}" />
        </f:facet>

        <h:form id="frmRequest">
          <h:panelGrid columns="3" footerClass="buttons">
            <h:outputText value="#{lbls.number}:"/>
            <h:inputText id="number" label="#{lbls.number}" styleClass="ltr" value="#{requestWaggon.request.number}" readonly="true" />
            <h:message for="number" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>

            <h:outputText value="#{lbls.requestDate}:"/>
            <h:panelGroup>
              <h:inputText styleClass="date ltr" id="date" label="#{lbls.requestDate}" value="#{requestWaggon.request.date}" required="true">
                <f:converter converterId="ir.khorasancustoms.DateConverter"/>
              </h:inputText>
              <input type="button" value="..." onclick="displayDatePicker('frmRequest:date', this);" class="datePicker"/>
            </h:panelGroup>
            <h:message for="date" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>

            <h:outputText value="#{lbls.nameOfMaterialOwner}:"/>
            <h:inputText id="ownerName" label="#{lbls.nameOfMaterialOwner}" value="#{requestWaggon.request.fullName}" required="true"/>
            <h:message for="ownerName" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>

            <h:outputText value="#{lbls.companyName}:"/>
            <h:inputText id="companyName" label="#{lbls.companyName}" value="#{requestWaggon.request.companyName}" required="true"/>
            <h:message for="companyName" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>

            <h:outputText value="#{lbls.nameOfMaterial}:"/>
            <h:inputText id="nameOfMaterial" label="#{lbls.nameOfMaterial}" value="#{requestWaggon.request.materialName}" required="true"/>
            <h:message for="nameOfMaterial" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>                        

            <h:outputText value="#{lbls.materialWeight}:"/>
            <h:panelGroup>
              <h:inputText id="materialWeight" styleClass="ltr" label="#{lbls.materialWeight}" value="#{requestWaggon.request.materialWeight}" required="true" style="min-width: 0px; width: 60px"/>
              <h:selectOneMenu id="weightUnit" label="#{lbl.weightUnit}" value="#{requestWaggon.request.weightUnit}" required="true" style="min-width: 0px; width: 90px">
                <f:selectItems value="#{requestWaggon.weightUnits}"/>
                <f:converter converterId="ir.khorasancustoms.CatalogValueConverter"/>
              </h:selectOneMenu>
            </h:panelGroup>
            <h:message for="materialWeight" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>

            <h:outputText value="#{lbls.senderAddress}:"/>
            <h:inputText id="senderAddress" label="#{lbls.senderAddress}" value="#{requestWaggon.request.address}" required="true" style="width: 350px;"/>
            <h:message for="senderAddress" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>

            <h:outputText value="#{lbls.receiverAddress} (#{lbls.country}):"/>            
            <h:selectOneMenu id="country" label="#{lbl.receiverAddress}" value="#{requestWaggon.request.country}" required="true">
              <f:selectItem/>
              <f:selectItems value="#{requestWaggon.countries}"/>
              <f:converter converterId="ir.khorasancustoms.CatalogValueConverter"/>
            </h:selectOneMenu>            
            <h:message for="country" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>

            <h:outputText value="#{lbls.station}:"/>
            <h:inputText id="station" styleClass="ltr" label="#{lbls.station}" value="#{requestWaggon.request.station}" required="true" />
            <h:message for="station" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>

            <h:outputText value="#{lbls.loadingDate}:"/>
            <h:panelGroup>
              <h:inputText styleClass="date ltr" id="loadingDate" label="#{lbls.loadingDate}" value="#{requestWaggon.request.loadingDate}" required="true">
                <f:converter converterId="ir.khorasancustoms.DateConverter"/>
              </h:inputText>
              <input type="button" value="..." onclick="displayDatePicker('frmRequest:loadingDate', this);" class="datePicker"/>
            </h:panelGroup>
            <h:message for="loadingDate" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>

            <h:outputText value="#{lbls.boundryStation}:"/>            
            <h:selectOneMenu id="boundryStation" label="#{lbl.boundryStation}" value="#{requestWaggon.request.bountryStation}" required="true">
              <f:selectItem/>
              <f:selectItems value="#{requestWaggon.boundryStations}"/>
              <f:converter converterId="ir.khorasancustoms.CatalogValueConverter"/>
            </h:selectOneMenu>            
            <h:message for="boundryStation" infoClass="info" warnClass="warning" errorClass="error" fatalClass="fatal"/>

            <f:facet name="footer">
              <h:commandButton action="#{requestWaggon.save}" value="#{lbls.ok}"/>
            </f:facet>
          </h:panelGrid>
          <h:outputScript>
            focusElement('frmRequest:ownerName');            
          </h:outputScript>
        </h:form>

        <f:facet name="footer">
          <h:messages styleClass="boxMessages" layout="table" infoClass="infoBox" warnClass="warningBox" errorClass="errorBox" fatalClass="errorBox" globalOnly="true"/>
        </f:facet>
      </p:panel>
    </h:panelGroup>
  </ui:define>
</ui:composition>

This shows 3 of the following warning messages:

Warning: This page calls for XML namespace declared with prefix input but no taglibrary exists for that namespace.

When I remove the <p:panel> tag, then those messages do not appear. How is this caused and how can I solve it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You've declared plain HTML <input> elements and the XML parser is somehow not been configured to use http://www.w3.org/1999/xhtml as global XML namespace. Add it yourself.

<ui:composition xmlns="http://www.w3.org/1999/xhtml">

Update (10 years later): this kind of warning is after all completely wrong in context of JSF and Facelets whereby [somehtmltag] is a plain HTML tag name such as html, style, div, p, etc.

Warning: This page calls for XML namespace declared with prefix [somehtmltag] but no taglibrary exists for that namespace.

It's caused by a bug in Mojarra's implementation of the code responsible for building the component tree based on tags found in a XML document. The original thought was to warn the developer about any namespaced tag which is not registered, such as <x:foo> without a xmlns:x="...". It would then be rendered "plain vanilla" instead of parsed as a real component. However the code responsible for this warning unintentionally also matches namespaceless tags such as plain HTML.

It also caused the incorrect implication that declaration of the default XML namespace is required in Facelets while it's technically really optional. It's at most only useful for tooling, e.g. the IDE being able to autocomplete plain HTML elements when the IDE itself isn't sufficiently smart to imply them based on file extension.

As per issue 4872 it's been fixed in Mojarra.

The default XML namespace of http://www.w3.org/1999/xhtml is optional in Facelets. You can safely omit it from your XHTML files to keep the code lean.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...