private static Control GetParentEditRecord(IParentEditRecordProp control)
        {
            string parentEditRecord = control.ParentEditRecord;

            if (parentEditRecord.IsEmpty())
            {
                return(GetParentValidationWidget(control));
            }

            // if the control is inside a block, check if it is using the special "declared in page"
            // edit record

            Control ownerControl;

            if (control is OSUserControl)
            {
                ownerControl = Utils.GetOwnerOfControl(control.Parent);
            }
            else
            {
                ownerControl = Utils.GetOwnerOfControl((Control)control);
            }
            OSUserControl block = ownerControl as OSUserControl;

            if (block != null && parentEditRecord == RuntimePlatformUtils.EditRecordDefinedInParentScreen)
            {
                return(GetParentEditRecord(block));
            }


            return(ownerControl.FindControl(parentEditRecord));
        }
        public static void VisitComponent(JavaScriptManager scriptManager, IParentEditRecordProp component,
                                          bool componentIsVisible, Func <string> componentClientID)
        {
            if (component != null)
            {
                string parentEditRecordId = component.GetParentEditRecordClientId();

                // #99202 - its safe to add the input controls to this list even if they are not rendered,
                // since the OSPage_Validators variable controls the validation and is not including
                // the invisible validators. This simplifies the case when an invisible input appears
                // in the page via an Ajax refresh.
                // However for buttons with validation we must skip the invisible ones, otherwise the
                // startup scripts to set the "elementsToValidate" attribute will fail since the element does not exist.
                // When hidden buttons appear in the page via Ajax refresh their elementsToValidate are updated automatically
                // (refer to "private void AddJavascriptIfNeeded()" in "Button.cs")
                if ((parentEditRecordId != null) && (parentEditRecordId != ""))
                {
                    switch (component.ValidatorType)
                    {
                    case ParentEditRecordPropType.AGGREGATOR:
                        break;

                    case ParentEditRecordPropType.NEEDS_VALIDATION:
                        scriptManager.addIdToParentEditRecord(componentClientID(), parentEditRecordId);
                        break;

                    case ParentEditRecordPropType.PERFORMS_VALIDATION:
                        // Only add the control to the script if it was rendered (it was visible) - #38772
                        scriptManager.addValidatorToParentEditRecord(componentClientID(), parentEditRecordId, componentIsVisible);
                        break;
                    }
                }
            }
        }
        public static string GetParentEditRecordClientId(this IParentEditRecordProp component)
        {
            Control parentEditRecord = GetParentEditRecord(component);

            if (parentEditRecord == null)
            {
                return(String.Empty);
            }
            else
            {
                return(parentEditRecord.ClientID);
            }
        }
        private static Control GetParentValidationWidget(IParentEditRecordProp control)
        {
            var widget = control.Parent;

            while (widget != null)
            {
                var widgetWithBehaviors = widget as IWidgetWithBehaviors;
                if (widgetWithBehaviors != null && widgetWithBehaviors.BehavesAs <OutSystems.WidgetsRuntimeAPI.IControlWithValidation>())
                {
                    break;
                }
                widget = widget.Parent;
            }
            return(widget);
        }
        public static Control GetValidationParentWidget(this IParentEditRecordProp control)
        {
            var widget = control.Parent;

            while (widget != null)
            {
                var widgetWithBehaviors = widget as IWidgetWithBehaviors;
                if (widgetWithBehaviors != null &&
                    widgetWithBehaviors.BehavesAs <OutSystems.HubEdition.RuntimePlatform.IValidationParent>())
                {
                    break;
                }
                widget = widget.Parent;
            }
            return(widget);
        }
Example #6
0
 private static bool ProceedWithValidation(IParentEditRecordProp widget, string parentEditRecord)
 {
     return(String.IsNullOrEmpty(parentEditRecord) || (widget.GetParentEditRecordClientId() == parentEditRecord));
 }