Rebecca Searls' Blog
Importing resource files with resImport in openinstaller
I've been playing with openinstaller because I am considering using it in a project. I have been proto-typing several application specific screens. I want to keep my screen's text separate and localizeable from openinstaller's. The view file schema, policytemplate.xsd provides element resImport for this purpose. It enables the importing of resource files into the view. In openinstaller 0.9.4, resImport is not supported. The element is parsed but ignored. Fortunately openinstaller is an open source project and I could access the source code. I found the way to enable this element with a simple code fix. Two files, CLIWizard and GUIWizard need the follow code addition in method flipGroup. In reviewing the code I also found there are some rules you must follow when specifying the path and file name in the element attribute.
Simple Code Fix
//- this is the existing code
if (null == gAPOCTemplate) {
throw new EnhancedException("APOC_TEMPLATE_NULL", "page=" + thePageName);
}
//- Adding this if-clause to enable sresource file processing
else {
//- process user provided .prefs files for I18n substitution
List<APOCResImport> gAPOCResImportList = gAPOCTemplate.getResImports ();
for (APOCResImport gAPOCResImport: gAPOCResImportList){
TemplateProcessor.getInstance().loadModelFromResource(gAPOCResImport.getPackagePath());
}
}
Path and file naming rules
Here is the DTD definition for resImport
<!ELEMENT resImport EMPTY>
<!ATTLIST resImport
apt:packagePath NMTOKEN #REQUIRED
>
example:
<apt:resImport apt:packagePath="/templates/LocalStrings"/>
<apt:resImport apt:packagePath="iHome/resources/MyInstallHome"/>
- The file must reside in your metadata directory. It can be in a subdirectory of this directory.
- Give the full pathname from the metadata root directory to the property file.
- The pathname may start with a '/' slash but it is not required.
- The file must use the extension .prefs.
- The file extension must not be specified in packagePath. Openinstaller appends
the extension to the filename.
Directory structure for example above
/prjA/pDemo/metadata/template/LocalStrings.perfs
/prjA/pDemo/metadata/template/ui.perfs
/prjA/pDemo/metadata/iHome/resources/MyInstallHome.perfs
/prjA/pDemo/metadata/view
/prjA/pDemo/metadata/model
/prjA/pDemo/metadata/dependency/index.xml
/prjA/pDemo/metadata/pagesequence.xml
/prjA/pDemo/metadata/pagesequence.properties
Posted at 04:13PM Mar 05, 2009 by rsearls in Sun | Comments[0]
Thursday Mar 05, 2009