java/sql-vyuka/web/ajax.jspx
author František Kučera <franta-hg@frantovo.cz>
Tue Jul 21 21:17:14 2009 +0200 (2009-07-21)
changeset 58 bbc73f664363
parent 54 016667d7e0bc
child 73 7252f80b39de
permissions -rw-r--r--
Drobnost: XHTML validita v AJAXu.
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@24
    12
        request.setCharacterEncoding("UTF-8");
franta-hg@24
    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@24
    43
                <table>
franta-hg@26
    44
                    <thead title="${zahlaviTip}">
franta-hg@24
    45
                        <tr>
franta-hg@24
    46
                            <c:forEach var="zahlavi" items="${tabulka.zahlavi}">
franta-hg@26
    47
                                <td>
franta-hg@26
    48
                                    <!-- <lokalizace> -->
franta-hg@26
    49
                                    <c:if test="${tabulka.lokalizovat}">
franta-hg@26
    50
                                        <fmt:message key="${zahlavi}" var="zahlavi"/>
franta-hg@26
    51
                                    </c:if>
franta-hg@26
    52
                                    <!-- </lokalizace> -->
franta-hg@26
    53
                                    <c:out value="${zahlavi}"/>
franta-hg@26
    54
                                </td>
franta-hg@24
    55
                            </c:forEach>
franta-hg@24
    56
                        </tr>
franta-hg@24
    57
                    </thead>
franta-hg@24
    58
                    <tbody>
franta-hg@24
    59
                        <c:forEach var="radek" items="${tabulka.hodnoty}">
franta-hg@24
    60
                            <tr>
franta-hg@24
    61
                                <c:forEach var="bunka" items="${radek}">
franta-hg@27
    62
                                    <!-- <formátováníPodleDatovýchTypů> -->
franta-hg@27
    63
                                    <c:choose>
franta-hg@27
    64
                                        <c:when test="${bunka.class == 'class java.sql.Timestamp'}">
franta-hg@27
    65
                                            <td>
franta-hg@27
    66
                                                <fmt:formatDate value="${bunka}" pattern="dd.MM.yyyy HH:mm:ss"/>
franta-hg@29
    67
                                                <!-- uvnitř vzoru je nedělitelná mezera -->
franta-hg@27
    68
                                            </td>
franta-hg@27
    69
                                        </c:when>
franta-hg@27
    70
                                        <c:when test="${bunka.class == 'class java.sql.Date'}">
franta-hg@27
    71
                                            <td>
franta-hg@27
    72
                                                <fmt:formatDate value="${bunka}" pattern="dd.MM.yyyy"/>
franta-hg@27
    73
                                            </td>
franta-hg@27
    74
                                        </c:when>
franta-hg@27
    75
                                        <c:when test="${bunka.class == 'class java.lang.Integer' || bunka.class == 'class java.math.BigDecimal'}">
franta-hg@27
    76
                                            <td class="cislo">
franta-hg@27
    77
                                                <fmt:formatNumber value="${bunka}" pattern="###,###.###"/>
franta-hg@27
    78
                                            </td>
franta-hg@27
    79
                                        </c:when>
franta-hg@31
    80
                                        <c:when test="${bunka.class == 'class java.lang.Boolean'}">
franta-hg@31
    81
                                            <td>
franta-hg@31
    82
                                                <c:choose>
franta-hg@31
    83
                                                    <c:when test="${bunka}">
franta-hg@31
    84
                                                        <fmt:message key="boolean.pravda.tip" var="pravda"/>
franta-hg@31
    85
                                                        <abbr title="${pravda}"><fmt:message key="boolean.pravda"/></abbr>
franta-hg@31
    86
                                                    </c:when>
franta-hg@31
    87
                                                    <c:otherwise>
franta-hg@31
    88
                                                        <fmt:message key="boolean.nepravda.tip" var="nepravda"/>
franta-hg@31
    89
                                                        <abbr title="${nepravda}"><fmt:message key="boolean.nepravda"/></abbr>
franta-hg@31
    90
                                                    </c:otherwise>
franta-hg@31
    91
                                                </c:choose>
franta-hg@31
    92
                                            </td>
franta-hg@31
    93
                                        </c:when>
franta-hg@27
    94
                                        <c:otherwise>
franta-hg@27
    95
                                            <td>
franta-hg@27
    96
                                                <c:out value="${bunka}" />
franta-hg@27
    97
                                            </td>
franta-hg@27
    98
                                        </c:otherwise>
franta-hg@27
    99
                                    </c:choose>
