You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Sergey Manukyan (JIRA)" <ta...@jakarta.apache.org> on 2006/03/21 22:58:40 UTC

[jira] Commented: (TAPESTRY-243) Add getParent() method to IComponent

    [ http://issues.apache.org/jira/browse/TAPESTRY-243?page=comments#action_12371311 ] 

Sergey Manukyan commented on TAPESTRY-243:
------------------------------------------

Stumbled on the same issue...

Howard, in my understanding the relation PARENT -> CHILD , or CONTAINER -> COMPONENTS still exists in Tapestry but the creation of the relationship isnot static but dynamic, you can dynamically create components, but once you create a component it should be created in SOME KIND OF PARENT right? I understand you can move a component to another parent and so on, but that only switches one parent to another ,...they will still have parent, be it statically or dynamically created parent! 

So still don't seee a reason not implementing the getParent() method in the component. Or I am completely missing the point and Tapestry doesn't work with components and TAGS in page are just TAGS without any COMPONENT meaning other then textual human readable information???


> Add getParent() method to IComponent
> ------------------------------------
>
>          Key: TAPESTRY-243
>          URL: http://issues.apache.org/jira/browse/TAPESTRY-243
>      Project: Tapestry
>         Type: Improvement
>   Components: Framework
>     Versions: 3.0.1
>     Reporter: Naeem Malik
>     Priority: Minor

>
> 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.)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org