matej spac

Greenhorn
+ Follow
since Apr 21, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
5
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by matej spac

Hello,
I have a class which looks like this:

I want to add an attribute "someAttr" to "list" element to reach following xml:.

Is this possible in some way?
Hi,
by default, when maven builds multi-module project, it prints reactor summary in following format:

Is there possibility to format this output? For example to:

11 years ago
@Tim
There is definitely only 1 version of parent nad child class.

Peter Johnson wrote:Are all of these class in the same project, or are some of them in a separate project? If a separate project, are you using a SNAPSHOT version? If so, then each time you build that other project you will get a different JAR file (snapshots include a timestamp in the jar file name), and m2e has to update Eclipse to reference the correct JAR file for your project. (This is all a guess...)


These classes are in different modules, but under one project. Each module is versioned as 1.0, so they are not SNAPSHOTs. But your point seems to me very likely as possible problem.

By the way, I found another way which relatively solve this problem - removing generics:

But changing code with removing generics I don't consider as a good solution...
However, we redefined generics in parent class and also in child classes and now code works. But I don't certainly found out why this problem occured in former code and is still weird for me.
11 years ago
@Tim
eclipse output folder is set to "PROJECT_ROOT/target/classes", so this is correct i think...
running maven commands do same either they are called from command line or from eclipse

@James
I can't past complete stack trace of error, because it is commercial project, but IMHO I don't think the type of error is important. I provide you with sample code:

This code works fine at beginning. I can build it without problems. Then I call maven clean, either from terminal of from eclipse. When I try to build project after that clean, maven prints error about inconvertible types, something like this:

[ERROR] /home/pathtomyproject/project-name/src/main/java/package/MyProject.java:[140,47] inconvertible types
[ERROR] found : package.MyParent<capture#994 of ?>
[ERROR] required: package.MyChild1
[ERROR] /home/pathtomyproject/project-name/src/main/java/package/MyProject.java:[147,8] inconvertible types
[ERROR] found : package.MyParent<capture#994 of ?>
[ERROR] required: package.MyChild2

This could be fixed as I mentioned in my first post easily with eclipse: right click on project -> Maven -> Update Project Configuration. But why I have to update project configuration every time after calling clean? I don't understand...
11 years ago
Hi,
I have maven project module, which on first build works fine. But after I call 'mvn clean' and then 'mvn install', project crash on java errors (inconvertible types, etc...).
The only solution I found was in Eclipse: right click on project module -> Maven -> Update Project Configuration. After this step 'mvn install' again works fine. But only until the time, when I again call mvn clean on project.
It is multi module project and only this one module produces this problem. So the question is: does 'mvn clean' erase some of my dependencies or something what is needed?
11 years ago
Hi,
I am trying to embbed Groovy in Java app.
I know that through Binding object I can bind variables from Java app to Groovy script and use it in script. In my app I am trying to change value of Java variable with Groovy script and it works well:

My question is: is there some way to make java variables updates immediately after shell.evaluate() method calling? For example, if I would have 1000 variables i don't want call for every variable

because of one variable change in script code. Is it possible to ommit this step and update java variables with new value automatically?
12 years ago
Matrix must be read form left bottom corner to right bottom corner etc in spiral way.
I read matrix by sides and each reading reduces items in side by 2 items.

This solution works for any type of matrix, however, one senior programmer told me "it is not ideal and you use too many variables" .



12 years ago

Winston Gutkowski wrote:

matej spac wrote:Hello,
I have a problem with reading 2D array in spiral way. It must be read from bottom left corner - to bottom right corner - to top right corner etc like spiral. I try different approaches but still get in some step ArrayIndexOutOfBoundsException. Please help me complete "output" method.


Well first, I don't see a program; I see a set of definitions and an output statement - admittedly with a loop, but that's not a program in any way I understand the word.


I don´t wrote "I have a program", but "I have a problem"
However, I follow your steps and it turns out that you are genius - I found solution in 15 minutes
Thanks.
12 years ago
Hello,
I have a problem with reading 2D array in spiral way. It must be read from bottom left corner - to bottom right corner - to top right corner etc like spiral. I try different approaches but still get in some step ArrayIndexOutOfBoundsException. Please help me complete "output" method.

Input example:
10 9 8 7
11 16 15 6
12 13 14 5
1 2 3 4

Ouput example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16


12 years ago
Hi,
I am trying to build eshop application. I use container managed authentication for access to an administration interface.
I also want to give users option to registry and login. Now I am not sure how to design login process.
Could I use this type of authentication also for common users?
In this thread:
https://coderanch.com/t/448131/JSF/java/forms-authentication-security-check-JSF
I read that invoking login page for container managed authentication is not intended to be directly. It should be displayed by container before access to a protected page defined in web.xml.
So should I construct my own login process for common user login and have container managed authentication for access to admin interface?
Thanks for any answer.
12 years ago
JSF
Nice talk

I found problem:

${applicationScope.manufacturers} refers to LinkedHashMap<Long, String>
${product.manufacturer} refers to variable of type int

So ${applicationScope.manufacturers[product.manufacturer]} returns nothing.

I change type of variable ${product.manufacturer} from int to Long and now it is working
12 years ago
JSP
Actually even ${applicationScope.manufacturers[1]} did not work.
So I change map from LinkedHashMap<Integer, String> to type LinkedHashMap<Long, String>.
Now at least ${applicationScope.manufacturers[1]} works and return "Value1" as expected.

But ${applicationScope.manufacturers[product.manufacturer]} still not working
12 years ago
JSP
Hi, I can´t get value from attribute object of type LinkedHashMap.

I have got this 2 attributes:
1. LinkedHashMap<Integer, String> object saved under name "manufacturers"
2. JavaBean object saved under name "product" with some properties

I try following in my JSP:



But I want to get values from LinkedHashMap based on ${product.manufacturer} value as a key. When I try to do it with:

it is not working, nothing is returned.
Separately both attributes is returned (with all kind of syntax above), but when I combine them, something goes wrong.

What am I doing wrong?
12 years ago
JSP
Hi, I think this thread describe similar question:

https://coderanch.com/t/535172/java-programmer-SCJP/certification/Priority-Queue-Ordering

Very valuable note in this thread from Ikpefua:

1. PriorityQueue does NOT permit insertion of non-comparable objects (doing so may result in ClassCastException).
2. The Iterator provided in method iterator() is NOT guaranteed to traverse the elements of the PriorityQueue in any particular order.

If you want selecting or printing elements from PriorityQueue in order according their priority, use peek() or poll() method.
Printing PriorityQueue elements with Iterator or like in your example only using

does not guarantee ordering.