James Dekker

Ranch Hand
+ Follow
since Dec 09, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
5
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by James Dekker

Am using Java 1.8, Primefaces 10.0.0 on Tomcat 8.5.55... Am fairly new to JSF UI programming. Have a custom date JSTL tag where I need to dynamically set the maxdate to be 10 years from now when using the calendar widget (p:datePicker) - this is generic so that's why I can't place it inside a custom bean. It needs to be set declaratively inside my input.xhtml file (see below):

pom.xml:



input.xhtml (custom taglib located inside ..src/main/webapp/WEB-INF/tags/input.xhtml):



My mindate works - I can not go before 1/1/2011 in my calendar widget.

But I can go well past 2031 inside my calendar widget.

How can I set the maxdate to 10 years from now only in the input.xhtml file?
5 days ago
JSF
Thanks Ritchie,

This works now:

1 week ago
Carey,

Thanks but it still doesn't work using your suggestion:



yields:



Even tried this:



same issue:



What am I possibly doing wrong?
1 week ago
Thank you all for the quick responses and sound advice...

When I tried doing this with BigDecimal:



My Junit tests break:



The correct values are displaying but my JUnit tests don't seem to like BigDecimal? I tried setting it to equal(Object) but it keeps breaking?
1 week ago
Am trying to round up 2 decimal places using a method I wrote in my class.

pom.xml:




MathUtils.java:



MathUtilsTest.java:




Question(s):

* Need 0.0565 to round up to 0.57 but fails with this:



Have tried using:



RoundingMode.HALF_UP fixed the issue with the second assertion, but not with the first assertion, it fails with 0.565 turning into 0.56 instead of 0.57.

Is there a different way to achieve this precision (e.g. using BigDecimal)? How else could someone re-write the roundUp() method (e.g. is my approach using DecimalFormat bad)?

Code samples would be greatly appreicated.
1 week ago
Using Java 1.8 and JUnit 1.5, am trying to read a sample csv file for standalone sudoku app through which I try to read the CSV file through a JUnit test.

pom.xml:



Project structure:



Sudoku.java:



SudokuTest.java:



valid.csv:



When I run the JUnit file manually in IntelliJ IDEA Ultimate Edition, I get the following exception:



This is weird because when using the debugger, it iterates and does parse values - I don't see a single 0 or "" anywhere in my code?

Why does this break?

Is there a better way to rewrite this method?
1 week ago
Am working on a coding exercise which I am somewhat confused on how to implement a solution.

According to the JavaDoc, I have to implement this EmployeeManager interface. Presume that employee data arrives in a separate thread from other requests. Note that getSalary() execute in constant time O(n). Execution time must not vary with number of employees or departments.



Question(s):

1. What type of problem is this?

2. Should I create Employee and Department classes as POJOs and what would be inside? Will they have to implement runnable in order to be thread-safe?

3. What type of data structure(s) does this need?

Am really rusty with my data structures and CS stuff so would greatly appreciate any feedback.
4 years ago
Am using the latest version of Spring Boot to read in a sample JSON via Restful Web Service...

Here's my pom.xml:




Here's my web service code:

When I invoke it using the following command:


I get this error message:



The only thing I am trying to do is pass in some valid JSON (as a string via curl) and to see if the String payload enters the process method as {"name":"value"}

What am I possibly doing wrong?

Thank you for taking the time to read this...
6 years ago
Am new to JPA...

I have the following preexisting tables inside a MySQL 5 database:

App
User
User_App_Bridge

The relationship(s) are mapped to the User_App_Bridge table (as the name implies, a bridge) amongst App and User as a One to Many cardinality.

The E-R diagram:

User ------ User_App_Bridge------ App

1 User is associated with many apps inside the User_App_Bridge table.

1 App is associated with many users inside the User_App_Bridge table.

The DDL for the User_App_Bridge table:



Lets say that I have the following JPA Annotated Classes which are mapped to these tables:




Question(s):

(1) Is this (the block inside the @JoinTable) the correct way to do the one to many mapping for User and App entites with the UserAppBridge?

(2) Inside the @JoinTable should the column & referencedColumnName be assigned to the SQL value (e.g. name="User_Id" , referencedColumnName = "User_Id")
or should it be the Java reference name (e.g. name="userId" , referencedColumnName = "userId")?

(3) Inside the inverseJoinColumns code black, is the unique = true necessary (what is it for)?

(4) Do I need to do anything else inside the UserAppBridge class (for connecting to App and User)?

Thank you for taking the time to read this...
This is how the coding puzzle came... I am supposed to provide implementation in the Field's enums?
6 years ago
What Field is an enum... Am new to this and the interface predefined getField() method.
6 years ago
Lets say you have a particular enum called Field:


And you have a corresponding Java interface called Music


And you implement it like this:

Does this sound correct?


Is this a correct way to implement the sortAlbums method?
6 years ago
Lets say you have a particular enum called Field:


And another enum called:


And you have a corresponding Java interface called Music


Which the implementation looks liks this:


How would you use this API to implement the following two methods?



Any suggestions will help...
6 years ago
Am using Hibernate 3 / JPA on Java 6. Am trying to fetch a simple row from the database (which is populated).

Created the following JPA Annotated Domain Object:



My hibernate.cfg.xml file:



Code snippet from calling class:



When I run the calling class, this is the exception I get:



Line 15 where this ClassCastException occurs is here:



Here are my dependencies:



What I am I possibly doing wrong? I just want to call a simple select query against a person table.

What is the most simplest way to do a select query for one row of my Person table in Hibernate / JPA?

I am using session factory instead of entity manager.

Thank you for taking the time to read this.