Tapestry
  1. Tapestry
  2. TAPESTRY-1457

No way for PageLink to distinguish between an explicitly empty page activate context and normal delegation to the target page's passivate event

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.3
    • Fix Version/s: 5.0.5
    • Component/s: Core Components
    • Labels:
      None

      Description

      It isn't possible to set an empty context using 'contex' parameter of PageLink. It always treats null and zero length array/list in the same way - asks the page about its activation context via onPassivate. I think that only null should trigger onPassivate.

      Example

      <a t:type="PageLink" page="test" context="context">page link</a>

      public Object[] getContext()
      {
      if (test == 0)
      return new Object[]

      {"1", "2"}

      ; // context will be ../test/1/2
      else
      if (test == 1)
      return new Object[0]; // onPassivate will be asked but context should be empty IMO
      else
      return null; // onPassivate will be asked, ok
      }

        Activity

        Hide
        Howard M. Lewis Ship added a comment -

        For PageLink, if you bind the context (to null) then the page link will be created with an empty context.

        That is, the override method parameter is set to true if the context component parameter is bound (even if bound to null). A null value is converted to an empty array. With override set to true, the target page will not be consulted (via the passivate event) for the context, the provided, empty context will be used.

        This is slightly different from the initial description. Of course, you can bypass PageLink and generate the Link in code if this isn't precisely what you want.

        Show
        Howard M. Lewis Ship added a comment - For PageLink, if you bind the context (to null) then the page link will be created with an empty context. That is, the override method parameter is set to true if the context component parameter is bound (even if bound to null). A null value is converted to an empty array. With override set to true, the target page will not be consulted (via the passivate event) for the context, the provided, empty context will be used. This is slightly different from the initial description. Of course, you can bypass PageLink and generate the Link in code if this isn't precisely what you want.
        Hide
        Howard M. Lewis Ship added a comment -

        I'm having to change the various createPageLink() methods (it's in a couple of different interfaces, due to Law of Demeter) ... anyway, adding an boolean override parameters which can be set to true to indicate "use the supplied context even when empty." Eventually, that will be tied to the ActionLink's context parameter, as in resources.isBound().

        Show
        Howard M. Lewis Ship added a comment - I'm having to change the various createPageLink() methods (it's in a couple of different interfaces, due to Law of Demeter) ... anyway, adding an boolean override parameters which can be set to true to indicate "use the supplied context even when empty." Eventually, that will be tied to the ActionLink's context parameter, as in resources.isBound().
        Hide
        Howard M. Lewis Ship added a comment -

        Ah, the joys of JDK 5 varargs. I really liked the idea of being able to pass Object... for the context. The problem is that there's no way to distinguish explicit null from omitting the varargs parameters (it just shows up as an empty array).

        I may have to convert the page context parameters to Object[] so that we can differential null from explict no context.

        Show
        Howard M. Lewis Ship added a comment - Ah, the joys of JDK 5 varargs. I really liked the idea of being able to pass Object... for the context. The problem is that there's no way to distinguish explicit null from omitting the varargs parameters (it just shows up as an empty array). I may have to convert the page context parameters to Object[] so that we can differential null from explict no context.

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Peter
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development