java

How do i get custom post-processing after binding to a backing bean ? Java Server Faces

Hi, What the best way to get custom post-processing after binding to a backing bean, similar to onBind event when using a Spring MVC controller ? I suppose i need a PhaseListener (after phase Update Model Values) as follows new PhaseListener() { public void beforePhase(PhaseEvent event) {} public void afterPhase(PhaseEvent e...

Possible to inject same stateful session bean instance into multiple other session beans?

Is it possible to make the container inject the same stateful session bean instance into multiple other stateful session beans? Given the following classes: @Stateful public class StatefulTwoBean implements StatefulTwo { @EJB private StatefulOne statefulOne; } @Stateful public class StatefulThreeBean implements StatefulThree...

Null Pointer Error Again

So I have this compiler class that compiles some .mjava files but others it fails on and wondering if anyone can help me figure out why. I have two methods that break for two different files. The first consts.mjava file I try to compile is: // demo of true local and global variables int glob0; int glob1; final int two = 2; final int th...

Is it possible to use JAXB to map from schema to a java.util.Map?

I have an existing XML schema that contains a type that I would like to map to a Java Map of some sort using JAXB. My build process takes the schema and creates the beans. I would like to customize this process by having one of the complexTypes in my schema map to a java.util.Map. I've read somewhere that JAXB "can't do interfaces." I'm ...

How to start/stop/restart a thread in Java?

I am having a real hard time finding a way to start, stop, and restart a thread in Java. Specifically, I have a class Task (currently implements Runnable) in a file Task.java. My main application needs to be able to START this task on a thread, STOP (kill) the thread when it needs to, and sometimes KILL & RESTART the thread ... My firs...

Java Sound API - Distinguish multiple equal USB sound cards

I'm using 4 USB sound cards (ASUS Xonar U1). I want to send to each one of them a different sound (the same text narrated in different languages). For now, what I do to get the sound mixers that I'm interested in, is something like this: Info[] mixerInfo = AudioSystem.getMixerInfo(); int count = 0; for (Info i : mixerInfo) { System....

Questions about Java's String pool

Consider this code: String first = "abc"; String second = new String ("abc"); When using the new keyword, Java will create the abc String again right? Will this be stored on the regular heap or the String pool? How many Strings will end in the String pool? ...

Suppressing Swing Visibility

Hello, I've been given a bunch of messy code and a short time limit (no surprises there) to write some tests for it. I have written tests! They are good tests. Unfortunately, instantiating some of the project's components causes Swing GUI elements to be constructed and set visible too. I don't want this to happen for obvious reasons, s...

what is the use of Long.reverse(long ) method?

I found one method in Long class public static long reverse(long i) {..} What is the use of this method? ...

JSP template implementation (Composite View Pattern)

What is the best way to implement the Composite View Pattern for a Java website? My idea was to take one jsp and include multiple pages like: <h1>Layout Start</h1> <% Values values = DataHandler.getValues(request); LayoutHelper layout = values.getLayout(); out.println("Layout.getContent(): " + layout.getContent()); %> <jsp:include pag...

Java Swing: change background color on mouse over

Hi, I've implemented a simple mouse listener where the background color changes whenever the mouse enters the component (a JPanel), and it reverts back whenever the mouse leaves. This has some problems: Sometimes the mouse moves so quick that the mouseExit event is not fired If my component has childs, when the mouse moves to the chil...

Model generation for manually entered page in Spring framework

I have to extend some Spring web application, but I'm not very familiar with the framework (however, I have some experience with few other frameworks). I can see that there is "ModelAndView" concept used by the framework. Controller returns both: a model and a view from onSubmit() method. But what to do if a model have to be generated fo...

Using MatrixCursor and SimpleCursorAdapter in a ListView with Text and Images

I'm new to Android development and running into an issue with using a MatrixCursor to populate my ListView. private void fillData() { String[] menuCols = new String[] { "icon", "item", "price" }; int[] to = new int[] { R.id.icon, R.id.item, R.id.price }; MatrixCursor menuCursor = new MatrixCursor(menuCols); startManagin...

How do I get Maven 2 to build 2 separate WAR files

when doing a mvn install I want to end up with 2 WAR files in my target dir. One will contain the production web.xml and one will contain the test/uat web.xml. I've tried this: <build> <finalName>cas-server</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> ...

"org.apache.axis2.AxisFault: unknown" when calling web service with Java

Hi, I'm trying to call a web service with a Java client. The WSDL looks like this: http://pastebin.com/m13124ba My client: public class Client{ public static void main(java.lang.String args[]){ try{ CompileAndExecuteServiceInterfaceStub stub = new CompileAndExecuteServiceInterfaceStub ...

Is there a convenient way to use a spinner as an editor in a Swing JTable?

I deal with numeric data that is often edited up or down by 0.01*Value_of_variable, so a spinner looks like a good choice compared to a usual text cell. I've looked at DefaultCellEditor but it will only take text fields, combo boxes or check boxes. Is there a convenient way to use a spinner? ...

Using javascript APIs in Java.

I am writing a standalone application in Java that needs to be able to call custom Javascript APIs? Is there a way to call custom Javascript APIs in Java? ...

Why does repaint(long) repaint immediately?

According to the Javadoc, JComponent.repaint(long) is supposed to schedule a repaint() sometime in the future. When I try using it it always triggers an immediate repaint. What am I doing wrong? import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.ActionEvent;...

What is a covariant return type?

What is a covariant return type in Java? In object-oriented programming in general? I know, it's a "just Google it"; I did, and found the answer, but I'm asking anyways because of SO's goal to be the #1 Google result for programming questions. ...

Rapid Java UI tools for backend server testing

We have a Java server application using a message based communication passing around strongly typed complex POJO messages. Our regular client is a rich-client Flex application that has a very heavy art and UI development process that doesn't lend itself to rapid prototyping. We are planning on building a Java UI to test server functiona...