Make request to BE with htmx

This commit is contained in:
Araozu 2024-03-14 18:11:00 -05:00
parent 151a2be1c4
commit 9f731c1c5c
5 changed files with 29 additions and 5 deletions

View File

@ -13,4 +13,5 @@ public class CertController {
public String index(Model model) {
return "certs";
}
}

View File

@ -0,0 +1,19 @@
package dev.araozu.eeg_java.person;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
@RequestMapping(path = "/person")
public class PersonController {
@GetMapping("/")
public String searchPersonByDniString(
@RequestParam(required = true, value="person_dni") String personDni
) {
System.out.println("PersonController.searchPersonByDniString: " + personDni);
return "fragments/sample.html";
}
}

View File

@ -1,12 +1,12 @@
<!DOCTYPE html>
<html lang="es" xmlns:th="http://www.thymeleaf.org">
<head th:replace="fragments/head"></head>
<head th:replace="~{fragments/head :: head}"></head>
<body hx-ext="response-targets, class-tools, loading-states">
<div class="grid grid-cols-[5rem_auto]">
<!-- Navigation Rail -->
<div th:replace="fragments/navigation_rail :: div"></div>
<div th:replace="~{fragments/navigation_rail :: div}"></div>
<!-- Certs -->
<div>
@ -21,7 +21,7 @@
</div>
<div x-data="{user_dni: ''}">
<form
hx-get="/certs/person" hx-target="#person-search-result"
hx-get="/person/" hx-target="#person-search-result"
hx-target-4*="#person-search-result"
hx-swap="outerHTML"
>
@ -30,6 +30,7 @@
invalid:border-c-error invalid:text-c-error
focus:border-c-primary outline-none font-mono
disabled:opacity-50 disabled:cursor-not-allowed" type="text" minLength="8"
name="person_dni"
maxLength="15" pattern="[0-9]{8,15}" placeholder="Número de DNI" x-model="user_dni"
required />

View File

@ -19,5 +19,5 @@
<!-- Phosphor icons -->
<link rel="stylesheet" type="text/css" href="https://unpkg.com/@phosphor-icons/web@2.0.3/src/regular/style.css" />
<!-- Alpinejs -->
<script src="https://unpkg.com/alpinejs" defer></script>
<script src="https://unpkg.com/alpinejs@3.13.7" defer></script>
</head>

View File

@ -0,0 +1,3 @@
<div>
Sample response :D (carita feliz)
</div>