franta-hg@27
   100
                                    <!-- </formátováníPodleDatovýchTypů> -->
franta-hg@24
   101
                                </c:forEach>
franta-hg@24
   102
                            </tr>
franta-hg@24
   103
                        </c:forEach>
franta-hg@24
   104
                    </tbody>
franta-hg@24
   105
                </table>
franta-hg@24
   106
            </c:forEach>
franta-hg@29
   107
            <!-- </Tabulky> -->
franta-hg@24
   108
franta-hg@29
   109
            <!-- <Hlášky> -->
franta-hg@24
   110
            <c:forEach var="hlaska" items="${vysledek.hlasky}">
franta-hg@24
   111
                <p class="vysledek${hlaska.typ}">
franta-hg@24
   112
                    <c:out value="${hlaska.text}" escapeXml="${hlaska.escapovat}" />
franta-hg@24
   113
                </p>
franta-hg@24
   114
            </c:forEach>
franta-hg@29
   115
            <!-- </Hlášky> -->
franta-hg@24
   116
        </c:when>
franta-hg@29
   117
        <!-- </Akce: Historie a vykonání SQL příkazu> -->
franta-hg@24
   118
franta-hg@29
   119
franta-hg@29
   120
        <!-- <Akce: Nápověda> -->
franta-hg@24
   121
        <c:when test="${param.akce == 'napoveda'}">
franta-hg@37
   122
            <!-- <VolbaMetody> -->
franta-hg@37
   123
            <c:choose>
franta-hg@37
   124
                <c:when test="${param.pruvodce == 'podleId'}">
franta-hg@37
   125
                    <jsp:setProperty name="ajax" property="idPruvodce" value="${param.idPruvodce}"/>
franta-hg@37
   126
                    <c:set var="pruvodce" value="${ajax.pruvodcePodleId}" scope="request"/>
franta-hg@37
   127
                </c:when>
franta-hg@37
   128
                <c:when test="${param.pruvodce == 'podleKodu'}">
franta-hg@37
   129
                    <jsp:setProperty name="ajax" property="kodPruvodce" value="${param.kodPruvodce}"/>
franta-hg@37
   130
                    <c:set var="pruvodce" value="${ajax.pruvodcePodleKodu}" scope="request"/>
franta-hg@37
   131
                </c:when>
franta-hg@37
   132
                <c:when test="${param.pruvodce == 'predchozi'}">
franta-hg@37
   133
                    <jsp:setProperty name="ajax" property="idPruvodce" value="${param.idPruvodce}"/>
franta-hg@37
   134
                    <c:set var="pruvodce" value="${ajax.pruvodcePredchozi}" scope="request"/>
franta-hg@37
   135
                </c:when>
franta-hg@37
   136
                <c:when test="${param.pruvodce == 'nasledujici'}">
franta-hg@37
   137
                    <jsp:setProperty name="ajax" property="idPruvodce" value="${param.idPruvodce}"/>
franta-hg@37
   138
                    <c:set var="pruvodce" value="${ajax.pruvodceNasledujici}" scope="request"/>
franta-hg@37
   139
                </c:when>
franta-hg@37
   140
            </c:choose>
franta-hg@37
   141
            <!-- </VolbaMetody> -->
franta-hg@37
   142
franta-hg@37
   143
            <!-- <Výpis> -->
franta-hg@37
   144
            <c:choose>
franta-hg@37
   145
                <c:when test="${pruvodce.lokalizovat}">
franta-hg@37
   146
                    <h1><fmt:message key="${pruvodce.nadpis}"/></h1>
franta-hg@37
   147
                    <fmt:message key="${pruvodce.obsah}"/>
franta-hg@37
   148
                </c:when>
franta-hg@37
   149
                <c:otherwise>
franta-hg@37
   150
                    <h1><c:out value="${pruvodce.nadpis}"/></h1>
franta-hg@37
   151
                    <c:out value="${pruvodce.obsah}" escapeXml="false"/>
franta-hg@37
   152
                </c:otherwise>
franta-hg@37
   153
            </c:choose>
franta-hg@58
   154
            <form action="#" id="pruvodceData">
franta-hg@54
   155
                <textarea name="id" cols="100" rows="1">${pruvodce.id}</textarea>
franta-hg@38
   156
            </form>
franta-hg@37
   157
            <!-- </Výpis> -->
franta-hg@24
   158
        </c:when>
franta-hg@29
   159
        <!-- </Akce: Nápověda> -->
franta-hg@24
   160
    </c:choose>
franta-hg@24
   161
</jsp:root>