Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 当另一个Select的值更改时,如何更新该Select?_Jsf - Fatal编程技术网

Jsf 当另一个Select的值更改时,如何更新该Select?

Jsf 当另一个Select的值更改时,如何更新该Select?,jsf,Jsf,因此,我的程序应该接收来自JavaBeans文件的输入,然后该文件将数据输出到现有的选择框,但只有当另一个选择框的选定值发生变化时才会输出。我该怎么做?以下是我现有的代码: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:h="http://xmlns.jcp.org/jsf/html"

因此,我的程序应该接收来自JavaBeans文件的输入,然后该文件将数据输出到现有的选择框,但只有当另一个选择框的选定值发生变化时才会输出。我该怎么做?以下是我现有的代码:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:f="http://xmlns.jcp.org/jsf/core">

<h:head>
    <title>Dropdown List</title>
</h:head>
<body>
    <select id="mySelect" onchange="myFunction()">
        <h:outputText value="#{helloWorld.getResultSet1()}" escape="false" />
        <f:attribute name="action" value="1" />
    </select>
    <br />

    <h:form id="formId">
        <h:inputHidden id="x" value="#{helloWorld.text}" />
        <h:commandButton id="y" value="read" action="#{helloWorld.submit()}">
            <f:ajax execute="@form" />
        </h:commandButton>
    </h:form>
    <div id="i">
        <select id="mySelect1">

        </select>
    </div>
    <p id="u"></p>

    <script>
        var x1 = document.getElementById("mySelect1");
        x1.style.display = 'none';
        document.getElementById("formId:y").style.display = 'none';

        function myFunction() {

            var x = document.getElementById('mySelect').value;
            document.getElementById("formId:x").value = x;
            document.getElementById("formId:y").click();

            var t = "#{helloWorld.getResultSet2()}";
            document.getElementById("u").innerHTML = t;
            x1.style.display = 'block';



        }
    </script>
</body>
</html>

不,您无法轻松使用您提供的代码。。。这不是什么JSF,也不是应该如何使用JSF。开始使用真正优秀的JSF教程

见对其他问题的评论。。。。。。