【问题标题】:<f:ajax> Parent is not composite component or of type ClientBehaviorHolder on a selection one menu<f:ajax> 父级不是复合组件或选择一个菜单上的 ClientBehaviorHolder 类型
【发布时间】:2014-02-06 15:10:15
【问题描述】:

我正在尝试根据为第一个值选择的内容来显示第二种选择方法。现在我需要为我正在制作的表格执行此操作超过 38 次,但我想看看我是否可以先解决一个问题。这是到目前为止我在 jsf 页面上剪切的代码。其他 38 个问题的值都相同。我刚刚重新创建了项目,到目前为止 bean 是空的,但我知道我应该能够首先看到表单,这是我现在希望在添加值和代码之前做的。

    <!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:f="http://java.sun.com/jsf/core" >

    <h:head>
    <title>QC-Form</title>

    </h:head>
    <h:body>
    <h1 class="title">QC Form</h1>
    <br/> <br/>

      <font face="comic sans MS" size="2" color="#33CCFF">
      <p><b>Enter the information below: </b> </p>
      </font>

    <h:form>

     <font face="comic sans MS" size="2"> 

     <b>Your initials: </b>  
        <h:inputText value="#{qcFormBean.techNameValue}"/><br/>
    <br/>

     <b>Model #: </b>  
    <h:selectOneMenu value="#{qcFormBean.modelValue}">
      <f:selectItem itemValue="3600" itemLabel="3600" />
      <f:selectItem itemValue="7200" itemLabel="7200" />
      <f:selectItem itemValue="8300" itemLabel="8300" />
      <f:selectItem itemValue="8400" itemLabel="8400" />
      <f:selectItem itemValue="8500p" itemLabel="8500p" />
      <f:selectItem itemValue="8800" itemLabel="8800" />
      <f:selectItem itemValue="9000" itemLabel="9000" />
      <f:selectItem itemValue="9008" itemLabel="9008" />
      <f:selectItem itemValue="9200" itemLabel="9200" />
      <f:selectItem itemValue="9300" itemLabel="9300" />
    </h:selectOneMenu><br/>
     <br/>

    <b>Date : </b>
     <h:outputText  value="#{currentDate}"/>
    <br/> <br/>


    <b>Serial #: </b>  
        <h:inputText value="#{qcFormBean.serialValue}"/><br/>
    <br/>

    <b>Customer Name: </b>  
        <h:inputText value="#{qcFormBean.customerNameValue}"/><br/>
    <br/>

    <b>Special Instructions: </b>  
        <h:inputText value="#{qcFormBean.specialInstructionsValue}"/><br/>    

    </font>

      <font face="comic sans MS" size="2" color="#33CCFF">
      <p><b>QC Process</b> </p>
      </font>

     <font face="comic sans MS" size="2"> 


     <b>1.Unit Serial number has been applied: </b>
     <h:selectOneMenu value="#{qcFormBean.unitSerialValue}">
      <f:selectItem itemValue="P" itemLabel="Pass or Not Applicable" />
      <f:selectItem itemValue="A" itemLabel="FAIL-Nonfunctional" />
      <f:selectItem itemValue="B" itemLabel="FAIL-Intermittent" />
      <f:selectItem itemValue="C" itemLabel="FAIL-Incorrect" />
      <f:selectItem itemValue="D" itemLabel="FAIL-DLI Standard" />
      <f:selectItem itemValue="F" itemLabel="FAIL-Special Standard" />
      <f:selectItem itemValue="G" itemLabel="FAIL-Physical" />
    </h:selectOneMenu>
    <br/>

    <br/>
    <b>2.Screen Protector has been applied: </b>
    <h:panelGroup id="dliSticker">
        <h:selectOneMenu value="#{qcFormBean.dlitcStickerValue}">
          <f:selectItem itemValue="P" itemLabel="Pass or Not applicable" />
          <f:selectItem itemValue="M" itemLabel="FAIL-Mechanical" />
          <f:selectItem itemValue="E" itemLabel="FAIL-Electrical" />
          <f:selectItem itemValue="C" itemLabel="FAIL-Cosmetic" />
          <f:selectItem itemValue="S" itemLabel="FAIL-Software" />
          <f:ajax event="change" execute="@this" render="perfbyDlitcSticker" />
        </h:selectOneMenu>
    </h:panelGroup>

    <h:panelGroup id="perfbyDlitcSticker">
        <h:selectOneMenu value="#{qcFormBean.stickerFreq}"
        rendered="#{!qcFormBean.dliStickerValue eq  'P'}">
            <f:selectItem itemValue="A" itemLabel="Always" />                
            <f:selectItem itemValue="O" itemLabel="Often" />
            <f:selectItem itemValue="S" itemLabel="Seldom" />                
        </h:selectOneMenu>
    </h:panelGroup>


    <br/>
    </font>

    </h:form>

    </h:body>
    </html>

