Skip to main content

Posts

Showing posts from March, 2023

Thymeleaf function on button click with multiple parameter

how you can write the onclick attribute using Thymeleaf syntax: <button type = "button" th:onclick= "|rejectSalaryPayment(' ${response.uuid} ', ${dto.id} )|" >Reject Salary Payment</button> This assumes that the response.uuid and dto.id variables are available in the current Thymeleaf context. If they are not, you will need to provide the appropriate values or expressions to evaluate them. Also note that the onclick attribute is written using the Thymeleaf expression syntax ( |...| ), which allows you to include string literals and variable expressions within the same attribute value. 

Why jar file or application takes lot of time to execute

There could be several reasons why your system is taking a lot of time to execute a jar file or application. Here are a few possible causes and solutions: Insufficient hardware resources: If your system does not have enough hardware resources such as RAM, CPU or storage, it can take longer for the jar file or application to execute. To resolve this issue, you can upgrade your hardware or try closing any unnecessary applications that are running in the background. Network issues: If the jar file or application relies on network resources, slow network connectivity can lead to delays in execution. To resolve this issue, you can try checking your network connectivity, ensure that your internet connection is stable and that the network is not congested. Large file size: If the jar file or application is large, it can take longer to load and execute. To resolve this issue, you can try compressing the file or splitting it into smaller files. Compatibility issues: If the jar file or applicati

Java Reflection Example

Document Filter an array by comparing another array @PatchMapping("/{id}") public Product updateProductFields(@PathVariable int id, @RequestBody Map<String, Object> fields){ retun updateProductByFileds(id, fields); } public Product updateProductByFileds(int id, Map<String, Object> fields){ Product existingProduct = repository.findById(id).get(); fields.forEach((key, value) -> { Field field = ReflectionUtils.findField(Product.class, key); field.setAccessible(true); ReflectionUtils.setFiled(field, existingProduct, value); }); retun repository.save(existingProduct); }