* @param context the current context
* @return a dictionary of D2W-related keys to describe the D2W state of the context.
*/
public static synchronized NSMutableDictionary informationForContext(WOContext context) {
NSMutableDictionary info = new NSMutableDictionary();
D2WContext d2wContext = null;
NSArray componentStack = ERXWOContext._componentPath(context);
// Try to get the information for the D2WPage closest to the end of the component stack, i.e., more specific
// info., that is especially helpful for finding problems in embedded page configurations.
WOComponent component = null;
for (Enumeration componentsEnum = componentStack.reverseObjectEnumerator(); componentsEnum.hasMoreElements();) {
WOComponent c = (WOComponent)componentsEnum.nextElement();
if (c instanceof D2WPage) {
component = c;
break;
}
}
if (null == component) { // Fall back to the highest level page.
component = context.page();
}
try {
d2wContext = (D2WContext)component.valueForKey("d2wContext");
} catch (NSKeyValueCoding.UnknownKeyException uke) {
if (log.isInfoEnabled()) {
log.info("Could not retrieve D2WContext from component context; it is probably not a D2W component.");
}
}
if (d2wContext != null) {
NSMutableDictionary d2wInfo = informationForD2WContext(d2wContext);
if (component instanceof ERD2WPage) {
ERD2WPage currentPage = (ERD2WPage)component;
String subTask = (String)d2wContext.valueForKey("subTask");
if ("tab".equals(subTask) || "wizard".equals("subTask")) {
NSArray sections = currentPage.sectionsForCurrentTab();
d2wInfo.setObjectForKey(sections != null ? sections : "null", "D2W-SectionsContentsForCurrentTab");
d2wInfo.removeObjectForKey("D2W-TabSectionsContents");
}