Originally I had a design problem where I needed five subclasses of a superclass, where all but two would use the same generic method of doing things and the other two classes would need special handling. I wanted to avoid writing the method five times; two special cases and three identical ones.
So I had every class inherit SuperClass,...
In a Java program, I am using a custom renderer for cells in a JTable.
On this renderer I set a tooltip, for which the content depends on the current cell.
When the values are different, the tooltip is updated, and will appear next to the mouse pointer, over the cell.
However, when the text for this tooltip is identical when changing c...
Hi,
There is a stack of activity i want to call the activity from that stack , My question is that is it possible to check from that stack and call that intent . When i press home button and again when i press the executable it should start the activity where i have left .
Is it possible ?
Any example related to the same would be ...
I use m2eclipse to import Maven Java projects in Eclipse.
It fails to recognize src/main/webapp as a source directory.
Graphically in the package explorer (or when I look into Java-Build-Path in the project's properties),
this directory isn't in the list of sources folder (while src/main/java or src/main/resources do).
To access it, I...
Where should an JDBC-compliant application store its SQL statements and why?
So far, I managed to identify these options:
Hardcoded in business objects
Embedded in SQLJ clauses
Encapsulate in separate classes e.g.
Data Access Objects
Metadata driven (decouple the object
schema from the data schema -
describe the mappings between them ...
We have a project where a 3rd party DLL is accessed through JacoZoom in a Tomcat application. Apparently the DLL leaks memory (confirmed by the vendor), but the vendor has no intention to fix this. The memory leak forces Tomcat to be restarted at regular intervals, which is naturally a great inconvenience for the users.
What would be th...
I have a Maven Java project, imported using m2eclipse.
The target/ directory is not marked as 'Derived' by m2eclipse.
Problems:
It is validated, so any validation error appear twice. My example shows a JSP Problem, when I insert intentionally an error in a jsp.
When I want to open a resource with Ctrl-Shift-R, all files appear twic...
The Java documentation says that an app can perform a query during a transaction, but only if it includes an ancestor filter, but there is no documentation for how to do it. Can anyone provide some example code that shows how to do this in the most concise way possible?
...
I have a Voucher - POJO mapped to two tables. The first mapping assigns an entity name "voucherA" and maps the POJO to TableA. The second mapping uses "voucherB" as entity name and maps the POJO to TableB.
Now i have also a customer POJO mapped to TableC. This POJO references vouchers in a list.
<list name="vouchers" table="TableC_vouc...
Wrote a quick Java proggy to spawn 10 threads with each priority and calculate pi (4*atan(1) method) with BigDecimals 500,000 times each, join on each thread and report the elapsed time for run method. Yeah, prob'ly not the best example, but keeping it basic.
I'm aware of Bug4813310
It is non-trivial to do in C, but can we assume that...
I need to store a lookup map in memory on a servlet. The map should be loaded from a file, and whenever the file is updated (which is not very often), the map should be reloaded in the same thread that is doing the lookup.
But I'm not sure how to implement this functionality in a thread safe manner. I want to make sure that the reload d...
Sample XML.
<person>
<name>Joe Dirt</name>
<ssn>123-45-6789</ssn>
<dob>07/04/1981</dob>
</person>
Sample Java Class
public class Person(){
private String name;
private String ssn;
private java.util.Date dob;
.....
}
Sample Digester rules
<?xml version="1.0"?>
<digester-rules>
<pattern value="message">
<object-c...
I persist in storage an object with a child inside it. There is an "Owned One-to-One Relationships" (http://code.google.com/appengine/docs/java/datastore/relationships.html#Owned%5FOne%5Fto%5FOne%5FRelationships). Now I want to load objects but I have ONLY id of child's object. Is it possible?
Child c = new Child("chld23", "I'm a c...
We just switched to Glassfish V2. We are now getting errors when setting a session attribute.
Error is:
java.lang.IllegalArgumentException: PWC2788: setAttribute: Non-serializable attribute
Code is:
getRequest().getSession().setAttribute("questionsForUser", getQuestions());
getQuestions() is just a simple getter which is inside a...
I've been doing quite a bit of simple XML-processing in python and grown to like the ElementTree way of doing things.
Is there something similar and as easy to use in Java? I find the DOM model a bit cumbersome and find myself writing much more code than I would like to do simple things.
Or am I asking the wrong thing?
Maybe my quest...
In one of my projects, I have an application that manages several clients (or customer if you prefer). For each of them, I have a dedicated schema on a database.
However, the application handles only one client at a time, i.e. the user must switch from one client to another in the application (at runtime, no restart of the application) i...
Hello, I've document and I want to change all template parameters like {name}, {address} to my own values. I tried to use POI HWPF Library, but I lost document formatting after saving. Even when I open my MS Word document with POI and save it (without any changes) document formatting is lost:) Formatting means centering, font size, etc (...
Hi,
We have a DB table that is mapped into a hibernate entity. So far everything goes well...
However what we want is to only map enentitys that satisty a specific criteria, like ' distinct(fieldA,fieldB) '...
Is it possible to map with hibernate and hibernate annotations? How can we do it? With @Filter?
...
Hi,
I'm getting a Null ArrayList in a program i'm developing. For testing purposes I created this really small example that still has the same problem. I already tried diferent Primary Keys, but the problem persists.
Any ideas or suggestions?
1-Employee class
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Em...
What is the best way to share common objects between multiple views in an MVC application? Say I have a LoginController that takes a user name and password and authenticates the user and loads their data (account info, full name, etc.). I want to display this on each page - something like a header with "Welcome <user name>, you have <a...