这是我使用此代码得到的错误代码:

/indexv2.xhtml 第 88 行第 76 列 Parent 不是复合组件或 ClientBehaviorHolder 类型,类型为:javax.faces.component.UIViewRoot@13fcf10

原因: javax.faces.view.facelets.TagException - /indexv2.xhtml 在第 88 行和第 76 列父级不是复合组件或 ClientBehaviorHolder 类型,类型为:javax.faces.component.UIViewRoot@13fcf10

【问题讨论】:

    标签: ajax jsf jsf-2


    【解决方案1】:

    删除h:selectOneMenu 之外的f:ajaxs。 h:form 不是 ClientBehaviourHolder,所以你不能在那里放置 f:ajax。您只需将它们放入h:selectOneMenu。


    编辑:只需删除不带参数的f:ajax,那些包装panelGroups 并保留selectOneMenues:
    <h:selectOneMenu value="#{qcFormBean.dlitcStickerValue}">
        <f:selectItem itemValue="P" itemLabel="Pass or Not applicable" />
        <f:selectItem itemValue="M" itemLabel="FAIL-Mechanical" />
        <f:selectItem itemValue="E" itemLabel="FAIL-Electrical" />
        <f:selectItem itemValue="C" itemLabel="FAIL-Cosmetic" />
        <f:selectItem itemValue="S" itemLabel="FAIL-Software" />
        <f:ajax event="change" execute="@this" render="perfbyDlitcSticker" />
    </h:selectOneMenu>
    


    EDIT2:将&lt;/b&gt; 和&lt;br/&gt; 之间的代码替换为commandButton 之前的代码,代码如下:
    <h:panelGroup id="dliSticker">
        <h:selectOneMenu value="#{qcFormBean.dlitcStickerValue}">
          <f:selectItem itemValue="P" itemLabel="Pass or Not applicable" />
          <f:selectItem itemValue="M" itemLabel="FAIL-Mechanical" />
          <f:selectItem itemValue="E" itemLabel="FAIL-Electrical" />
          <f:selectItem itemValue="C" itemLabel="FAIL-Cosmetic" />
          <f:selectItem itemValue="S" itemLabel="FAIL-Software" />
          <f:ajax event="change" execute="@this" render="perfbyDlitcSticker" />
        </h:selectOneMenu>
    </h:panelGroup>
    
    <h:panelGroup id="perfbyDlitcSticker">
        <h:selectOneMenu value="#{qcFormBean.stickerFreq}"
        rendered="#{!qcFormBean.dliStickerValue eq  'P'}">
            <f:selectItem itemValue="A" itemLabel="Always" />                
            <f:selectItem itemValue="O" itemLabel="Often" />
            <f:selectItem itemValue="S" itemLabel="Seldom" />                
        </h:selectOneMenu>
    </h:panelGroup>
    

    【讨论】:

    • 这实际上很令人困惑,因为您可以使用f:ajax 包装组件(请参阅mkblog.exadel.com/2010/04/…)。但我同意在这种情况下它们是不必要的。
    • 那么Ajax事件不是你的意思吗?
    • 我更新了我的代码来代表你的建议我不再收到错误我只是没有在我的 IE 中显示任何内容,你能提供一个关于如何输入的示例吗?
    • @GilbertV 您需要保留f:ajax 标签inside &lt;h:selectOneMenu&gt; 但可以删除它之外的标签。
    • 所以只留下'f:ajax'并保持这样吗? ?我会试试的
    【解决方案2】:

    我没有使用'f:ajax',而是使用了xhtml的richfaces'a4j:ajax'参数,而现在我有一个不同的问题“带有标签的网页不会只显示文本。”所以我无法确定我是否正确转换为richfaces,但这是我所做的更改,让我知道我是否正确,谢谢。

        <!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:f="http://java.sun.com/jsf/core" 
              xmlns:a4j="http://richfaces.org/a4j"   >
    
        <h:head>
        <title>QC-Form</title>
        <link href="./css/styles.css" 
              rel="stylesheet" type="text/css"/>
        </h:head>
    
        <f:view>
    
        <h:body>
        <h1 class="title">QC Form</h1>
        <br/> <br/>
    
          <font face="comic sans MS" size="2" color="#33CCFF">
          <p><b>Enter the information below: </b> </p>
          </font>
    
        <h:form>
    
         <font face="comic sans MS" size="2"> 
    
         <h:panelGroup id="initialInfo">
    
            <b>Your initials: </b>  
                <h:inputText value="#{qcFormBean.techNameValue}"/><br/>
            <br/>
    
            <b>Model #: </b>  
            <h:selectOneMenu value="#{qcFormBean.modelValue}">
              <f:selectItem itemValue="3600" itemLabel="3600" />
              <f:selectItem itemValue="7200" itemLabel="7200" />
              <f:selectItem itemValue="8300" itemLabel="8300" />
              <f:selectItem itemValue="8400" itemLabel="8400" />
              <f:selectItem itemValue="8500p" itemLabel="8500p" />
              <f:selectItem itemValue="8800" itemLabel="8800" />
              <f:selectItem itemValue="9000" itemLabel="9000" />
              <f:selectItem itemValue="9008" itemLabel="9008" />
              <f:selectItem itemValue="9200" itemLabel="9200" />
              <f:selectItem itemValue="9300" itemLabel="9300" />
            </h:selectOneMenu><br/>
             <br/>
    
            <b>Date : </b>
             <h:outputText  value="#{currentDate}"/>
            <br/> <br/>
    
    
            <b>Serial #: </b>  
                <h:inputText value="#{qcFormBean.serialValue}"/><br/>
            <br/>
    
            <b>Customer Name: </b>  
                <h:inputText value="#{qcFormBean.customerNameValue}"/><br/>
            <br/>
    
            <b>Special Instructions: </b>  
                <h:inputText value="#{qcFormBean.specialInstructionsValue}"/><br/>    
    
         </h:panelGroup>
        </font>
    
          <font face="comic sans MS" size="2" color="#33CCFF">
          <p><b>QC Process</b> </p>
          </font>
    
         <font face="comic sans MS" size="2"> 
    
        <h:panelGroup id="dliSerial">
         <b>1.Unit Serial number has been applied: </b>
         <h:selectOneMenu value="#{qcFormBean.unitSerialValue}">
        <f:selectItems value="#{qcFormBean.valueQcValue}"/>
        </h:selectOneMenu>
        <br/>
    
        </h:panelGroup>
    
        <br/>
        <b>2.Screen Protector has been applied: </b>
        <h:panelGroup id="dliSticker">
            <h:selectOneMenu value="#{qcFormBean.dliStickerValue}">
              <f:selectItem itemValue="P" itemLabel="Pass or Not applicable" />
              <f:selectItem itemValue="M" itemLabel="FAIL-Mechanical" />
              <f:selectItem itemValue="E" itemLabel="FAIL-Electrical" />
              <f:selectItem itemValue="C" itemLabel="FAIL-Cosmetic" />
              <f:selectItem itemValue="S" itemLabel="FAIL-Software" />
              <a4j:ajax event="change" execute="@this" render="perfbyDliSticker"  limitRender="true" />
            </h:selectOneMenu>
        </h:panelGroup>
    
        <h:panelGroup id="perfbyDlitcSticker">
            <h:selectOneMenu value="#{qcFormBean.stickerFreq}"
            rendered="#{!qcFormBean.dliStickerValue eq  'P'}">
                <f:selectItem itemValue="A" itemLabel="Always" />                
                <f:selectItem itemValue="O" itemLabel="Often" />
                <f:selectItem itemValue="S" itemLabel="Seldom" />                
            </h:selectOneMenu>
        </h:panelGroup>
    
    
        <br/>
        </font>
    
    
    
        </h:form>
    
        </h:body>
        </f:view>
        </html>
    

    【讨论】:

      猜你喜欢
      • 2011-04-02
      • 2013-06-20
      • 2021-06-09
      • 2016-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多