Jsf primefaces inputext onblur事件不工作

Jsf primefaces inputext onblur事件不工作,jsf,primefaces,Jsf,Primefaces,您好,我有一个inputText on blur事件,它将向支持bean发送一个信号,这个bean包含一个布尔变量,它决定是否启用另一个输入文本。。。但我不能这样做,这是我的代码: <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java

您好,我有一个inputText on blur事件,它将向支持bean发送一个信号,这个bean包含一个布尔变量,它决定是否启用另一个输入文本。。。但我不能这样做,这是我的代码:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
template="/Template.xhtml">
<ui:define name="content">
<h:form id="someForm">
<p:growl id="msg" showDetail="true" life="3000"/>
<p:panelGrid border="0" id="panel">
<p:row>
<p:column width="350">
Title
</p:column>
<p:column colspan="2">
<p:inputText id="someId" value="#{someBean.somePropertie}">
<p:ajax event="blur" update="anotherInput" listener="#{someBean.onEvent}" />
</p:inputText>
</p:column>
</p:row>
<p:row>
<p:column width="350">title 2</p:column>
<p:column colspan="2">
<p:inputText id="anotherInput" converter="toUpperCaseConverter" value="#{someBean.somePropertie2}" 
disabled="#{someBean.bDisabled}"
/>
</p:column>
</p:row>
</p:panelGrid>
</h:form>
</ui:define>
</ui:composition>
这是主要的夯实机:

<!DOCTYPE html>
<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:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<h:head>
<title>..:: XXXXX ::..</title>
<meta http-equiv="Pragma" content="no-cache" />
<link rel="stylesheet" type="text/css" href="#{request.contextPath}/css/default.css"/>
<style type="text/css">
.ui-growl{
position:absolute;
top:20%;
left:50%;
z-index:9999;
}

.ui-widget,.ui-widget .ui-widget {
font-family: Trebuchet MS;
}
</style>
</h:head>
<h:body style="background-color: #E1E1E1;">
<div id="page">
<div id="divHeader" style="height: 70px;">
<ui:insert name="header" >
<ui:include src="header.xhtml" />
</ui:insert>
</div>
<div id="divMenu" style="height: 50px;">
<ui:insert name="menu">
<ui:include src="menu.xhtml" />
</ui:insert>
</div>
<div id="divContent">
<ui:insert id="content" name="content" >
<ui:include src="content.xhtml" />
</ui:insert>
</div>
</div>   
</h:body>
</html>
有什么想法吗


请帮助:

您的问题不完整,因为它没有提供复制错误的所有元素。您没有提供调用元素的页面,也没有提供转换器等

JSF的调试器最好的朋友是firebug。始终检查javascript错误,并启用网络选项卡以查看每个请求-响应正文,其中可能包含无声错误消息

我会冒险去猜你的问题:-

这是您的代码,稍微更改为在my primefaces 4中运行

<?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: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.org/ui">
<h:head>
    <title>You NEED a header</title>
</h:head>
<h:body>
    <h:form>
        <ui:include src="index2.xhtml" />   
    </h:form>
</h:body>
</html>
我注意到,如果不从调用方页面中省略HEAD部分,它似乎可以呈现和工作

但是如果您忘记了头部部分,请参见第2项,您将完全呈现页面,但会出现一些javascript错误,页面将无法工作。我要说的主要部分是这个

<h:head>
    <title>You NEED a header</title>
</h:head>
这是没有头部部分时的外观

对于头部,它似乎起作用。还要注意面部的细微表情和感觉


感谢您的回答,我更新了相关代码,我在主标题tamplate中的标题是您的意思?您的模板是什么样子的?我在原始问题中发布了:
<?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: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.org/ui">
<h:head>
    <title>You NEED a header</title>
</h:head>
<h:body>
    <h:form>
        <ui:include src="index2.xhtml" />   
    </h:form>
</h:body>
</html>
<ui:composition
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">
        <p:growl
            id="msg"
            showDetail="true"
            life="3000" />
        <p:panelGrid
            border="0"
            id="panel">
            <p:row>
                <p:column width="350">
Title
</p:column>
                <p:column colspan="2">
                    <p:inputText
                        id="someId"
                        value="#{someBean.somePropertie}">
                        <p:ajax
                            event="blur"
                            update="anotherInput"
                            listener="#{someBean.onEvent}" />
                    </p:inputText>
                </p:column>
            </p:row>
            <p:row>
                <p:column width="350">title 2</p:column>
                <p:column colspan="2">
                    <p:inputText
                        id="anotherInput"
                        value="#{someBean.somePropertie2}"
                        disabled="#{someBean.bDisabled}" />
                </p:column>
            </p:row>
        </p:panelGrid>
</ui:composition>
import java.io.Serializable;

import javax.faces.bean.ManagedBean;

@ManagedBean
@SuppressWarnings("serial")
public class SomeBean implements Serializable {

    private boolean bDisabled;

    private String somePropertie;
    private String somePropertie2;

    public void onEvent() {

        System.out.println("DO SOMETHING");

        this.bDisabled = true;

    }

    public boolean isbDisabled() {
        return this.bDisabled;
    }

    public void setbDisabled(boolean bDisabled) {
        this.bDisabled = bDisabled;
    }

    public String getSomePropertie() {
        return this.somePropertie;
    }

    public void setSomePropertie(String somePropertie) {
        this.somePropertie = somePropertie;
    }

    public String getSomePropertie2() {
        return this.somePropertie2;
    }

    public void setSomePropertie2(String somePropertie2) {
        this.somePropertie2 = somePropertie2;
    }

}
<h:head>
    <title>You NEED a header</title>
</h:head>