File tree Expand file tree Collapse file tree 7 files changed +17
-5
lines changed
java/ru/mystamps/web/controller
webapp/WEB-INF/views/site Expand file tree Collapse file tree 7 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 30
30
import javax .servlet .http .HttpServletResponse ;
31
31
import javax .validation .groups .Default ;
32
32
33
+ import org .apache .commons .lang3 .StringUtils ;
34
+
33
35
import org .springframework .beans .propertyeditors .StringTrimmerEditor ;
34
36
import org .springframework .stereotype .Controller ;
35
37
import org .springframework .ui .Model ;
@@ -345,12 +347,12 @@ public String searchSeriesByCatalog(
345
347
@ RequestParam ("catalogName" ) String catalogName ,
346
348
Model model ,
347
349
Locale userLocale ,
348
- HttpServletResponse response )
350
+ RedirectAttributes redirectAttributes )
349
351
throws IOException {
350
352
351
- if (catalogNumber == null ) {
352
- response . sendError ( HttpServletResponse . SC_NOT_FOUND );
353
- return null ;
353
+ if (StringUtils . isBlank ( catalogNumber ) ) {
354
+ redirectAttributes . addFlashAttribute ( "numberIsEmpty" , true );
355
+ return "redirect:" + Url . INDEX_PAGE ;
354
356
}
355
357
356
358
String lang = LocaleUtils .getLanguageOrNull (userLocale );
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ spring.messages.cache-seconds: -1
26
26
spring.messages.fallback-to-system-locale : false
27
27
spring.messages.basename : \
28
28
ru/mystamps/i18n/Messages, \
29
+ ru/mystamps/i18n/ValidationMessages, \
29
30
ru/mystamps/i18n/SpringSecurityMessages, \
30
31
ru/mystamps/i18n/MailTemplates
31
32
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ spring.messages.cache-seconds: 60
28
28
spring.messages.fallback-to-system-locale : false
29
29
spring.messages.basename : \
30
30
ru/mystamps/i18n/Messages, \
31
+ ru/mystamps/i18n/ValidationMessages, \
31
32
ru/mystamps/i18n/SpringSecurityMessages, \
32
33
ru/mystamps/i18n/MailTemplates
33
34
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ spring.messages.cache-seconds: -1
26
26
spring.messages.fallback-to-system-locale : false
27
27
spring.messages.basename : \
28
28
ru/mystamps/i18n/Messages, \
29
+ ru/mystamps/i18n/ValidationMessages, \
29
30
ru/mystamps/i18n/SpringSecurityMessages, \
30
31
ru/mystamps/i18n/MailTemplates
31
32
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ value.too-short = Value is less than allowable minimum of {min} characters
24
24
value.too-long = Value is greater than allowable maximum of {max} characters
25
25
value.invalid-length = Value length must be equals to {max} characters
26
26
value.hyphen = Value must not start or end with hyphen
27
+ value.empty = Value must not be empty
27
28
28
29
category-name-en.invalid = Category name must consist only latin letters, hyphen or spaces
29
30
category-name-ru.invalid = Category name must consist only Russian letters, hyphen or spaces
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ value.too-short = Значение должно быть не менее {min}
24
24
value.too-long = Значение должно быть не более {max} символов
25
25
value.invalid-length = Значение должно быть длинной {max} символов
26
26
value.hyphen = Значение не должно начинаться или заканчиваться знаком дефиса
27
+ value.empty = Значение не должно быть пустым
27
28
28
29
category-name-en.invalid = Название категории может содержать только латинские буквы, дефис или пробел
29
30
category-name-ru.invalid = Название категории может содержать только кирилические буквы, дефис или пробел
Original file line number Diff line number Diff line change @@ -247,9 +247,14 @@ <h4 class="panel-title" th:text="#{t_search_by_catalog}">Search by catalog</h4>
247
247
</ div >
248
248
< div class ="panel-body ">
249
249
< form method ="post " action ="../series/search_result.html " th:action ="@{${SEARCH_SERIES_BY_CATALOG}} ">
250
- < div class ="form-group ">
250
+ < div class ="form-group " th:classappend =" ${numberIsEmpty != null ? 'has-error' : ''} " >
251
251
< label for ="catalogNumber " th:text ="|#{t_number}:| "> Number:</ label >
252
252
< input id ="catalogNumber " name ="catalogNumber " type ="search " class ="form-control " required ="required " />
253
+ <!--/*/
254
+ <span th:if="${numberIsEmpty != null}" th:text="#{value.empty}" class="help-block">
255
+ Value must not be empty
256
+ </span>
257
+ /*/-->
253
258
</ div >
254
259
< div class ="form-group ">
255
260
< label for ="catalogName " th:text ="|#{t_catalog}:| "> Catalog:</ label >
You can’t perform that action at this time.
0 commit comments