java

JSF Navigation Rules with Relative Paths

Say I am on a page at www.foo.com/foo/bar/page.jsf and want to define a navigation rule to go to www.foo.com/foo/ how would I define the <to-view-id> of the navigation rule. I thought it would be something like this: <navigation-case> <from-outcome>goToFoo</from-outcome> <to-view-id>/../</to-view-id> </navigation-case> but...

Killing this NumberFormatException

I'm getting a NumberFormatException on the Integer.parseInt() method. I know this exception is produced when something like "ab" is passed to the method, but I'm at a loss finding where this is happening. How can I fix this? I'm using Netbeans and trying to debug putting a watch on the caseStartLineSplitted[0] variable and then hitting...

What does AtomicReference.compareAndSet() use for determination?

Say you have the following class public class AccessStatistics { private final int noPages, noErrors; public AccessStatistics(int noPages, int noErrors) { this.noPages = noPages; this.noErrors = noErrors; } public int getNoPages() { return noPages; } public int getNoErrors() { return noErrors; } } and you execute the...

Idiom for achievieng imperative wiring in a declarative Spring xml config?

I am a user of class A, which is provided to me as a library. In my spring config I specify an A bean, which Spring happily instantiates for me. As a side effect, A creates its own instance of B, which it exposes via A.getB(). B exposes a setC() method that I wish to invoke with a C that I configure in spring. How do I do this? I'...

Java ResultSet hasNext()

I've got a class that implements Iterator with a ResultSet as a data member. Essentially the class looks like this: public class A implements Iterator{ private ResultSet entities; ... public Object next(){ entities.next(); return new Entity(entities.getString...etc....) } public boolean hasNext(){ ...

In Maven2, what's the simplest way to build a WAR and the EAR to contain that WAR in a single POM?

Situation is pretty straightforward. I have a Java webapp that I'm converting to be built with Maven. At present, the app is built with Ant into a single WAR file, which is then bundled into an EAR with a very simple application.xml. maven-war-plugin and maven-ear-plugin both look pretty straightforward to me, and it appears they're set...

How to programmaticaly extract and manipulate images from an Office file ?

I need to extract some images from PowerPoint and Word documents, in order to manipulate them, and after that, put the images back in the MS Office files. Do you know any Java or C++ library that does this? It is better if it's open-source. ...

How to paint a gridline as a background on JPanel

Hi everyone, I have a problem. I used Gridbaglayout in my JFrame. One of the component is JPanel. I wanted to draw a gridline as a background for my JPanel. e.g in the program below, it supposed to produce 3 vertical and 3 horizontal lines, however it only shows 2 vertical and 2 horizontal line. the last line was not shown. Another pro...

Modelling a Finite Deterministic Automaton via this data *Edit with new code*

I have this input file: 2 3 2 1 ab 1 0 2 0 2 0 2 0 3 abaa aab aba 3 3 2 ade 0 1 2 1 2 0 2 1 0 1 2 2 2 a de The first line represents the number of test cases. Each test case starts with 3 integers, the first is the number of state for the automaton, next is the number of symbols in the alphabet and then the number of final states. ...

How to use PORT command while writing an FTP client with JAVA

I am trying to write an FTP client using java. As far as I understand I need to send my IP adress with PORT command when I need to establish an active connection but, How do I get that IP address? I am trying to do something like this but it is obviously wrong: ServerSocket ssock = new ServerSocket(); ssock.bind(null); ssock.ssock.get...

Hibernate session problem for transactions.

Hi all, I am new to hibernate and trying integrate hibernate with an existing spring based application. I configured session factory and transaction manager, transaction proxy template. I am also using Quartz scheduler in this application. When I run the application, I am getting the following exception. ERROR au.com.michaelpage.cts...

Java JTextArea - Adding a newline

So I'm stumped. I, for some reason, seem to remember that Java does weird things when you try to add new lines to stuff... so I think that may be the problem here. This code is not working how you'd expect it to: public void displayText(KeyEvent k){ txt = inputArea.getText(); outputArea.setText(txt); if(k.getKeyCode() == 1...

Switching from Java to .NET from a career change point of view

Could anyone share with me their experience with switching from Java to .NET from a career point of view? I've been a Java developer for 12 years and am just getting tired of how fragmented the Java world has become. For my liking, there's just too many frameworks, tools, application servers, etc.. And it seems each new tool just add...

Hibernate: Query without SQL-strings?

Hello everyone! Is it possible (and if yes, is it advisable) to do queries of Hibernate-mapped data without using SQL-strings, but some OOP way instead? ...

Restart a career for ex-C programmer

I'm trying to re-enter the job market after a loong break - 15 years. My last full time job was programming in C with Sybase SQL backend for a corporation. Recently, I did a few websites. You know, HTML, CSS, PHP, etc. But I feel JAVA is more closely related to what I did, plus I don't really like web development - web technologies chang...

Why is Set marked by the compiler as "not a known variable in this context"?

This is my code; import java.util.*; class State extends HashMap<Character, State>{ boolean isFinal; State () { isFinal = false; } } class Automaton{ private Set<State> allStates; private Set<State> finalStates; private State initialState; private State currentSt...

GWT using domain models /services from external module (jar) ?

Greetings, We have been using our reusable "user-management" module which was written using Spring/Hibernate(using Doman-Model Pattern).We have used that module in several project integrating with Wicket,JSP and ZK frameworks. Now I am going to develop an application using GWT.I am completely new to GWT and I noticed that the domain obj...

Problem with StrutsSpringTestCase and rest-plugin

I'm able to run tests against my rest-plugin classes with StrutsSpringTestCase, but none of the parameters are set on the action. For e.g.: @Test public void testAgegateParams() throws Exception { request.setParameter("year", "2000"); request.setParameter("month", "01"); request.setParameter("day", "1"); ActionProxy pr...

Self updating Java PriorityQueue

I'm trying to use a PriorityQueue to order objects using a Comparator. This can be achieved easily, but the objects class variables (with which the comparator calculates priority) may change after the initial insertion. Most people have suggested the simple solution of removing the object, updating the values and reinserting it again, a...

Java: MalformedByteSequenceException (XML)

I'm trying to parse XML using this class. When I type out a simple file, it works fine. <testData> <text> odp </text> </testData> Here is my main public static void main(String[] args) { Xml train = new Xml(args[0], "trainingData"); Xml test = new Xml(args[1], "testData"); } However, when I use the file I got by cop...