Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1d00b6ee

Přidáno uživatelem Jan Čarnogurský před asi 4 roky(ů)

  • ID 1d00b6ee972a1a7be011e8727eef19373112df3e
  • Rodič f09d9a1f

re #8102 - indication submit button in post

Zobrazit rozdíly:

src/main/java/vldc/aswi/web/controller/AssemblyController.java
142 142

  
143 143
        modelMap.addAttribute("configuration", configuration);
144 144
        modelMap.addAttribute("comparator", comparator);
145
        modelMap.addAttribute("formAction", "/assembly?assemblyID=" + assembly.getId());
145 146

  
146 147
        return modelAndView;
147 148
    }
......
155 156
     * @return ModelAndView for assembly.
156 157
     */
157 158
    @PostMapping("/assembly")
158
    public ModelAndView assemblyPost(@Valid Assembly assembly, BindingResult bindingResult, RedirectAttributes atts) {
159
        ModelAndView modelAndView = new ModelAndView();
159
    public ModelAndView assemblyPost(Assembly assembly,
160
                                     BindingResult bindingResult,
161
                                     RedirectAttributes atts,
162
                                     @RequestParam("assemblyID") String id,
163
                                     @RequestParam(required=false, value="generateTable") String generateTable,
164
                                     @RequestParam(required=false, value="exportXls") String exportXls,
165
                                     @RequestParam(required=false, value="exportPdf") String exportPdf,
166
                                     @RequestParam(required=false, value="saveConfiguration") String saveConfiguration)
167
    {
168
        if (generateTable != null)
169
        {
170
            System.out.println("Generuj tabulku");
171
        }
172
        else if (exportXls != null)
173
        {
174
            System.out.println("Generuj XLS");
175
        }
176
        else if (exportPdf != null)
177
        {
178
            System.out.println("Generuj PDF");
179
        }
180
        else if (saveConfiguration != null)
181
        {
182
            System.out.println("ulož konfiguraci");
183
        }
184

  
160 185

  
186

  
187
        ModelAndView modelAndView = new ModelAndView("redirect:/assembly?assemblyID=" + id);
188

  
189
        return modelAndView;
190
/*
161 191
        ModelMap modelMap = modelAndView.getModelMap();
162 192

  
163 193
        long assemblyID = assembly.getId();
......
170 200
        modelMap.addAttribute("contingencyTableRows", this.sqlQueryManager.getContingencyTableRow(assembly2.getSQLQuery()));
171 201

  
172 202
        return modelAndView;
203

  
204
 */
173 205
    }
174 206

  
175 207
    /**
src/main/java/vldc/aswi/web/controller/ConfigurationController.java
68 68

  
69 69
        modelMap.addAttribute("configuration", configuration);
70 70
        modelMap.addAttribute("comparator", comparator);
71
        modelMap.addAttribute("formAction", "/configuration?configurationID=" + configuration.getId());
71 72

  
72 73
        return modelAndView;
73 74
    }
......
80 81
     * @return modelAndView with redirection
81 82
     */
82 83
    @PostMapping("/configuration")
83
    public ModelAndView configurationPost(@Valid Configuration newConfiguration, BindingResult bindingResult,
84
                                          @RequestParam("configurationID") String id) {
84
    public ModelAndView configurationPost( Configuration newConfiguration,
85
                                           BindingResult bindingResult,
86
                                           @RequestParam("configurationID") String id,
87
                                           @RequestParam(required=false, value="generateTable") String generateTable,
88
                                           @RequestParam(required=false, value="exportXls") String exportXls,
89
                                           @RequestParam(required=false, value="exportPdf") String exportPdf,
90
                                           @RequestParam(required=false, value="saveConfiguration") String saveConfiguration)
91
    {
92
        if (generateTable != null)
93
        {
94
            System.out.println("Generuj tabulku");
95
        }
96
        else if (exportXls != null)
97
        {
98
            System.out.println("Generuj XLS");
99
        }
100
        else if (exportPdf != null)
101
        {
102
            System.out.println("Generuj PDF");
103
        }
104
        else if (saveConfiguration != null)
105
        {
106
            System.out.println("ulož konfiguraci");
107
        }
108

  
109

  
85 110
        ModelAndView modelAndView = new ModelAndView();
86 111

  
87 112
        if (bindingResult.hasErrors()) {
src/main/webapp/WEB-INF/templates/assembly.html
17 17
            <a href="/" class="btn btn-success mb-2">Zpět</a>
18 18
        </div>
19 19

  
20
        <form th:object="${configuration}" method="post" th:action="@{/configuration(configurationID=${configuration.id})}">
20
        <form th:object="${configuration}" method="post" th:action="@{${formAction}}">
21 21
            <input type="hidden" th:field="*{assembly.id}" th:value="${configuration.assembly?.getId()}"/>
22 22
            <div class="container box">
23 23
                <div class="col-md-12">
......
190 190
                    <div class="col-md-12 form-group row template-input">
191 191
                        <label for="exampleFormControlSelect1" class="template-input-label">Vlastní název šablony:</label>
192 192
                        <div class="">
193
                            <input type="text" required="required" class="form-control select-filter-input" id="name"
193
                            <input type="text" class="form-control select-filter-input" id="name"
194 194
                                   th:field="${configuration.name}">
195 195
                        </div>
196 196

  
197
                        <button type="submit" class="btn btn-success mb-2 template-input-submit">Uložit šablonu</button>
197
                        <button type="submit" class="btn btn-success mb-2 template-input-submit" name="saveConfiguration">Uložit šablonu</button>
198 198
                    </div>
199 199

  
200 200

  
201 201
                    <div class="buttons-wrap">
202
                        <button type="submit" class="btn btn-secondary mb-2 " name="generate-table">Vygenerovat tabulku
203
                        </button>
204
                        <button type="submit" class="btn btn-secondary mb-2 " name="export-xls">Export do XLS</button>
205
                        <button type="submit" class="btn btn-secondary mb-2 " name="export-pdf">Export do PDF</button>
202
                        <button type="submit" class="btn btn-secondary mb-2 " name="generateTable">Vygenerovat tabulku</button>
203
                        <button type="submit" class="btn btn-secondary mb-2 " name="exportXls">Export do XLS</button>
204
                        <button type="submit" class="btn btn-secondary mb-2 " name="exportPdf">Export do PDF</button>
206 205
                    </div>
207 206
                </div>
208 207
            </div>

Také k dispozici: Unified diff