Tapestry
  1. Tapestry
  2. TAPESTRY-891

CLONE -Add getParent() method to IComponent

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.1
    • Fix Version/s: 4.1.1
    • Component/s: Framework
    • Labels:
      None

      Description

      Tapestry does not allow you to retrieve the parent of a component. If you have a component C nested in a component P, there is no method to retrieve the parent P from C. What is needed is a getParent() method.

      There is no logical reason for not including a getParent method as methods exist to retrieve the children of a component. The getParent method is extremely useful if you wish to change the rendering behavior of a component based on whether it is nested inside a particular component. The JSP taglib API supports this with the TagSupport.findAncestorWithClass(Tag, Class) method. Without the getParent method, it is difficult to convert some JSP tags to Tapestry components.

      Fortunately, this improvement is not difficult to implement. I have successfully implemented this by adding a private variable _parent of type IComponent to AbstractComponent and adding getParent/setParent methods to get/set the variable: the getter should look like this:

      return _parent != null ? _parent : getContainer();

      Finally, add the following line to BaseComponentTemplateLoader.process(OpenToken) method (line 268 under version 3.0.1)

      component.setParent(_activeComponent);

      (Note that Tapestry does allow you to retrieve the IComponent a particular component is embedded in via the IComponent.getContainer() call. This call will retrieve the component whose template C was defined in. This method does not address the issue.)

        Issue Links

          Activity

          Hide
          Sergey Manukyan added a comment -

          Please see my comment on TAPESTRY-243.

          The relationship PARENT->CHILD is extremely important in development of highly structural complex components. Not having a standard API to implement this relationship represents certain difficulties during implementation.

          The problem is that this relationship is visual in cases of creating templates of complex components and navigation on them requires the knowledge of the parents and children. I am curious why the XML DOM model cannot be used as the representation of complex structure of components with some extensions for functionality specifyc for Tapestry?

          If the reality is that Tapestry framework doesn't allow structuring of components as it stands now then the framework should be recognized as unstructured, some kind of system of independent components without parent->child relationship, which IMHO from object oriented point of view makes it less pure from the architecture point of view.

          Thanks.

          Show
          Sergey Manukyan added a comment - Please see my comment on TAPESTRY-243 . The relationship PARENT->CHILD is extremely important in development of highly structural complex components. Not having a standard API to implement this relationship represents certain difficulties during implementation. The problem is that this relationship is visual in cases of creating templates of complex components and navigation on them requires the knowledge of the parents and children. I am curious why the XML DOM model cannot be used as the representation of complex structure of components with some extensions for functionality specifyc for Tapestry? If the reality is that Tapestry framework doesn't allow structuring of components as it stands now then the framework should be recognized as unstructured, some kind of system of independent components without parent->child relationship, which IMHO from object oriented point of view makes it less pure from the architecture point of view. Thanks.
          Hide
          Jesse Kuhnert added a comment -

          See new render stack related methods added to IRequestCycle

          Show
          Jesse Kuhnert added a comment - See new render stack related methods added to IRequestCycle

            People

            • Assignee:
              Jesse Kuhnert
              Reporter:
              Sergey Manukyan
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development