userexit
JCHJava Community | Help. Code. Learn.
•Created by userexit on 11/3/2024 in #java-help
How to include a thymeleaf template into another one, to include header, footer etc
Title is self explanatory
-
63 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 11/2/2024 in #java-help
I set incrment to be 10, and I set initial value to be 100 but its not working, did it with hibernat
242 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 10/30/2024 in #java-help
How to create custom id generator for primary key in springboot
very clear question in title
302 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 10/30/2024 in #java-help
How to choose between using @Enumerated and a converter ? or @PostLoad and @PrePersist ?
Which one is better ? or does it depend, and if it depends, in what does it depend ?
4 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 10/28/2024 in #java-help
Enable live reload with Spring Boot devtools
help with the title
7 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 10/28/2024 in #java-help
Need help with this error in vscodium
8 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 10/28/2024 in #java-help
Syntax questions
Id like to know what these syntaxes mean:
javadoc -d doc Hello.java
jar -cf hello.jar Hello.class
java -cp hello.jar Hello
36 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/24/2024 in #java-help
Is this good composition class ?
4 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/21/2024 in #java-help
Help decoupling a presenter class in multiple classes
4 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/21/2024 in #java-help
Is it good practice to have 2 DTO's. one for database, one for application.
Im having an error as my DTO constructor can throw exceptions if the data introduced to it is invalid, but doing so means I can't create DTO's in DAO without handling these exceptions, but the DAO layer is not supposed to handle exceptions
4 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/21/2024 in #java-help
Should I decouple my presenter in multiple ones ?
6 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/20/2024 in #java-help
Help improving this code
ok so when i query a favorite row i know its id because its already been inserted, problem arises when i try inserting a favoritedto that i made in the program, i cant know what the id will be for it, but i dont have to either because the add method of my dao will just insert it and sql will generate a key for it. problem is when im trying to save a favorite ride i need to pass a favoritedto as argument but a favoritedto requires a id to be constructed, so i just put garbage number to construct it, there is no issue then all fine. problem is i dont think this is good written and i would refer to this as spaghetti code
195 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/20/2024 in #java-help
How could I simplify this
public interface Dao<K, S extends Key<K>> {
void update(S item);
void insert(S item);
void delete(K key);
S select(K key);
List<S> selectAll();
}
public interface Dao<K, T, S extends Key<K, T>> {
void update(S item);
void insert(S item);
void delete(K key1, T key2);
S select(K key1, T key2);
List<S> selectAll();
}
public interface Dao<K, T, I S extends Key<K, T, I>> {
void update(S item);
void insert(S item);
void delete(K key1, T key2, I key3);
S select(K key1, T key2, I key3);
List<S> selectAll();
}
87 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/19/2024 in #java-help
HELP HANDLING ERRORS IN MVP
Design Pattern: MVP -> MODEL-VIEW-PRESENTER
Interaction with user - presenter calls logic on model - model updates presenter - presenter updates view and/or calls new logic on model
now assume there is code in model that throws errors (parameter validation for example):
in presenter:
try {
model.doSomething();
} catch (error) {
view.showError(blabla);
}
is it better this way, or is it better like this:
in presenter:
model.doSomething();
in model:
if (name.length < 2) {
notifyObservers(ModelEvent.NOT_ENOUGH_NAME_LENGTH);
return;
}
then in presenter:
update(ModelEvent event) {
switch (event) {
case NOT_ENOUGH_NAME_LENGTH:
view.showError(blabla);
break;
}
}
50 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/18/2024 in #java-help
Help Project MVP Layout
I was thinking of this layout:
Presenter class that will handle interaction between model and view
ViewController class with methods to interact with the UI
Model package with:
- Repository that is going to contact the database and get me the needed information
- Dijkstra class that is going to handle calculating shortest path between 2 nodes.
Instantiating View => generating the UI
Instantiating Presenter => initializing the View with data that I get from the model, adding presenter as a button handler for view and adding presenter as an observer of Model
Instantiating Model => creating an instance of dijkstra and repository.
any idea how to optimize this ?
4 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/18/2024 in #java-help
Help optimize this dijkstra algorithm:
9 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/17/2024 in #java-help
Help implementing DJIKSTRA ALGORITHM
I have a Graph class that contains a Set of nodes,
I define a node to have a name and adjacent nodes.
The only thing im struggling with is:
lets say we have this:
A ---- B ---- C
|
|
D ---- E
Node D has name "D" and its adjacent nodes are E and A. How can I adapt my class to hold the distance to node E and A ? I have thought of modifying my node class to have a attribute distance to Parent, then Node E distance to parent is 1 but what if it has multiple parents as in what if a node F was connected to it
4 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/17/2024 in #java-help
How can I do this MVP model view presenter
Trying to implement this design pattern but need some help,
my view class extends Application and has a start method inside it how can I access this and launch the view through my main class ?
58 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/17/2024 in #java-help
Can anyone explain this error message
Explain this error message please:
27 replies
JCHJava Community | Help. Code. Learn.
•Created by userexit on 5/16/2024 in #java-help
What is the benefit of using the Singleton pattern like this:
What is the benefit of having an internal class compared to just returning a new ConfigManager()
33 replies