[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: CheckBoxList - solution
This message is going to a personal response, and the mailing list.. The
solution I came up with is at the end.. Also, be sure to check the wod
file, if you are unfamiliar with the checkbox list.. Thanks for the ideas..
I ended up with output like this, using a table (the pipes | are table
edges..):
________________________________
| [] 111 [] 222 [] 333 [] 444 | Colorado |
|______________________|_________|
| [] 101 [] 202 [] 303 [] 404 | California |
|______________________|_________|
> Good point. I don't think it would be very difficult to do the bounds
> checking and you could just kludge the first statename by leaving it as a
> separate string and not part of the checkbox list. I know that's ugly, but
> if you're short on time it would probably work. I don't really understand
> why you need to look at the next object to get the statename. How do you
do
> it currently?
First, I did use your suggestion.. it is the code at the end of the message,
now to answer your question..
(kinda out of order, but it seems to make more sense to me..)
You use the index (it is a counter, more or less) attrib from the
checkboxlist... You set the index to a script (my case Java) variable, and
use it to access that object..
like this:
[wod]
ACCheckBoxes: WOCheckBoxList {
index = acIndex;
item = AreaCode;
list = AreaCodesDG.allObjects;
selections = selectedAreaCodes;
suffix = cbSuffix;
value = AreaCode.areaCode;
}
[java]
int acIndex; // this is actually a class var, not a method var..
but shown here for clarity
/** @TypeInfo AreaCodes */
EnterpriseObject thisAC = (EnterpriseObject)
AreaCodesDG.displayedObjects().elementAt(acIndex);
Now for the 'magic' of the stuff..
public String cbSuffix() {
// get thisState, for this Object..
/** @TypeInfo AreaCodes */
EnterpriseObject thisAC = (EnterpriseObject)
AreaCodesDG.displayedObjects().elementAt(acIndex);
String thisState = thisAC.valueForKey("state").toString();
// Setup the nextState
/** @TypeInfo AreaCodes */
EnterpriseObject nextAC;
String nextState;
// First, I make sure I am not going 'out-of-bounds'
if ((acIndex + 1) < AreaCodesDG.displayedObjects().size()) {
// I am not out-of-bounds, so set the object..
/** @TypeInfo AreaCodes */
nextAC = (EnterpriseObject)
AreaCodesDG.displayedObjects().elementAt(acIndex + 1);
nextState = nextAC.valueForKey("state").toString();
}
else {
// I will be out of bounds, so set the object(s) to null
nextAC = null;
nextState = null;
}
if (nextState == null || (!nextState.equals(thisState))) {
// If nextState is null or not equal to thisState, end the
table row
// new table row and print this state..
lineCount = 0;
if (nextState == null) return "</TD><TD>" + thisState +
"</TD></TR>";
else return ("</TD><TD>" + thisState +
"</TD></TR><TR><TD>");
}
else {
// else, wrap the area codes every 4
lineCount++;
if ((lineCount % 4) == 0) return "<BR>";
else return " ";
}
}
These opinions are mine, and not necessarily those of my employer.
James 'Ghostman' Schrecengost
Johns Manville, Electronic Commerce Team
schrecen@jm.com
303-978-2677