Primefaces Javascript Uncaught TypeError:无法调用未定义的方法'val'

时间:2014-02-10 14:18:17

标签: javascript jquery jsf primefaces selectonemenu

我已经找到了与此类似的主题,但我使用的是Primefaces,但我找不到具体的解决方案。

我正在分享xhtml

SSCCE版本:

<p:selectOneMenu id="selectCondition"  value="#{ruleBean.selectedCondition}" style="width:300px">
            <p:ajax listener="#{ruleBean.onConditionSelected}" update="panelLinkerId" />
            <f:selectItem itemLabel="Yeni Koşul Ekle" itemValue="1" />
            <f:selectItem itemLabel="Hava Durumu" itemValue="2" />
            <f:selectItem itemLabel="Nem" itemValue="3" />
            <f:selectItem itemLabel="Sıcaklık" itemValue="4" />
</p:selectOneMenu>

以下是整个代码:

<?xml version="1.0" encoding="UTF-8"?>
<!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://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:b="http://books.org/jsf/taglib">

<h:body>    

<ui:composition template="/resources/templates/commonLayout.xhtml">

<!-- <h:outputScript library="primefaces" name="jquery/jquery.js" target="head" /> -->
<!-- <h:outputScript library="primefaces" name="jquery/jquery-plugins.js" target="head" /> -->

<ui:define name="head">
</ui:define>


<ui:define name="content">


<h:form id="form"> 

<p:growl id="growl" sticky="true" showDetail="true"/>
<h:outputText value="&#160;" />

<p:panel header="Ürün">
    <h:panelGrid columns="4" cellpadding="5">
        <p:selectOneMenu id="selectProduct"  value="#{ruleBean.selectedProduct}" style="width:300px">
            <f:selectItem itemLabel="Bir Ürün Seçiniz" itemValue="" />  
            <f:selectItems value="#{ruleBean.mappedProducts}" /> 
        </p:selectOneMenu>
        <p:selectOneMenu id="selectProductcard"  value="#{ruleBean.selectedProductcard}" style="width:300px">
        <f:selectItem itemLabel="Bir Ürün Kartı Seçiniz" itemValue="" />  
            <f:selectItems value="#{ruleBean.mappedProductcards}" /> 
        </p:selectOneMenu>
        <p:selectOneMenu id="selectRegion"  value="#{ruleBean.selectedRegion}" style="width:300px">
        <f:selectItem itemLabel="Bir Bölge Seçiniz" itemValue="" />  
            <f:selectItems value="#{ruleBean.mappedRegions}" /> 
        </p:selectOneMenu>
        <p:selectOneMenu id="selectPeriod"  value="#{ruleBean.selectedPeriod}" style="width:300px">
        <f:selectItem itemLabel="Bir Dönem Seçiniz" itemValue="" />  
            <f:selectItems value="#{ruleBean.mappedPeriods}" /> 
        </p:selectOneMenu>
    </h:panelGrid>
</p:panel>
<p:panel header="Koşul" style="width:800px;text-align:center;">
    <p:selectOneMenu id="selectCondition"  value="#{ruleBean.selectedCondition}" style="width:300px">
        <p:ajax listener="#{ruleBean.onConditionSelected}" update="panelLinkerId" />
        <f:selectItem itemLabel="Yeni Koşul Ekle" itemValue="1" />
        <f:selectItem itemLabel="Hava Durumu" itemValue="2" />
        <f:selectItem itemLabel="Nem" itemValue="3" />
        <f:selectItem itemLabel="Sıcaklık" itemValue="4" />
    </p:selectOneMenu>
</p:panel>
<p:panel id="panelLinkerId" header="Bağlayıcı" style="width:800px;text-align:center;" widgetVar="panelLinker" visible="false">
<h:panelGrid columns="1" style="margin-bottom:10px;width:800px;text-align:center;" cellpadding="5" >
    <p:selectOneButton value="#{ruleBean.selectedTimeType}" >  
        <f:selectItem itemLabel="Geçmiş" itemValue="1" />  
        <f:selectItem itemLabel="Şimdi" itemValue="2" />  
        <f:selectItem itemLabel="Gelecek" itemValue="3" />
    </p:selectOneButton>
    <p:commandButton id="addLinker" value="Bağlayıcı Ekle" actionListener="#{ruleBean.showLinkerPopup}" update="growl" />
</h:panelGrid>  
</p:panel> 

<p:dialog header="Bağlayıcı Ekle" widgetVar="linkerPopup" resizable="false" id="linkerPopupDlg"  
            showEffect="fade" hideEffect="explode" modal="true"> 

    <h:panelGrid columns="2" cellpadding="5">
    </h:panelGrid>
</p:dialog>


</h:form>  
</ui:define>
</ui:composition>
</h:body>

</html>

正如您所看到的,当我在selectOneMenu中使用'selectCondition'id选择一个项目时,浏览器会抛出此错误:“Uncaught TypeError:无法调用未定义的方法'val'”

因此,这会导致像commandbutton这样的链错误从不调用它的监听器。

注意: selectOneMenu在值更改时调用onConditionSelected Java方法,并且方法调用'panelLinker.show();' js代码。当我删除此方法并将panelLinker可见性设置为可见时,此错误消失。所以它使这个问题非常奇怪。

我希望这不是Primefaces的错误。我在等你的宝贵方法。

干杯。

0 个答案:

没有答案