2

你好我有一个这样的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 submit() 没有在任何地方定义,所以页面无法加载它,谁能告诉我应该在哪里以及如何实现这个 javascript 方法?

4

1 回答 1

1

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>
于 2018-05-12T09:34:24.160 回答