java/sql-vyuka/web/ajax.jspx
author František Kučera <franta-hg@frantovo.cz>
Sun Apr 07 18:38:36 2013 +0200 (2013-04-07)
changeset 81 6fb319847482
parent 58 bbc73f664363
permissions -rw-r--r--
Oprava: Obecné ECMAScriptové nahrazování řetězců.
Chyba se projevovala v Chromiu, ve FF to fungovalo.
Při kliknutí na SQL v průvodci (např. „Restrikce – operátory“), které obsahuje víc > se nahradil jen první výskyt (ignorování nestandardního "g").
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/replace
franta-hg@24
     1
<?xml version="1.0" encoding="UTF-8"?>
franta-hg@24
     2
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
franta-hg@24
     3
          xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
franta-hg@27
     4
          xmlns:fn="http://java.sun.com/jsp/jstl/functions"
franta-hg@24
     5
          xmlns:c="http://java.sun.com/jsp/jstl/core"
franta-hg@24
     6
          version="2.0">
franta-hg@24
     7
    <jsp:directive.page contentType="text/html" pageEncoding="UTF-8"/>
franta-hg@24
     8
    <fmt:setBundle basename="cz.frantovo.sql.vyuka.preklady" scope="application"/>
franta-hg@24
     9
    <jsp:useBean id="ajax" class="cz.frantovo.sql.vyuka.web.Ajax" scope="request"/>
franta-hg@24
    10
franta-hg@24
    11
    <jsp:scriptlet>
franta-hg@73
    12
	    request.setCharacterEncoding("UTF-8");
franta-hg@73
    13
	    ajax.setKlient(request.getRemoteAddr(), request.getHeader("x-forwarded-for"), request.getRequestedSessionId());
franta-hg@24
    14
    </jsp:scriptlet>
franta-hg@24
    15
franta-hg@24
    16
    <c:choose>
franta-hg@29
    17
        <!-- <Akce: Historie a vykonání SQL příkazu> -->
franta-hg@24
    18
        <c:when test="${param.akce == 'historie' || param.akce == 'vykonat'}">
franta-hg@29
    19
            <!-- <Načteme výsledek z beany>  -->
franta-hg@24
    20
            <c:choose>
franta-hg@24
    21
                <c:when test="${param.akce == 'historie'}">
franta-hg@24
    22
                    <c:set var="vysledek" value="${ajax.historie}" scope="request"/>
franta-hg@24
    23
                </c:when>
franta-hg@24
    24
                <c:when test="${param.akce == 'vykonat'}">
franta-hg@24
    25
                    <jsp:setProperty name="ajax" property="sqlPrikaz" value="${param.sql}"/>
franta-hg@24
    26
                    <c:set var="vysledek" value="${ajax.SQLVysledek}" scope="request"/>
franta-hg@24
    27
                </c:when>
franta-hg@24
    28
            </c:choose>
franta-hg@29
    29
            <!-- </Načteme výsledek z beany>  -->
franta-hg@24
    30
franta-hg@29
    31
            <!-- <Tabulky> -->
franta-hg@24
    32
            <c:forEach var="tabulka" items="${vysledek.tabulky}">
franta-hg@26
    33
                <!-- <lokalizace> -->
franta-hg@26
    34
                <c:choose>
franta-hg@26
    35
                    <c:when test="${tabulka.lokalizovat}">
franta-hg@26
    36
                        <fmt:message key="${tabulka.zahlaviTip}" var="zahlaviTip"/>
franta-hg@26
    37
                    </c:when>
franta-hg@26
    38
                    <c:otherwise>
franta-hg@26
    39
                        <c:set value="${tabulka.zahlaviTip}" var="zahlaviTip"/>
franta-hg@26
    40
                    </c:otherwise>
franta-hg@26
    41
                </c:choose>
franta-hg@26
    42
                <!-- </lokalizace> -->
franta-hg@73
    43
		<c:choose>
franta-hg@73
    44
                    <c:when test="${fn:length(tabulka.zahlavi) == 1 &amp;&amp; tabulka.zahlavi[0] == 'pouze_xml'}">
franta-hg@73
    45
			<!-- <XML tabulka> -->
franta-hg@73
    46
                        <pre><c:out value="${tabulka.hodnoty[0][0]}" /></pre>
franta-hg@73
    47
			<!-- </XML tabulka> -->
franta-hg@73
    48
                    </c:when>
