Operator Precedence in Java

In an an attempt to print the value of an entity; carelessness in terms of operator precedence can lead to surprising results….

Continue Reading Add comment June 17, 2008

Javascript Tip: ‘Number()’ function

Trying to do a simple number comparison, can be surprising in javascript sometimes. For example…

Continue Reading 4 comments June 11, 2008

Spring UTF-8 conversion using CharacterEncodingFilter

Having to deal with non english characters can often lead to frustation, even after specifying the UTF charset with <%@ page…

Continue Reading 1 comment June 10, 2008

NotReadablePropertyException: Invalid property ‘key’ of bean class [java.lang.Integer] …

It seems like, after the spring framework jars being used in the application were upgraded, all the form pages that made use of….

Continue Reading Add comment June 6, 2008

Not-null property references a null or transient value

Trying to run an application (using spring & hibernate) that has a parent (one) and child (many) relationship. When trying to add a parent, children maybe added at runtime and once submit is pressed both the parent and the respective children are saved.

To add the children at run time isFormChangeRequest & onFormChange methods, provided by spring, are used. And when submitting the parent form, hibernate helps to save the children automatically when the parent is saved.

After submit is pressed, the following creeps up….

org.springframework.dao.PropertyValueException: not-null property references a null or transient value:…

It seems like one of the child properties is missing, but a simple System.out.print shows that the property being complained about is NOT null !

Continue Reading 11 comments June 5, 2008

Javascript numerical data validation

Validating input, to check for a particular numeric range is pretty straight forward… but what if you want to check whether or not data is numerical. Browsing the internet, I found an effective method for numerical data validation using javascript.

Continue Reading 2 comments June 3, 2008

Aligning divs next to each other !

Context:

Since the dawn of the tableless design (css & divs), often frustration has been felt in not being able to (in the beginning at least !) place objects as desired…. in comparison to when using tables. Among the difficulties realised, has been the ability to place div elements next to each other, horizontally.

Solution :

The solution is actually much simpler than anticipated, and can be broken down in two parts :-

1) Placing the divs next to each other, and
2) trying to confine text to only it’s respective div and not overflowing into the next.

Part 1: To define a width and then to make use of the css ‘float’ property, as follows…

.div
{
   width: 50px;
   float: left;
   ...
}

Part 2: To make use of the css ‘overflow’ property. (Defining all the possible options is outside the scope of this article, please refer to a css reference such as W3 Schools.) As follows…

.div
{
   width: 50px;
   float: left;

   overflow: auto;
}

… where ‘auto’ ensures that if text is cut-off, a scroll bar can be used to view the cut-off part. Additionally, IE users could make use of ‘word-wrap’ as follows…

.div
{
   width: 50px;
   float: left;

   overflow: auto;

   /* IE only */
   word-wrap: break-word;
}

Please note the ‘.’ instead of the regular ‘#’ for the div definition. This is because, we are defining a class that may be reused by several divs. So the html element will use the above with a ‘class’ and not an ‘id’.. As follows…

<div class="div">
   first div
</div>
<div class="div">
   second div
</div>

… That’s all there is to it !

Wa Allahu A’lam.

Add comment May 30, 2008

Error reading tld listeners

Problem :

Trying to run a web application (that makes use of the log4j framework) on tomcat, during start up, it complained of the following error…

SEVERE: Error reading tld listeners java.lang.NullPointerException
java.lang.NullPointerException
at org.apache.log4j.Category.isEnabledFor(Category.java:746)
at org.apache.commons.logging.impl.Log4JLogger.isTraceEnabled(Log4JLogger.java:327)
at org.apache.catalina.startup.TldConfig.tldScanResourcePaths(TldConfig.java:581)
at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:282)
at org.apache.catalina.core.StandardContext.processTlds(StandardContext.java:4278 )
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4115)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:608 )
...

Solution 1:

Simply replace the commons-logging-1.1 jar with an older version, namely commons-loggin-1.0.4.jar.

Solution 2:

Edit the context.xml file residing under the META-INF folder (or create one if it doesn’t already exist), and turn off the tld processing as follows…

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/yourowncontextname" processTlds="false"/>

… where “yourowncontextname” is the context name your application will use to run in the browser under.

Wa’Allahu A’lam.

Add comment May 28, 2008

java.util cannot be resolved !

Context :

After upgrading my java sdk on my linux, eclipse did not seem to recognise any of the java packages anymore. At first I thought, “… yep that’s probably because eclipse doesn’t reference the latest version…”, only to be proven incorrect. After hours of trying to configure eclipse properly, I was beginning to lose hope. I had already tried….

1) to select the correct version under the ‘preferences > java > installed JREs’,

2) to select the correct compiler compliance level under ‘preferences > java > compiler’,

3) to reselect the correct server version under ’server > installed runtimes’,

… but to no avail !

Solution :

Alhumdulillah, eventually after some time the problem was resolved. Essentially, the problem was that after the java upgrade on my machine, somehow eclipse managed to ‘unbound’ a few libraries from the build path. This unbinding was undone to reactive the libraries as follows…

Step 1: Select the project properties from the ‘Project Explorer’.

Step 2: Select ‘Java Build Path > Libraries’.

Step 3: Select individually the ‘unbound’ libraries, press ‘Edit…’ and reselect (re-bind) the appropriate versions. Particularly in my case the…

i) ‘JRE System Library [...version...] > Edit… > Workspace default JRE (…version…)’, and
ii) ‘Apache Tomcat v6.0 [apache-tomcat-...version...] > Edit… > apache-tomcat-…version…‘.

… and voala. Eclipse back to normal. If you have any further comments, please let me know.

… Wa Allahu A’lam.

6 comments May 20, 2008

Prototype & JavaScript based tooltip

Standard tooltips can be created using the ‘title’ attribute of the html tags, but these are not configurable and the layout may vary depending on your browser. Also, at times, the need may arise to have more than just one line of text showing in the tooltip.

Continue Reading Add comment May 15, 2008

Next Posts Previous Posts


Recent Posts

Recent Comments

Categories

Top Posts

Links

Blog Stats

Meta