Archive for September, 2009
Running JBoss with Oracle
by Frank Kim on Sep.28, 2009, under JBoss

(Photo: oracle by you are the atman)
Most commercial websites that use JBoss also use Oracle. To run JBoss with Oracle you simply need to tell JBoss where to find the Oracle JDBC drivers. To do this modify run.bat or run.sh and set the JBOSS_CLASSPATH to include the Oracle JDBC jar file before
set JBOSS_CLASSPATH=C:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar
I did this right before run.bat checks to see if JBOSS_CLASSPATH is empty.
rem If JBOSS_CLASSPATH or JAVAC_JAR is empty, don't include it, as this will rem result in including the local directory in the classpath, which makes rem error tracking harder. if not "%JAVAC_JAR%" == "" set RUNJAR=%JAVAC_JAR%;%RUNJAR% if "%JBOSS_CLASSPATH%" == "" set RUN_CLASSPATH=%RUNJAR% if "%RUN_CLASSPATH%" == "" set RUN_CLASSPATH=%JBOSS_CLASSPATH%;%RUNJAR%
After doing this you might need to tell your web application how to configure the data sources. I wrote a post about how to configure your data source for ATG web applications.
Microsoft Windows Vista Error 0×80070091 and Cygwin
by Frank Kim on Sep.25, 2009, under Windows
In Windows Vista I installed JBoss. When I then logged in as another user for some reason all the JBoss directories had no permissions, i.e. their permissions were 000. I ignored this and went ahead and copied one of the server directories. Then I tried to go into the copied server directory and could not.
Thinking something was funky I tried to delete the whole JBoss directory but got this maddening and uninformative window.

I googled for a long time but could not find a satisfying solution. I gave myself full control permissions for all files and folders but that did not help. Then I noticed that if I clicked on one of the directories that Windows Vista was not letting me delete I would be prompted for permission to enter this directory. Then I would repeat this process for all directories within. After doing this I could delete that directory.
I then looked in Cygwin and found out what Vista had done, it had simply given the directory read and write permission.
Therefore the simple solution was to do the following:
chmod -R 500 .
After doing that simple change I could remove everything.
Update Profile in ATG Commerce
by Frank Kim on Sep.08, 2009, under Commerce
(Photo: Wolf portrait 3 by Tambako the Jaguar)
ProfileTools provides methods for updating a profile. In ATG Commerce you can access the ProfileTools via the CommerceProfileTools.
Therefore to update a profile it is as simple as calling the update methods in ProfileTools.
getCommerceProfileTools().updateProperty(propertyName,
property, getProfile());
getCommerceProfileTools().updateProperty(propertyTable, getProfile());
The update methods get the MutableRepositoryItem for the profile, set the property in the MutableRepositoryItem and then update the item in the ProfileRepository.
Pretty simple, eh?
Using ResourceBundle and MessageFormat for Error Messages
by Frank Kim on Sep.07, 2009, under Java SE
When generating error messages, two Java utility classes, ResourceBundle and MessageFormat, are extremely practical and powerful. From the ResourceBundle JavaDoc:
Resource bundles contain locale-specific objects. When your program needs a locale-specific resource, a
Stringfor example, your program can load it from the resource bundle that is appropriate for the current user’s locale. In this way, you can write program code that is largely independent of the user’s locale isolating most, if not all, of the locale-specific information in resource bundles.This allows you to write programs that can:
- be easily localized, or translated, into different languages
- handle multiple locales at once
- be easily modified later to support even more locales
And from the MessageFormat JavaDoc:
MessageFormatprovides a means to produce concatenated messages in a language-neutral way. Use this to construct messages displayed for end users.
MessageFormattakes a set of objects, formats them, then inserts the formatted strings into the pattern at the appropriate places.
This is an example of an error message resource bundle, ErrorMessagesResources.properties.
userAlreadyExists=A user already exists with the name {0}.
passwordInvalid=Please enter a valid password.
This is an example of how you would use this resource bundle.
protected static final ResourceBundle resourceBundle =
ResourceBundle.getBundle("com.betweengo.ErrorMessageResources");
public boolean handleLogin(DynamoHttpServletRequest pReq, DynamoHttpServletResponse pRes) {
...
// user already exists
String errMsg1 = resourceBundle.getString("userAlreadyExists");
errMsg1 = MessageFormat.format(errMsg1, userName);
...
// password invalid
String errMsg2 = resourceBundle.getString("passwordInvalid");
...
}
The Strangely Behaved ATG textarea Tag
by Frank Kim on Sep.03, 2009, under Page Development
(Photo: Escalera al cielo / Stairway to heaven by Davichi)
When I create a DSP textarea tag like this it outputs the value of the bean property in the text area box.
<dsp:textarea bean="MyFormHandler.foo" rows="5" cols="20"/>
Similarly if I create a DSP textarea tag like this I get the same output.
<dsp:textarea bean="MyFormHandler.foo" rows="5" cols="20"></dsp:textarea>
However when I leave some space between the textarea opening and closing tag I get a blank instead of the value of the bean property in the text area box.
<dsp:textarea bean="MyFormHandler.foo" rows="5" cols="20"> </dsp:textarea>
Anyone know why there is a difference?
Anyway after reading the documentation it turns out if I want to control what is output in the text box I can use the default attribute.
<dsp:textarea bean="MyFormHandler.foo" rows="5" cols="20" default="bar"/>
Maybe I should have read the documentation before writing this post.
Update 2009-09-03: I also found this strange pattern of behavior with the DSP droplet tag. When I invoked a droplet that took no parameters and had no open parameters like this:
<dsp:droplet name="MyDroplet"/>
or like this:
<dsp:droplet name="MyDroplet"></dsp:droplet>
the droplet would not be invoked.
However when I did this the droplet was invoked. Strange …
<dsp:droplet name="MyDroplet"> </dsp:droplet>
Enums in Java
by Frank Kim on Sep.02, 2009, under Java SE

(Photo: Slide-together : now with cards by fdecomite)
Enums are highly useful data types introduced in Java SE 5.0. Though I love using them I often forget the exact syntax so this post is to remind me later how to use it.
public enum Example {
FOO,BAR
}
// create one using its name
Example myExample = Example.valueOf(“bar”.toUpperCase());
// if statement
if (myExample == Example.FOO) System.out.println(“FOO!”);
// switch statement
switch (myExample) {
case FOO: System.out.println(“FOO!”);
case BAR: System.out.println(“BAR!”);
}
// output as String using name
System.out.println(myExample.name());
For further reading please see Java’s Enums guide and Enum Types (The Java™ Tutorials > Learning the Java Language > Classes and Objects).
betweenGo Consults with Cineplex to Release Latest Version of Online Store on ATG
by Frank Kim on Sep.01, 2009, under Consulting
On Monday, August 30 Cineplex launched the latest version of its store running on ATG 2007.1 and JBoss 4.0.5.GA.
betweenGo with Bell Canada was proud to be part of this release. betweenGo implemented the handling of gift cards and product bundles and other eCommerce features.
Specific features we implemented for gift cards and product bundles included:
- product listing
- search listing
- display in cart and throughout checkout
- handling of taxes and shipping costs
- promotions
- inventory status
- adding gift cards to the cart (required some JavaScript magic
Other features we implemented included:
- lightbox to display after login if user’s cart has been modified to include items from their last session
- fixed order transaction issues
betweenGo was proud to be part of this enjoyable project. If you need expert ATG consulting please contact us.
