Skip to content

Commit 2e1c093

Browse files
committed
[cleanup] remove deprecated classes HtmxView and HtmxViewMethodReturnValueHandler
1 parent 3410aea commit 2e1c093

File tree

4 files changed

+1
-249
lines changed

4 files changed

+1
-249
lines changed

htmx-spring-boot/src/main/java/io/github/wimdeblauwe/htmx/spring/boot/mvc/HtmxMvcAutoConfiguration.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.springframework.context.annotation.Bean;
1111
import org.springframework.core.Ordered;
1212
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
13-
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
1413
import org.springframework.web.servlet.View;
1514
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
1615
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -47,11 +46,6 @@ public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers)
4746
resolvers.add(new HtmxResponseHandlerMethodArgumentResolver());
4847
}
4948

50-
@Override
51-
public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> handlers) {
52-
handlers.add(new HtmxViewMethodReturnValueHandler());
53-
}
54-
5549
@Override
5650
public ExceptionHandlerExceptionResolver getExceptionHandlerExceptionResolver() {
5751
return new HtmxExceptionHandlerExceptionResolver(handlerMethodHandler);

htmx-spring-boot/src/main/java/io/github/wimdeblauwe/htmx/spring/boot/mvc/HtmxView.java

Lines changed: 0 additions & 126 deletions
This file was deleted.

htmx-spring-boot/src/main/java/io/github/wimdeblauwe/htmx/spring/boot/mvc/HtmxViewMethodReturnValueHandler.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

htmx-spring-boot/src/test/java/io/github/wimdeblauwe/htmx/spring/boot/mvc/HtmxHandlerMethodTest.java

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,6 @@ public void testExceptionHandler() throws Exception {
5151
.andExpect(content().string("View1\n"));
5252
}
5353

54-
@Test
55-
public void testExceptionHandlerWithHtmxView() throws Exception {
56-
57-
mockMvc.perform(get("/throw-exception-htmx-view").headers(htmxRequest()))
58-
.andExpect(status().isOk())
59-
.andExpect(header().string("HX-Retarget", "#container"))
60-
.andExpect(content().string("View1\n"));
61-
}
62-
6354
@Test
6455
public void testExceptionHandlerUsingAnnotation() throws Exception {
6556

@@ -69,15 +60,6 @@ public void testExceptionHandlerUsingAnnotation() throws Exception {
6960
.andExpect(content().string("View1\n"));
7061
}
7162

72-
@Test
73-
public void testExceptionHandlerUsingAnnotationWithHtmxView() throws Exception {
74-
75-
mockMvc.perform(get("/throw-exception-annotated-htmx-view").headers(htmxRequest()))
76-
.andExpect(status().isOk())
77-
.andExpect(header().string("HX-Reswap", "none"))
78-
.andExpect(content().string("View1\n"));
79-
}
80-
8163
@Test
8264
public void testLocationRedirect() throws Exception {
8365

@@ -153,14 +135,6 @@ public void testLocationRedirectWithFlashAttributes() throws Exception {
153135
.andExpect(flash().attribute("flash", "test"));
154136
}
155137

156-
@Test
157-
public void testMultipleViews() throws Exception {
158-
159-
mockMvc.perform(get("/multiple-views").headers(htmxRequest()))
160-
.andExpect(status().isOk())
161-
.andExpect(content().string("View1\nView2\n"));
162-
}
163-
164138
@Test
165139
public void testRedirect() throws Exception {
166140

@@ -199,7 +173,7 @@ public void testRedirectViewNamePrefixFlashAttributes() throws Exception {
199173
mockMvc.perform(get("/contextpath/redirect-view-name-prefix-flash-attributes").contextPath("/contextpath").headers(htmxRequest()))
200174
.andExpect(status().isOk())
201175
.andExpect(header().string("HX-Redirect", "/contextpath/test"))
202-
.andExpect(flash().attribute("flash", "test"));;
176+
.andExpect(flash().attribute("flash", "test"));
203177
}
204178

205179
@Test
@@ -235,14 +209,6 @@ public void testRefreshViewName() throws Exception {
235209
.andExpect(header().string("HX-Refresh", HtmxValue.TRUE));
236210
}
237211

238-
@Test
239-
public void testSingleView() throws Exception {
240-
241-
mockMvc.perform(get("/single-view").headers(htmxRequest()))
242-
.andExpect(status().isOk())
243-
.andExpect(content().string("View1\n"));
244-
}
245-
246212
@Controller
247213
static class TestController {
248214

@@ -254,14 +220,6 @@ public String handleError(RuntimeException ex, HtmxRequest htmxRequest, HtmxResp
254220
return "view1";
255221
}
256222

257-
@ExceptionHandler(TestExceptionForHtmxViewHandler.class)
258-
public HtmxView handleError(TestExceptionForHtmxViewHandler ex, HtmxRequest htmxRequest, HtmxResponse htmxResponse) {
259-
if (htmxRequest.isHtmxRequest()) {
260-
htmxResponse.setRetarget("#container");
261-
}
262-
return new HtmxView("view1");
263-
}
264-
265223
@ExceptionHandler(TestExceptionForAnnotatedHandlerWithAnnotationOverride.class)
266224
@HxRetarget("#container")
267225
public String handleError(TestExceptionForAnnotatedHandlerWithAnnotationOverride ex, HtmxRequest htmxRequest, HtmxResponse htmxResponse) {
@@ -274,12 +232,6 @@ public String handleError(TestExceptionForAnnotatedHandler ex, HtmxRequest htmxR
274232
return "view1";
275233
}
276234

277-
@ExceptionHandler(TestExceptionForAnnotatedHandlerWithHtmxView.class)
278-
@HxReswap(HxSwapType.NONE)
279-
public HtmxView handleError(TestExceptionForAnnotatedHandlerWithHtmxView ex, HtmxRequest htmxRequest, HtmxResponse htmxResponse) {
280-
return new HtmxView("view1");
281-
}
282-
283235
@HxRequest
284236
@GetMapping("/location-redirect")
285237
public HtmxLocationRedirectView locationRedirect() {
@@ -370,12 +322,6 @@ public HtmxLocationRedirectView locationRedirectWithFlashAttributes(RedirectAttr
370322
return new HtmxLocationRedirectView("/path");
371323
}
372324

373-
@HxRequest
374-
@GetMapping("/multiple-views")
375-
public HtmxView multipleViews() {
376-
return new HtmxView("view1", "view2");
377-
}
378-
379325
@HxRequest
380326
@GetMapping("/redirect")
381327
public HtmxRedirectView redirect() {
@@ -430,24 +376,12 @@ public String refreshViewName() {
430376
return "refresh:htmx";
431377
}
432378

433-
@HxRequest
434-
@GetMapping("/single-view")
435-
public HtmxView singleView() {
436-
return new HtmxView("view1");
437-
}
438-
439379
@HxRequest
440380
@GetMapping("/throw-exception")
441381
public void throwException() {
442382
throw new RuntimeException();
443383
}
444384

445-
@HxRequest
446-
@GetMapping("/throw-exception-htmx-view")
447-
public void throwExceptionHtmxView() {
448-
throw new TestExceptionForHtmxViewHandler();
449-
}
450-
451385
@HxRequest
452386
@GetMapping("/throw-exception-annotation-override")
453387
@HxRetarget("controller-method-target")
@@ -461,26 +395,12 @@ public void throwExceptionForAnnotatedHandler() {
461395
throw new TestExceptionForAnnotatedHandler();
462396
}
463397

464-
@HxRequest
465-
@GetMapping("/throw-exception-annotated-htmx-view")
466-
public void throwExceptionForAnnotatedHandlerWithHtmxView() {
467-
throw new TestExceptionForAnnotatedHandlerWithHtmxView();
468-
}
469-
470-
}
471-
472-
static class TestExceptionForHtmxViewHandler extends RuntimeException {
473-
474398
}
475399

476400
static class TestExceptionForAnnotatedHandler extends RuntimeException {
477401

478402
}
479403

480-
static class TestExceptionForAnnotatedHandlerWithHtmxView extends RuntimeException {
481-
482-
}
483-
484404
static class TestExceptionForAnnotatedHandlerWithAnnotationOverride extends RuntimeException {
485405

486406
}

0 commit comments

Comments
 (0)