James Dekker

Ranch Hand
+ Follow
since Dec 09, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
1
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

Thanks for the quick responses Ritchie and Stephan!

Just edited my original post to help describe my problem based on your answers.

The JSONObject contains the entire JSON above (staring with "products") how do I get "productTypes" and other values such as "storeId"?
8 months ago
Am facing impediments when using Java 1.8 and the org.json lib to marshal & parse a complex JSON object...

JSON dependency:




JSON response payload:





This productsJsonObject contains the entire JSON above am having trouble getting the subsection which starts with the  "productTypes" JSON key.

However, when I try to obtain the next section:



This exception is thrown:



Am not trying to marshal this to a Java class, I am trying to get it from JSONObject (which contains the whole JSON starting with "products").
8 months ago
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?
2 years ago
JSF
Thanks Ritchie,

This works now:

2 years ago
Carey,

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



yields:



Even tried this:



same issue:



What am I possibly doing wrong?
2 years 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?
2 years 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.
2 years 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?
2 years 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.
7 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...
8 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?
9 years ago
What Field is an enum... Am new to this and the interface predefined getField() method.
9 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?
9 years ago