franta-hg@73
    49
                    <c:otherwise>
franta-hg@73
    50
			<!-- <bežná tabulka> -->
franta-hg@73
    51
			<table>
franta-hg@73
    52
			    <thead title="${zahlaviTip}">
franta-hg@73
    53
				<tr>
franta-hg@73
    54
				    <c:forEach var="zahlavi" items="${tabulka.zahlavi}">
franta-hg@73
    55
					<td>
franta-hg@73
    56
					    <!-- <lokalizace> -->
franta-hg@73
    57
					    <c:if test="${tabulka.lokalizovat}">
franta-hg@73
    58
						<fmt:message key="${zahlavi}" var="zahlavi"/>
franta-hg@73
    59
					    </c:if>
franta-hg@73
    60
					    <!-- </lokalizace> -->
franta-hg@73
    61
					    <c:out value="${zahlavi}"/>
franta-hg@73
    62
					</td>
franta-hg@73
    63
				    </c:forEach>
franta-hg@73
    64
				</tr>
franta-hg@73
    65
			    </thead>
franta-hg@73
    66
			    <tbody>
franta-hg@73
    67
				<c:forEach var="radek" items="${tabulka.hodnoty}">
franta-hg@73
    68
				    <tr>
franta-hg@73
    69
					<c:forEach var="bunka" items="${radek}">
franta-hg@73
    70
					    <!-- <formátováníPodleDatovýchTypů> -->
franta-hg@73
    71
					    <c:choose>
franta-hg@73
    72
						<c:when test="${bunka.class == 'class java.sql.Timestamp'}">
franta-hg@73
    73
						    <td>
franta-hg@73
    74
							<fmt:formatDate value="${bunka}" pattern="dd.MM.yyyy HH:mm:ss"/>
franta-hg@73
    75
							<!-- uvnitř vzoru je nedělitelná mezera -->
franta-hg@73
    76
						    </td>
franta-hg@73
    77
						</c:when>
franta-hg@73
    78
						<c:when test="${bunka.class == 'class java.sql.Date'}">
franta-hg@73
    79
						    <td>
franta-hg@73
    80
							<fmt:formatDate value="${bunka}" pattern="dd.MM.yyyy"/>
franta-hg@73
    81
						    </td>
franta-hg@73
    82
						</c:when>
franta-hg@73
    83
						<c:when test="${bunka.class == 'class java.lang.Integer' || bunka.class == 'class java.math.BigDecimal'}">
franta-hg@73
    84
						    <td class="cislo">
franta-hg@73
    85
							<fmt:formatNumber value="${bunka}" pattern="###,###.###"/>
franta-hg@73
    86
						    </td>
franta-hg@73
    87
						</c:when>
franta-hg@73
    88
						<c:when test="${bunka.class == 'class java.lang.Boolean'}">
franta-hg@73
    89
						    <td>
franta-hg@73
    90
							<c:choose>
franta-hg@73
    91
							    <c:when test="${bunka}">
franta-hg@73
    92
								<fmt:message key="boolean.pravda.tip" var="pravda"/>
franta-hg@73
    93
								<abbr title="${pravda}"><fmt:message key="boolean.pravda"/></abbr>
franta-hg@73
    94
							    </c:when>
franta-hg@73
    95
							    <c:otherwise>
franta-hg@73
    96
								<fmt:message key="boolean.nepravda.tip" var="nepravda"/>
franta-hg@73
    97
								<abbr title="${nepravda}"><fmt:message key="boolean.nepravda"/></abbr>
franta-hg@73
    98
							    </c:otherwise>
franta-hg@73
    99
							</c:choose>
franta-hg@73
   100
						    </td>
franta-hg@73
   101
						</c:when>
franta-hg@73
   102
						<c:otherwise>
franta-hg@73
   103
						    <td>
franta-hg@73
   104
							<c:out value="${bunka}" />
franta-hg@73
   105
						    </td>
franta-hg@73
   106
						</c:otherwise>
franta-hg@73
   107
					    </c:choose>
franta-hg@73
   108
					    <!-- </formátováníPodleDatovýchTypů> -->
franta-hg@73
   109
					</c:forEach>
franta-hg@73
   110
				    </tr>
franta-hg@73
   111
				</c:forEach>
franta-hg@73
   112
			    </tbody>
franta-hg@73
   113
			</table>
