Esempio n. 1
0
        /// <summary>
        /// Finds the next <see cref="IWebNavigator"/> up  the control hierarchy,
        /// starting at the specified <paramref name="control"/>.
        /// </summary>
        /// <remarks>
        /// This method checks both, for controls implementing <see cref="IWebNavigator"/> or <see cref="IWebNavigable"/>. In addition
        /// when MasterPages are used, it interprets the control hierarchy as control-&gt;page-&gt;masterpage. (<see cref="WebUtils.GetLogicalParent"/>).
        /// </remarks>
        /// <param name="control">the control to start the search with.</param>
        /// <param name="includeSelf">include checking the control itself or start search with its parent.</param>
        /// <param name="restrictToValidNavigatorsOnly">requires <see cref="IWebNavigable"/>s to hold a valid <see cref="IWebNavigable.WebNavigator"/> instance.</param>
        /// <returns>If found, the next <see cref="IWebNavigator"/> or <see cref="IWebNavigable"/>.
        /// <c>null</c> otherwise</returns>
        protected static NavigableControlInfo FindNavigableParent(Control control, bool includeSelf, bool restrictToValidNavigatorsOnly)
        {
            while (control != null)
            {
                if (!includeSelf)
                {
                    // Get next parent in hierarchy
                    control = WebUtils.GetLogicalParent(control);
                }
                includeSelf = false;

                if (control is IWebNavigable || control is IWebNavigator)
                {
                    NavigableControlInfo nci = new NavigableControlInfo(control);
                    if (!restrictToValidNavigatorsOnly)
                    {
                        return(nci);
                    }
                    if (nci.WebNavigator != null)
                    {
                        return(nci);
                    }
                }
            }
            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns a redirect url string that points to the
        /// <see cref="Spring.Web.Support.Result.TargetPage"/> defined by this
        /// result evaluated using this Page for expression
        /// </summary>
        /// <param name="destination">Name of the result.</param>
        /// <param name="sender">the instance that issued this request</param>
        /// <param name="context">The context to use for evaluating the SpEL expression in the Result</param>
        /// <returns>A redirect url string.</returns>
        public override string GetResultUri(string destination, object sender, object context)
        {
            if (this.CheckCanNavigate(destination, false))
            {
                return(base.GetResultUri(destination, sender, context));
            }

            NavigableControlInfo nci = FindNavigableParent(this._owner, false, true);

            if (nci != null)
            {
                // when delegating upwards, the control containing the matching result
                // will appear as sender - this makes dealing with expressions more "natural".
                return(nci.WebNavigator.GetResultUri(destination, nci.Control, context));
            }

            return(HandleUnknownDestination(destination, sender, context));
        }
Esempio n. 3
0
        /// <summary>
        /// Check, whether this navigator can navigate to the specified <paramref name="destination"/>.
        /// </summary>
        /// <param name="destination">the destination name to check.</param>
        /// <param name="includeControlHierarchy">
        /// whether the check shall include the <see cref="Owner"/> control hierarchy or
        /// the standard <see cref="IHierarchicalWebNavigator.ParentNavigator"/> hierarchy only.
        /// </param>
        protected bool CheckCanNavigate(string destination, bool includeControlHierarchy)
        {
            // check the default path
            if (base.CanNavigateTo(destination))
            {
                return(true);
            }

            // include checking the control hierarchy
            if (includeControlHierarchy)
            {
                NavigableControlInfo nci = FindNavigableParent(this._owner, false, true);
                if (nci != null)
                {
                    // when delegating upwards, the control containing the matching result
                    // will appear as sender - this makes dealing with expressions more "natural".
                    return(nci.WebNavigator.CanNavigateTo(destination));
                }
            }

            return(false);
        }
        /// <summary>
        /// Finds the next <see cref="IWebNavigator"/> up  the control hierarchy, 
        /// starting at the specified <paramref name="control"/>.
        /// </summary>
        /// <remarks>
        /// This method checks both, for controls implementing <see cref="IWebNavigator"/> or <see cref="IWebNavigable"/>. In addition 
        /// when MasterPages are used, it interprets the control hierarchy as control-&gt;page-&gt;masterpage. (<see cref="WebUtils.GetLogicalParent"/>).
        /// </remarks>
        /// <param name="control">the control to start the search with.</param>
        /// <param name="includeSelf">include checking the control itself or start search with its parent.</param>
        /// <param name="restrictToValidNavigatorsOnly">requires <see cref="IWebNavigable"/>s to hold a valid <see cref="IWebNavigable.WebNavigator"/> instance.</param>
        /// <returns>If found, the next <see cref="IWebNavigator"/> or <see cref="IWebNavigable"/>.
        /// <c>null</c> otherwise</returns>
        protected static NavigableControlInfo FindNavigableParent( Control control, bool includeSelf, bool restrictToValidNavigatorsOnly )
        {
            while (control != null)
            {
                if (!includeSelf)
                {
                    // Get next parent in hierarchy
                    control = WebUtils.GetLogicalParent( control );
                }
                includeSelf = false;

                if (control is IWebNavigable || control is IWebNavigator)
                {
                    NavigableControlInfo nci = new NavigableControlInfo(control);
                    if (!restrictToValidNavigatorsOnly)
                    {
                        return nci;
                    }
                    if (nci.WebNavigator != null)
                    {
                        return nci;
                    }
                }
            }
            return null;
        }