diff --git a/Frameworks/D2W/ERModernDirectToWeb/Components/Nonlocalized.lproj/ERMDInspectPageRepetition.wo/ERMDInspectPageRepetition.html b/Frameworks/D2W/ERModernDirectToWeb/Components/Nonlocalized.lproj/ERMDInspectPageRepetition.wo/ERMDInspectPageRepetition.html index 2239b5ad3e3..fa8371af9ea 100644 --- a/Frameworks/D2W/ERModernDirectToWeb/Components/Nonlocalized.lproj/ERMDInspectPageRepetition.wo/ERMDInspectPageRepetition.html +++ b/Frameworks/D2W/ERModernDirectToWeb/Components/Nonlocalized.lproj/ERMDInspectPageRepetition.wo/ERMDInspectPageRepetition.html @@ -7,20 +7,26 @@

- - + +
-   +   - + + + + + + -
+
+
diff --git a/Frameworks/D2W/ERModernDirectToWeb/Components/Nonlocalized.lproj/ERMDInspectPageRepetition.wo/ERMDInspectPageRepetition.wod b/Frameworks/D2W/ERModernDirectToWeb/Components/Nonlocalized.lproj/ERMDInspectPageRepetition.wo/ERMDInspectPageRepetition.wod index e7f2e94bcdb..ceb099b5b24 100644 --- a/Frameworks/D2W/ERModernDirectToWeb/Components/Nonlocalized.lproj/ERMDInspectPageRepetition.wo/ERMDInspectPageRepetition.wod +++ b/Frameworks/D2W/ERModernDirectToWeb/Components/Nonlocalized.lproj/ERMDInspectPageRepetition.wo/ERMDInspectPageRepetition.wod @@ -15,15 +15,18 @@ IsNotOmitted : WOConditional { negate = true; } + AttributeValue: WOSwitchComponent { WOComponentName = d2wContext.componentName; localContext = d2wContext; object = object; } -LineDiv : WOGenericContainer { - elementName = "div"; +LineDiv : WOSwitchComponent { + WOComponentName = lineDivComponentName; + id = lineDivId; class = lineDivClass; + elementName = "div"; } EmptyLabelSpan : WOGenericContainer { @@ -63,6 +66,20 @@ SafeWrapper : D2WEmptyWrapper { } +shouldObserve : WOConditional { + condition = shouldObserve; +} + +shouldNotObserve : WOConditional { + condition = shouldObserve; + negate = true; +} + +AjaxObserveField: AjaxObserveField { + action = postChangeNotification; + updateContainerID = d2wContext.ajaxNotificationCenterID; +} + Section: WOSwitchComponent { WOComponentName = d2wContext.sectionComponentName; d2wContext = d2wContext; diff --git a/Frameworks/D2W/ERModernDirectToWeb/Sources/er/modern/directtoweb/components/repetitions/ERMDInspectPageRepetition.java b/Frameworks/D2W/ERModernDirectToWeb/Sources/er/modern/directtoweb/components/repetitions/ERMDInspectPageRepetition.java index 576403781f4..ace8e4a862d 100644 --- a/Frameworks/D2W/ERModernDirectToWeb/Sources/er/modern/directtoweb/components/repetitions/ERMDInspectPageRepetition.java +++ b/Frameworks/D2W/ERModernDirectToWeb/Sources/er/modern/directtoweb/components/repetitions/ERMDInspectPageRepetition.java @@ -1,10 +1,15 @@ package er.modern.directtoweb.components.repetitions; import com.webobjects.appserver.WOContext; +import com.webobjects.appserver._private.WOGenericContainer; import com.webobjects.foundation.NSArray; +import com.webobjects.foundation.NSNotificationCenter; +import er.ajax.AjaxUpdateContainer; import er.directtoweb.components.repetitions.ERDInspectPageRepetition; import er.extensions.foundation.ERXStringUtilities; +import er.extensions.foundation.ERXValueUtilities; +import er.modern.directtoweb.components.ERMDAjaxNotificationCenter; /** * Modern tableless inspect/edit page repetition @@ -25,7 +30,9 @@ */ public class ERMDInspectPageRepetition extends ERDInspectPageRepetition { - public int index; + private static final long serialVersionUID = 1L; + + public int index; public ERMDInspectPageRepetition(WOContext context) { super(context); @@ -67,10 +74,10 @@ public String lineDivClass() { // ERRORS // public boolean hasNoErrors() { - if(false) { - String keyPath = "errorMessages." + displayNameForProperty(); - return d2wContext().valueForKeyPath(keyPath) == null; - } + // if(false) { + // String keyPath = "errorMessages." + displayNameForProperty(); + // return d2wContext().valueForKeyPath(keyPath) == null; + // } return !validationExceptionOccurredForPropertyKey(); } @@ -88,10 +95,56 @@ public boolean validationExceptionOccurredForPropertyKey() { } } - @SuppressWarnings("unchecked") - public NSArray keyPathsWithValidationExceptions() { + @SuppressWarnings({ "unchecked", "rawtypes" }) + public NSArray keyPathsWithValidationExceptions() { NSArray exceptions = (NSArray)d2wContext().valueForKey("keyPathsWithValidationExceptions"); return exceptions != null ? exceptions : NSArray.EmptyArray; } + + // AJAX notification center support + + public boolean isDependent() { + return ERXValueUtilities.booleanValueWithDefault( + d2wContext().valueForKey("isDependent"), false); + } + public boolean shouldObserve() { + return ERXValueUtilities.booleanValueWithDefault( + d2wContext().valueForKey("shouldObserve"), false); + } + + public String lineDivId() { + String lineDivId = null; + // only needed if this is a dependent property + if (isDependent()) { + String pageConfiguration = (String) d2wContext().valueForKey( + "pageConfiguration"); + lineDivId = pageConfiguration + + ERXStringUtilities.capitalize(propertyKey()).replaceAll("\\.", "_") + + "LineUC"; + } + return lineDivId; + } + + /** + * If the current property key is depending on an observed property key, we + * surround it with an update container. + * + * @return the component name to use as the line div + */ + public String lineDivComponentName() { + String lineDivComponentName = WOGenericContainer.class.getSimpleName(); + if (isDependent()) { + lineDivComponentName = AjaxUpdateContainer.class.getSimpleName(); + } + return lineDivComponentName; + } + + /** + * Posts a change notification when an observed property key has changed. + */ + public void postChangeNotification() { + NSNotificationCenter.defaultCenter().postNotification( + ERMDAjaxNotificationCenter.PropertyChangedNotification, d2wContext()); + } } \ No newline at end of file