franta-hg@73
   114
			<!-- </bežná tabulka> -->
franta-hg@73
   115
		    </c:otherwise>
franta-hg@73
   116
                </c:choose>
franta-hg@24
   117
            </c:forEach>
franta-hg@29
   118
            <!-- </Tabulky> -->
franta-hg@24
   119
franta-hg@29
   120
            <!-- <Hlášky> -->
franta-hg@24
   121
            <c:forEach var="hlaska" items="${vysledek.hlasky}">
franta-hg@24
   122
                <p class="vysledek${hlaska.typ}">
franta-hg@24
   123
                    <c:out value="${hlaska.text}" escapeXml="${hlaska.escapovat}" />
franta-hg@24
   124
                </p>
franta-hg@24
   125
            </c:forEach>
franta-hg@29
   126
            <!-- </Hlášky> -->
franta-hg@24
   127
        </c:when>
franta-hg@29
   128
        <!-- </Akce: Historie a vykonání SQL příkazu> -->
franta-hg@24
   129
franta-hg@29
   130
franta-hg@29
   131
        <!-- <Akce: Nápověda> -->
franta-hg@24
   132
        <c:when test="${param.akce == 'napoveda'}">
franta-hg@37
   133
            <!-- <VolbaMetody> -->
franta-hg@37
   134
            <c:choose>
franta-hg@37
   135
                <c:when test="${param.pruvodce == 'podleId'}">
franta-hg@37
   136
                    <jsp:setProperty name="ajax" property="idPruvodce" value="${param.idPruvodce}"/>
franta-hg@37
   137
                    <c:set var="pruvodce" value="${ajax.pruvodcePodleId}" scope="request"/>
franta-hg@37
   138
                </c:when>
franta-hg@37
   139
                <c:when test="${param.pruvodce == 'podleKodu'}">
franta-hg@37
   140
                    <jsp:setProperty name="ajax" property="kodPruvodce" value="${param.kodPruvodce}"/>
franta-hg@37
   141
                    <c:set var="pruvodce" value="${ajax.pruvodcePodleKodu}" scope="request"/>
franta-hg@37
   142
                </c:when>
franta-hg@37
   143
                <c:when test="${param.pruvodce == 'predchozi'}">
franta-hg@37
   144
                    <jsp:setProperty name="ajax" property="idPruvodce" value="${param.idPruvodce}"/>
franta-hg@37
   145
                    <c:set var="pruvodce" value="${ajax.pruvodcePredchozi}" scope="request"/>
franta-hg@37
   146
                </c:when>
franta-hg@37
   147
                <c:when test="${param.pruvodce == 'nasledujici'}">
franta-hg@37
   148
                    <jsp:setProperty name="ajax" property="idPruvodce" value="${param.idPruvodce}"/>
franta-hg@37
   149
                    <c:set var="pruvodce" value="${ajax.pruvodceNasledujici}" scope="request"/>
franta-hg@37
   150
                </c:when>
franta-hg@37
   151
            </c:choose>
franta-hg@37
   152
            <!-- </VolbaMetody> -->
franta-hg@37
   153
franta-hg@37
   154
            <!-- <Výpis> -->
franta-hg@37
   155
            <c:choose>
franta-hg@37
   156
                <c:when test="${pruvodce.lokalizovat}">
franta-hg@37
   157
                    <h1><fmt:message key="${pruvodce.nadpis}"/></h1>
franta-hg@37
   158
                    <fmt:message key="${pruvodce.obsah}"/>
franta-hg@37
   159
                </c:when>
franta-hg@37
   160
                <c:otherwise>
franta-hg@37
   161
                    <h1><c:out value="${pruvodce.nadpis}"/></h1>
franta-hg@37
   162
                    <c:out value="${pruvodce.obsah}" escapeXml="false"/>
franta-hg@37
   163
                </c:otherwise>
franta-hg@37
   164
            </c:choose>
franta-hg@58
   165
            <form action="#" id="pruvodceData">
franta-hg@54
   166
                <textarea name="id" cols="100" rows="1">${pruvodce.id}</textarea>
franta-hg@38
   167
            </form>
franta-hg@37
   168
            <!-- </Výpis> -->
franta-hg@24
   169
        </c:when>
franta-hg@29
   170
        <!-- </Akce: Nápověda> -->
franta-hg@24
   171
    </c:choose>
franta-hg@24
   172
</jsp:root>