⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchform.jsp

📁 jsf与JavaScript结合的范例。让你轻松学会网络编程。
💻 JSP
字号:
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>

<f:view>
<html>
<head>
    <title>Search Form</title>
    <style type="text/css">
        .visible { margin-left: 40px; }
        .hidden  { display: none; }
    </style>
    <script type="text/javascript">
        function initForm() {
            var text = document.getElementById("searchForm:text");
            text.focus();
            updatePanelClass();
        }

        function updatePanelClass() {
            var checkbox = document.getElementById("searchForm:moreOptions");
            var panel = document.getElementById("searchForm:optionsPanel");
            panel.className = checkbox.checked ? "visible" : "hidden";
        }
    </script>
</head>
<body onload="initForm()">
    <h1>Search Form</h1>
    <h:form id="searchForm">
        <h:panelGrid columns="1" border="0" cellspacing="5">
            <h:panelGroup>
                <h:outputLabel value="Text: " for="text"/>
                <h:inputText id="text" value="#{searchBean.text}"
                    required="true" size="20"/>
                <h:message for="text"/>
            </h:panelGroup>
            <h:panelGroup>
                <h:selectBooleanCheckbox id="moreOptions"
                    value="#{searchBean.moreOptions}"
                    onclick="updatePanelClass()"/>
                <h:outputLabel value="More Options" for="moreOptions"/>
            </h:panelGroup>
            <h:panelGrid id="optionsPanel"
                    columns="1" border="0" cellspacing="5">
                <h:panelGroup>
                    <h:selectBooleanCheckbox id="matchCase"
                        value="#{searchBean.matchCase}"/>
                    <h:outputLabel value="Match Case" for="matchCase"/>
                </h:panelGroup>
                <h:panelGroup>
                    <h:outputLabel value="Language: " for="language"/>
                    <h:selectOneMenu id="language" value="#{searchBean.language}">
                        <f:selectItem itemValue="English" itemLabel="English"/>
                        <f:selectItem itemValue="Spanish" itemLabel="Spanish"/>
                        <f:selectItem itemValue="French" itemLabel="French"/>
                    </h:selectOneMenu>
                </h:panelGroup>
            </h:panelGrid>
            <h:commandButton id="search" value="Search"
                action="#{searchBean.searchAction}"/>
        </h:panelGrid>
    </h:form>
</body>
</html>
</f:view>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -