簡體   English   中英

JSF <h:selectOneMenu> valueChangeListener不起作用

[英]JSF <h:selectOneMenu> valueChangeListener does not work

嗨,我有一個像這樣的jsp頁面

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>title</title>
</head>
<body>
<f:view>
    <f:loadBundle basename="amdocs.gcreport.messages" var="msg" />
    <h:panelGrid columns="1">
        <h:outputLabel value="#{msg.environmens}"></h:outputLabel>
    </h:panelGrid>
    <h:panelGrid columns="1">
        <h:selectOneMenu id="selectEnv" value="#{gCAnalyzerController.envName}" onchange="submit();" valueChangeListener="#{gCAnalyzerController.envValueChange}" >
                <f:selectItems value="#{gCAnalyzerController.envs}" var="env" itemValue="#{env.name}"/>
        </h:selectOneMenu>  
    </h:panelGrid>
.
.
.

每當我在此下拉列表框中更改值時,應在Bean類中調用函數envValueChange。 但是,當在IE中運行這段代碼時,出現異常“錯誤:期望對象”,當嘗試在Google chrome中調試時,出現了以下異常。

未捕獲的ReferenceError:未定義提交GCAnalyzerView.jsp:15 onchange

看來javascript提交()並未在任何地方定義,因此頁面無法加載它,任何人都可以告訴我在哪里以及如何實現此javascript方法?

由OP解決。

該代碼應包含在表單標簽中以進行提交。

<h:form>
    <h:panelGrid columns="1">
        <h:outputLabel value="#{msg.environmens}"></h:outputLabel>
    </h:panelGrid>
    <h:panelGrid columns="1">
        <h:selectOneMenu id="selectEnv" value="#{gCAnalyzerController.envName}" onchange="submit();" valueChangeListener="#{gCAnalyzerController.envValueChange}" >
                <f:selectItems value="#{gCAnalyzerController.envs}" var="env" itemValue="#{env.name}"/>
        </h:selectOneMenu>  
    </h:panelGrid>
</h:form>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM