警告:此页面调用使用前缀 [tagname] 声明的 XML 命名空间,但该命名空间不存在标记库 [英] Warning: This page calls for XML namespace declared with prefix [tagname] but no taglibrary exists for that namespace

查看:21
本文介绍了警告:此页面调用使用前缀 [tagname] 声明的 XML 命名空间,但该命名空间不存在标记库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已按如下方式声明 Facelet 视图模板:

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>

这显示了以下警告消息中的 3 条:

This shows 3 of the following warning messages:

警告:此页面调用使用前缀输入声明的 XML 命名空间,但该命名空间不存在标签库.

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?

推荐答案

您已经声明了纯 HTML <input> 元素,并且 XML 解析器未配置为使用 http://www.w3.org/1999/xhtml 作为全局 XML 命名空间.自己添加.

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">


更新(10 年后):这种警告在 JSF 和 Facelets 的上下文中毕竟是完全错误的,其中 [somehtmltag] 是一个纯 HTML 标记名称,例如如htmlstyledivp


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.

警告:此页面需要使用前缀 [somehtmltag] 声明的 XML 命名空间,但该命名空间不存在标签库.

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

这是由 Mojarra 的代码实现中的错误引起的,该代码负责根据 XML 文档中的标签构建组件树.最初的想法是警告开发人员任何未注册的命名空间标记,例如 没有 xmlns:x=..."代码>.然后它会被渲染成普通香草".而不是解析为真正的组件.然而,负责此警告的代码无意中也匹配了无命名空间的标签,例如纯 HTML.

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.

它还导致了错误的含义,即在 Facelets 中需要声明默认的 XML 名称空间,而它在技术上实际上是可选的.它最多只对工具有用,例如当 IDE 本身不够智能,无法根据文件扩展名暗示它们时,IDE 能够自动完成纯 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.

根据 issue 4872 已在 Mojarra 中修复.

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

http://www.w3.org/1999/xhtml 的默认 XML 命名空间在 Facelets 中是可选的.您可以安全地从 XHTML 文件中省略它以保持代码精简.

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.

这篇关于警告:此页面调用使用前缀 [tagname] 声明的 XML 命名空间,但该命名空间不存在标记库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