Apple WebObjects 3.5 User Manual
Page 114

Chapter 7
Managing State
114
// Java DodgeLite Application.java
public class Application extends WebApplication {
public ImmutableHashtable dodgeData;
public ImmutableVector prices;
public ImmutableVector sortBys;
public Application() {
super();
String filePath = resourceManager()
.pathForResourceNamedInFramework("DodgeData.dict", null);
if (null != filePath) {
try {
dodgeData = new ImmutableHashtable(new
java.io.FilePath(filePath));
}
catch (Exception e) {
//...
}
} else {
// ...
}
int priceValues[] = { 8000, 10000, 12000, 14000, 16000, 18000,
20000, 25000, 30000, 50000, 90000};
MutableVector a = new MutableVector();
for (int i=0; i<priceValues.length; i++) {
Number num = new Integer(priceValues[i]);
a.addElement(num);
}
prices = (ImmutableVector) a;
String sortByStrings[] = { "Price", "Type", "Model" };
for (int i=0; i<sortByStrings.length; i++) {
a.addElement(sortByStrings[i]);
}
sortBys = (ImmutableVector) a;
}
// WebScript DodgeLite Application.wos
id dodgeData;
id prices;
id sortBys;
- init {
id filePath;
[super init];
filePath = [[self resourceManager]
pathForResourceNamed:@"DodgeData.dict" inFramework:nil];
if (filePath)
dodgeData = [NSDictionary dictionaryWithContentsOfFile:filePath];
//...
prices = @(8000, 10000, 12000, 14000, 16000, 18000, 20000, 25000, 30000,
50000, 90000);
sortBys = @("Price", "Type", "Model");
return self;
}