' .•` KIΛ.RΛR ’•. '
' .•` KIΛ.RΛR ’•. '
JCHJava Community | Help. Code. Learn.
Created by ' .•` KIΛ.RΛR ’•. ' on 9/19/2024 in #java-help
Gradle & Java Version
Im searching for the correct garde & java version to run thsi repo: https://github.com/boazy/TWEditorEnhanced currently i tried gradel v8: java 20 7:java20 6.22 java20 6.22 java11 none of these worked ._.
18 replies
JCHJava Community | Help. Code. Learn.
Created by ' .•` KIΛ.RΛR ’•. ' on 11/29/2023 in #java-help
springframework.validation.BindException: Date
@Controller
public class WelcomeController {
@GetMapping("/welcome")
public String mainWithParam(
@RequestParam(name = "name", required = false, defaultValue = "") String name, Model model,
@ModelAttribute ReservationForm form) {

model.addAttribute("form", form);
return "welcome";
}

@PostMapping("/welcome/a")
public String datePickerOnChange(@ModelAttribute("form") ReservationForm form, Model model,
@RequestParam String date) {
System.out.println("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
System.out.println(date);
System.out.println(form.getDate());
//set date on form to new date
//update data

/* [org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'form' on field 'date': rejected value [2023-11-29T11:20:17.719199]; codes [typeMismatch.form.date,typeMismatch.date,typeMismatch.java.time.LocalDateTime,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [form.date,date]; arguments []; default message [date]]; default message [Failed to convert value of type 'java.lang.String[]' to required type 'java.time.LocalDateTime'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.format.annotation.DateTimeFormat java.time.LocalDateTime] for value '2023-11-29T11:20:17.719199'; nested exception is java.lang.IllegalArgumentException: Parse attempt failed for value [2023-11-29T11:20:17.719199]]]
*/
return "welcome";
}
}
@Controller
public class WelcomeController {
@GetMapping("/welcome")
public String mainWithParam(
@RequestParam(name = "name", required = false, defaultValue = "") String name, Model model,
@ModelAttribute ReservationForm form) {

model.addAttribute("form", form);
return "welcome";
}

@PostMapping("/welcome/a")
public String datePickerOnChange(@ModelAttribute("form") ReservationForm form, Model model,
@RequestParam String date) {
System.out.println("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
System.out.println(date);
System.out.println(form.getDate());
//set date on form to new date
//update data

/* [org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'form' on field 'date': rejected value [2023-11-29T11:20:17.719199]; codes [typeMismatch.form.date,typeMismatch.date,typeMismatch.java.time.LocalDateTime,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [form.date,date]; arguments []; default message [date]]; default message [Failed to convert value of type 'java.lang.String[]' to required type 'java.time.LocalDateTime'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.format.annotation.DateTimeFormat java.time.LocalDateTime] for value '2023-11-29T11:20:17.719199'; nested exception is java.lang.IllegalArgumentException: Parse attempt failed for value [2023-11-29T11:20:17.719199]]]
*/
return "welcome";
}
}
21 replies
JCHJava Community | Help. Code. Learn.
Created by ' .•` KIΛ.RΛR ’•. ' on 11/28/2023 in #java-help
Java Date Parsing from String with Timezone
Tue Nov 28 18:26:14 CET 2023
Tue Nov 28 18:26:14 CET 2023
how can i parse this string as date? im not sure how to add weekdays and timezone ?? ?? dd HH:mm:ss ?? yyyy
9 replies
JCHJava Community | Help. Code. Learn.
Created by ' .•` KIΛ.RΛR ’•. ' on 11/25/2023 in #java-help
Thymeleaf Iteration with buttons, every button onclick gets called simultaniosly
<div>
<div class="alleyContainer" th:each="entry, it : ${listAlleys}" th:with="index = ${it.count}"> <!-- th:classappend="${entry.getType()}" -->
<div class="alleyContainer grid-alleyContainer">
<button class="btn" id="${entry.getId()}" th:id="${entry.getId()}" th:text="#{reservation.alley.book}" th:onclick="${form.addAlley(entry.getId())}">
Book Lane
</button>
</div>
</div>
</div>
<div>
<div class="alleyContainer" th:each="entry, it : ${listAlleys}" th:with="index = ${it.count}"> <!-- th:classappend="${entry.getType()}" -->
<div class="alleyContainer grid-alleyContainer">
<button class="btn" id="${entry.getId()}" th:id="${entry.getId()}" th:text="#{reservation.alley.book}" th:onclick="${form.addAlley(entry.getId())}">
Book Lane
</button>
</div>
</div>
</div>
Foreach has 12 items, they all get displayed with correct id, but when i tap on a button the onlcik gets called for all 12 entrys at the same time?
43 replies
JCHJava Community | Help. Code. Learn.
Created by ' .•` KIΛ.RΛR ’•. ' on 11/25/2023 in #java-help
Spring + Thymeleaf Datapicker onChange
is there a way to detect when the user chanegd the dateinput? i need to reload possible options based on the date so when the user changes the selected date the site should reload the displayed options
4 replies
JCHJava Community | Help. Code. Learn.
Created by ' .•` KIΛ.RΛR ’•. ' on 11/20/2023 in #java-help
Spring Post request without returning Template
i want a post request withpout having to return a template - just a simple plain abckend request qwq
10 replies
JCHJava Community | Help. Code. Learn.
Created by ' .•` KIΛ.RΛR ’•. ' on 11/20/2023 in #java-help
Spring RequestParam
i have a form, which has an array wiht ints. i want to add an int to this forms array.
@PostMapping(path = "/a")
String addEntry(@Valid @ModelAttribute("form") Form form, Errors errors, Model model,
@RequestParam(value = "id", required = false, defaultValue = "0") int id) {

if (id != 0) {
form.add(id);
return mainMapping(model, form); // is the get mapping for /a
// return "a";????
}
form.toNewEntry();
return "redirect:/b";
}
@PostMapping(path = "/a")
String addEntry(@Valid @ModelAttribute("form") Form form, Errors errors, Model model,
@RequestParam(value = "id", required = false, defaultValue = "0") int id) {

if (id != 0) {
form.add(id);
return mainMapping(model, form); // is the get mapping for /a
// return "a";????
}
form.toNewEntry();
return "redirect:/b";
}
Form
public void add(int id) {
List<Integer> arr = getAlleys();

if (arr.contains(id)) {
return;
}
arr.add(id);
setAlleys(arr);
System.out.println(getAlleys()); // [1]
}

Model toNewEntry() {
Model entry = Model();
System.out.println(getAlleys()); // []
entry.setAlleys(getAlleys());
return entry;
}
public void add(int id) {
List<Integer> arr = getAlleys();

if (arr.contains(id)) {
return;
}
arr.add(id);
setAlleys(arr);
System.out.println(getAlleys()); // [1]
}

Model toNewEntry() {
Model entry = Model();
System.out.println(getAlleys()); // []
entry.setAlleys(getAlleys());
return entry;
}
why is the array empty in the tonewentry func?
10 replies
JCHJava Community | Help. Code. Learn.
Created by ' .•` KIΛ.RΛR ’•. ' on 6/2/2023 in #java-help
Custom Collector
i try to write a custom collector, but the supllier function keeps saying type mismatch. the input is a ResourceType, the output should be a set of strings. im not sure what type i should name for the accumulator function tho ^^" (java version 20 i think)
public interface KeywordCollector extends Collector<RessourceType, List<String>, Set<String>> {}



public class PlainTextCollector implements KeywordCollector {
public Supplier<List<String>> supplier() {
return new ArrayList<String>();
}
}
public interface KeywordCollector extends Collector<RessourceType, List<String>, Set<String>> {}



public class PlainTextCollector implements KeywordCollector {
public Supplier<List<String>> supplier() {
return new ArrayList<String>();
}
}
Type mismatch: cannot convert from List<String> to Supplier<List<String>>Java(16777235)
9 replies