<f:ajax> Parent不是复合组件,也不是选择一个菜单上的ClientBehaviorHolder类型</f:ajax>

时间:2014-02-06 15:10:15

标签: ajax jsf jsf-2

我正在尝试根据为第一个值选择的内容显示第二个选择方法。现在我需要为我正在制作的表格执行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>

以下是我使用此代码获取的错误代码:

第88行和第76列的

/indexv2.xhtml父类不是复合组件或类型为ClientBehaviorHolder,类型为:javax.faces.component.UIViewRoot@13fcf10

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

2 个答案:

答案 0 :(得分:1)

删除f:ajax之外的h:selectOneMenuh:form不是ClientBehaviourHolder,因此您无法在f:ajax放置h:selectOneMenu。你可以将它们放入f:ajax

<小时/> 编辑:只需删除没有参数的panelGroup,包含selectOneMenu的参数,并保留<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> es:

</b>

<小时/> EDIT2:使用以下代码替换<br/>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>

答案 1 :(得分:0)

而不是使用'f:ajax'而是使用了richfaces'a4j:ajax'参数用于xhtml,而现在我有一个不同的问题“带有标签的网页不会只显示文本。”所以我无法确定我是否正确地转换为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>