I tried to put GWT in an existing project and after my first try to make a gwt compile, I got the following exception:


java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding.closestReferenceMatch()Lorg/eclipse/jdt/internal/compiler/lookup/ReferenceBinding;


The problem exist, because the existing libraries in my project had an conflict with the gwt libraries. Putting the gwt libraries in a higher position in the build path fixes the problem.

Wednesday, July 15, 2009

Loading beans in spring...

We developed an e-shop (a front end and a back end) as an eclipse project. The front end produces its own war and the back end a different one. Both web applications uses the same API and have differences in the GUI. A major difference is that the back end uses scheduling (quartz) and the front end not. The API is configured with spring.

We decided to configure quartz with spring and the job we needed to run with it. The result was, that the front end, using the same configuration as the back end, initialized the quartz framework and enabled its own scheduling. But that was not what we wanted to do.

The solution was simple. At the definition of a spring bean in the configuration there is an attribute in the bean tag named lazy-init. The default value for this attribute is false, and this means that the container will create a bean of that kind at the initialization process. If you give the value true, then the bean will be created only at the time when you request it.













So, the scheduler initializes in the back end, because we want it to do so, and in the front end it stays only as a bean in the spring configuration.

Wednesday, July 1, 2009

The ol/li problem

I was setting up a web site with joomla and at last the time for the data input has come. Evething seemed to work well. I checked evething in Safari, Firefox and IE8 but in IE7 there was a problem. The first number (1) of an ol/li list has gone.

Trying to solve the problem I isolated the code with the problem in a html and a css file.

In Firefox 3 the result looks lite this:
In Safari 4 it looks like this:

The html page code is this:






Here is the title



tool1

tool2







and the css code:

body {

}

.page {
width: 100%;
height: 500px;
}

.content {
width: 300px;
}

.toolbar {
background: #ECECEC none repeat scroll 0 0;
border-top: 1px solid #DDDDDD;
clear: both;
display: block;
float: left;
margin-bottom: 15px;
width: 100%;
}

.leftToolbar {
float: left;
padding: 5px;
width: 80%;
}

.rightToolbar {
float: right;
width: 15%;
}

.menu {

}


I could not find a solution but luckily I found a work around. The problem occurs because the first element of the list doesn't have enough space to show up in the right position. Making the content boarder (try resizing the browser, or try resizing the content with firebug) solves the problem. Not a nice solution be an acceptable workaround.

In the old days I used to work with flash and it was always a problem to send data to the flash from the HTML level. As it looks it is really simple now to do exactly this: simple calling a java script method described in this tutorial from adobe. In this tutorial you can learn how to send and receive a string from (and to) a text field in flash to (and from) a HTML form using java script function calls.

Wednesday, June 17, 2009

Testing with app engine in Java

I wanted to make a template for my tests in a web app using spring and google app engine. The test uses of course JUnit and annotations. Here is the result:


@ContextConfiguration(locations = {"classpath:test-config.xml"})
@RunWith(SpringJUnit4ClassRunner.class)
public class TheTest {

@Before
public void setUp() throws Exception {
ApiProxy.setEnvironmentForCurrentThread(new TestEnvironment());
ApiProxy.setDelegate(new ApiProxyLocalImpl(new File(".")) {
});
}

@After
public void tearDown() throws Exception {
ApiProxy.setDelegate(null);
ApiProxy.setEnvironmentForCurrentThread(null);
}

@Autowired
private ToBeTestedRepository toBeTestedRepository ;

@Test
public void testLottoFileReader() {
// Do some tests here using the toBeTestedRepository
}

public void setToBeTestedRepository (ToBeTestedRepository toBeTestedRepository ){
return this.toBeTestedRepository = toBeTestedRepository;
}

public ToBeTestedRepository getToBeTestedRepository () {
return toBeTestedRepository;
}

The methods setUp() and tearDown() tell the datastore that we are using it localy.