You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2006/03/23 13:52:16 UTC

DO NOT REPLY [Bug 39080] New: - XmlDefinitionsSet.extend does not clear "path" attribute

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39080>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39080

           Summary: XmlDefinitionsSet.extend does not clear "path" attribute
           Product: Struts
           Version: 1.2.8
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Tiles
        AssignedTo: dev@struts.apache.org
        ReportedBy: brenmcguire@tariffenet.it
                CC: brenmcguire@tariffenet.it


I need to extend definitions specified in different files.
In file 1 (the root) I have:

 <definition name="page.index" path="/layout/classic_layout.jsp">
   <put name="top" value="/tiles/top.jsp"/>
   <put name="left" value="/tiles/fourth.jsp"/>
   <put name="body" value="/tiles/login.jsp" />
 </definition>

In file 2 (the child) I have:

 <definition name="page.index.bug" path="/layout/three_rows_layout.jsp" />
 <definition name="page.index" extends="page.index.bug">
   <put name="top" value="/tiles/top_pda.jsp"/>
   <put name="left" value="/tiles/fourth.jsp"/>
   <put name="body" value="/tiles/login.jsp" />
 </definition>

In the second file, the "page.index" extends "page.index.bug", then it should
inherit its path ("/layout/three_rows_layout.jsp"). Instead it inherits the path
from "page.index" in the first file ("/layout/classic_layout.jsp")!
After calling XmlDefinitionsSet.extend, the definitions has both "extend" and
"path" properties set, that seems to be strange.

POSSIBLE SOLUTION

In XmlDefinitionsSet.extend I find this code:

<snip>
     XmlDefinition childInstance = (XmlDefinition)i.next();
     XmlDefinition parentInstance = getDefinition(childInstance.getName() );
     if( parentInstance != null )
       {
       parentInstance.overload( childInstance );
       }
      else
       putDefinition( childInstance );
</snip>

So, if there is no parent definition, it is simply put, otherwise it is
"overloaded".
The "overload" method is:

<snip>
 public void overload( XmlDefinition child )
   {
   if( child.getPath() != null )
     {
     path = child.getPath();
     }
   if( child.getExtends() != null )
     {
     inherit = child.getExtends();
     }
   if( child.getRole() != null )
     {
     role = child.getRole();
     }
   if( child.getController()!=null )
     {
     controller = child.getController();
     controllerType =  child.getControllerType();
     }
     // put all child attributes in parent.
   attributes.putAll( child.getAttributes());
   }
}
</snip>

That is, for each property of "child", if it is not null, it is copied, without
modifying the original. IMHO if the "inherit" property of "child" is not null,
the "path" attribute
of the original definition must be set to null (if child.path is null) or it
should match child.path.
So the code could be:

<snip>
 public void overload( XmlDefinition child )
   {
   if( child.getExtends() != null )
     {
     inherit = child.getExtends();
     path = child.getPath(); //It's ok even if it is null
     }
   else if( child.getPath() != null )
     {
     path = child.getPath();
     }
...
</snip>

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 39080] - XmlDefinitionsSet.extend does not clear "path" attribute

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39080>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39080





------- Additional Comments From brenmcguire@tariffenet.it  2006-05-30 11:34 -------
It seems that Standalone Tiles does not suffer of this "bug" because a totally
different strategy used to resolve inheritances between definitions.
Struts Tiles:
1) Take the root definition and call it "definition"
2) Get the next child and call it "child"
3) If the definition has missing attributes (including "extend" and "path"),
overload them with child's ones.
4) Go to point 2

Standalone Tiles:
1) Take the last child and call it "definition"
2) Take the parent of "definition" and call it "parent"
3) Overload all missing attributes in "definition" with "parent" ones.
4) Take the parent of "parent" and call it "parent" until root definition is reached
5) Go to point 3

Therefore in Standalone Tiles the "child" attributes have the "precedence" to
the parent ones. In Struts Tiles it is exactly the opposite

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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