You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Antonio Petrelli <ap...@apache.org> on 2006/11/06 13:56:47 UTC

[tiles2] AttributeTag.preprocessAttribute disappearance

Hi list, and especially David (H. DeWolf)
I noticed that you renamed AttributeTag.preprocessAttribute into 
"calculateType", and you removed all the logic that "fixed" the 
attribute object itself.
Is this "fixing" code moved anywhere, or is it been removed completely?

TIA
Antonio

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


Re: [tiles2] AttributeTag.preprocessAttribute disappearance

Posted by "David H. DeWolf" <dd...@apache.org>.
Cool! As long as there's a reason! :)

Greg Reddin wrote:
> 
> On Nov 6, 2006, at 8:42 AM, Antonio Petrelli wrote:
> 
>> David H. DeWolf ha scritto:
>>> By the way, what's the use case for putting definitions in a jsp?  
>>> Why would someone prefer that method over another. . .
>>
>> That's a good question. In real applications I never used 
>> JSP-configured defininitions, but removing them could break all the 
>> applications. It is not like removing a tag library because it is 
>> redundant, removing a functionality that will not exist anymore can be 
>> harmful.
>> Just my 2 eurocents....
> 
> Yeah, I can envision a use case where someone may want to define defs in 
> a JSP page so they are dynamic.  I've never done it, but it could be 
> done :-)
> 
> Greg
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 

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


Re: [tiles2] AttributeTag.preprocessAttribute disappearance

Posted by Greg Reddin <gr...@apache.org>.
On Nov 6, 2006, at 8:42 AM, Antonio Petrelli wrote:

> David H. DeWolf ha scritto:
>> By the way, what's the use case for putting definitions in a jsp?   
>> Why would someone prefer that method over another. . .
>
> That's a good question. In real applications I never used JSP- 
> configured defininitions, but removing them could break all the  
> applications. It is not like removing a tag library because it is  
> redundant, removing a functionality that will not exist anymore can  
> be harmful.
> Just my 2 eurocents....

Yeah, I can envision a use case where someone may want to define defs  
in a JSP page so they are dynamic.  I've never done it, but it could  
be done :-)

Greg



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


Re: [tiles2] AttributeTag.preprocessAttribute disappearance

Posted by Antonio Petrelli <ap...@apache.org>.
David H. DeWolf ha scritto:
> By the way, what's the use case for putting definitions in a jsp?  Why 
> would someone prefer that method over another. . .

That's a good question. In real applications I never used JSP-configured 
defininitions, but removing them could break all the applications. It is 
not like removing a tag library because it is redundant, removing a 
functionality that will not exist anymore can be harmful.
Just my 2 eurocents....

Antonio

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


Re: [tiles2] AttributeTag.preprocessAttribute disappearance

Posted by "David H. DeWolf" <dd...@apache.org>.
By the way, what's the use case for putting definitions in a jsp?  Why 
would someone prefer that method over another. . .

David

Antonio Petrelli wrote:
> David H. DeWolf ha scritto:
>> ummm. . .yes, I specifically remember removing that for a reason, but 
>> for the life of me can't remember why.  Perhaps I just wasn't thinking 
>> straight.
>>
>> Good catch, I'd say let's add it back in as it will make the rest of 
>> the attribute tag processing a little simpler.
>>
>> The only reason why we wouldn't want to modify the underlying 
>> ComponentAttribute would be if we want to support the case where:
>>
>> 1) type is calculated
>> 2) no valid definition is found matching the name
>> 3) type is set to string
>> 4) definition is added to the container
>> 5) tag is now in an invalid state as a recalculation would result in a 
>> type of 'definition'
> 
> I added that "preprocessAttribute" method simply because attributes in 
> definitions created with DefinitionTag may be inconsistent, while those 
> created in tiles-defs.xml are consistent after resolving attributes. In 
> fact the "preprocessing" could be executed when the definition in 
> DefinitionTag is created, therefore there won't be need for such a 
> preprocessing in AttributeTag.
> 
>> On the other hand, the benefit of setting the type after calculation 
>> is that it saves us a couple of nano-seconds because we don't have to 
>> recalculate the next time around (which is basically a couple of 
>> equals operations and a lookup in a map).
> 
> Speaking of performances, there is an issue for that:
> http://issues.apache.org/struts/browse/SB-49
> 
> You have to read "AttributeTag" instead of "InsertTag". I did not update 
> the issue waiting for an answer from you.
> Thank you.
> 
> Ciao
> Antonio
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 

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


Re: [tiles2] AttributeTag.preprocessAttribute disappearance

Posted by "David H. DeWolf" <dd...@apache.org>.
Gotcha,

Yes, I fully expect that this test will pass as soon as we are able to 
register the jsp defined definitions (of course, I could be wrong!). 
The behavior should be the same as the configured definitions. . and the 
test should result in the same behavior as the configured composite test.

David


Antonio Petrelli wrote:
> David H. DeWolf ha scritto:
>> Hmm, now I'm really lost. . what is the feature that you're talking 
>> about?  I thought you were talking about rendering attributes of type 
>> definition.  How is that tested by the "Test definition tag" 
>> (testdef.jsp)?
> 
> Err... sorry I meant "Test insert definition that contains another 
> definition inside" (all of them), they all fail.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 

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


Re: [tiles2] AttributeTag.preprocessAttribute disappearance

Posted by Antonio Petrelli <ap...@apache.org>.
David H. DeWolf ha scritto:
> Hmm, now I'm really lost. . what is the feature that you're talking 
> about?  I thought you were talking about rendering attributes of type 
> definition.  How is that tested by the "Test definition tag" 
> (testdef.jsp)?

Err... sorry I meant "Test insert definition that contains another 
definition inside" (all of them), they all fail.


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


Re: [tiles2] AttributeTag.preprocessAttribute disappearance

Posted by "David H. DeWolf" <dd...@apache.org>.
Hmm, now I'm really lost. . what is the feature that you're talking 
about?  I thought you were talking about rendering attributes of type 
definition.  How is that tested by the "Test definition tag" (testdef.jsp)?

<tiles:definition name="templateDefinition" template="/layout.jsp">
   <tiles:put name="title"  value="This is the title." />
   <tiles:put name="header" value="/header.jsp" />
   <tiles:put name="body"   value="/body.jsp" />
</tiles:definition>
<tiles:insertDefinition name="templateDefinition" />

This doesn't include any attributes of type def.

If this is really a problem with the definition tag, then I suspect that 
it will be fixed when we come up with a strategy for refactoring the 
definitions factory and providing a mutable container.

David

Antonio Petrelli wrote:
> David H. DeWolf ha scritto:
>> Perhaps we're talking past each other, do you have a test case that 
>> shows the failure?
> 
> Yes, it is "Test definition tag" in test webapp, but it is hidden by a 
> TODO that you put in DefinitionTag...
> In fact the problem happens only with JSP-configured definitions, so no 
> luck until DefinitionTag is fixed.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 

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


Re: [tiles2] AttributeTag.preprocessAttribute disappearance

Posted by Antonio Petrelli <ap...@apache.org>.
David H. DeWolf ha scritto:
> Perhaps we're talking past each other, do you have a test case that 
> shows the failure?

Yes, it is "Test definition tag" in test webapp, but it is hidden by a 
TODO that you put in DefinitionTag...
In fact the problem happens only with JSP-configured definitions, so no 
luck until DefinitionTag is fixed.

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


Re: [tiles2] AttributeTag.preprocessAttribute disappearance

Posted by "David H. DeWolf" <dd...@apache.org>.
I don't think that we want to "get" a definition outside of the 
container.  That should be an implementation detail of the container.  I 
think it's this philosophy that allowed the tags to be cleaned up 
significantly.

Instead, attributes are now "recognized" as being a definition and thus 
the container is invoked by the render tag in order to perform the render.

Perhaps we're talking past each other, do you have a test case that 
shows the failure?

David



Antonio Petrelli wrote:
> David H. DeWolf ha scritto:
>> Works for me. . .go for it!
> 
> Committed but there's still a problem. In previous versions, if the 
> attribute value was a string and the type was "definition", it tries to 
> get that definition and put it as the value of the attribute. This logic 
> seems to have disappeared. I put a FIXME for it, because i don't know 
> the new "correct" way to get a definition.
> 
> What do you think?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 

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


Re: [tiles2] AttributeTag.preprocessAttribute disappearance

Posted by Antonio Petrelli <ap...@apache.org>.
David H. DeWolf ha scritto:
> Works for me. . .go for it!

Committed but there's still a problem. In previous versions, if the 
attribute value was a string and the type was "definition", it tries to 
get that definition and put it as the value of the attribute. This logic 
seems to have disappeared. I put a FIXME for it, because i don't know 
the new "correct" way to get a definition.

What do you think?

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


Re: [tiles2] AttributeTag.preprocessAttribute disappearance

Posted by "David H. DeWolf" <dd...@apache.org>.
Works for me. . .go for it!

Antonio Petrelli wrote:
> David H. DeWolf ha scritto:
>> Can you help me understand why those created from the factory are 
>> "consistent"?
> 
> Err... I am not that sure... I think that preprocessing should happen 
> also to "configured" attributes, I thought that 
> ComponentDefinitionsImpl.resolveAttributes fixed the attributes, but it 
> seems that it doesn't.
> 
>> We definitely could do this type of thing at creation time - for both 
>> those defined through the tag and those defined through the factory.  
>> I don't really have a strong opinion either way, but my inclination 
>> would be to resolve the unspecified type 'just in time'. . .
> 
> Ok, then I think that "preprocessAttribute" should be re-put.
> 
>>
>> 2) Accept this small overhead in order to allow this property to morph 
>> as new definitions are registered.
>>
>> What I don't think we want is to require the tag to differentiate 
>> between tag created definitions and container created definitions.
>>
>> Agree?
> 
> Ok, but leave SB-49 open, so maybe one day we will fix it.
> 
> Ciao
> Antonio
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 

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


Re: [tiles2] AttributeTag.preprocessAttribute disappearance

Posted by Antonio Petrelli <ap...@apache.org>.
David H. DeWolf ha scritto:
> Can you help me understand why those created from the factory are 
> "consistent"?

Err... I am not that sure... I think that preprocessing should happen 
also to "configured" attributes, I thought that 
ComponentDefinitionsImpl.resolveAttributes fixed the attributes, but it 
seems that it doesn't.

> We definitely could do this type of thing at creation time - for both 
> those defined through the tag and those defined through the factory.  
> I don't really have a strong opinion either way, but my inclination 
> would be to resolve the unspecified type 'just in time'. . .

Ok, then I think that "preprocessAttribute" should be re-put.

>
> 2) Accept this small overhead in order to allow this property to morph 
> as new definitions are registered.
>
> What I don't think we want is to require the tag to differentiate 
> between tag created definitions and container created definitions.
>
> Agree?

Ok, but leave SB-49 open, so maybe one day we will fix it.

Ciao
Antonio

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


Re: [tiles2] AttributeTag.preprocessAttribute disappearance

Posted by "David H. DeWolf" <dd...@apache.org>.

Antonio Petrelli wrote:
> David H. DeWolf ha scritto:
>> ummm. . .yes, I specifically remember removing that for a reason, but 
>> for the life of me can't remember why.  Perhaps I just wasn't thinking 
>> straight.
>>
>> Good catch, I'd say let's add it back in as it will make the rest of 
>> the attribute tag processing a little simpler.
>>
>> The only reason why we wouldn't want to modify the underlying 
>> ComponentAttribute would be if we want to support the case where:
>>
>> 1) type is calculated
>> 2) no valid definition is found matching the name
>> 3) type is set to string
>> 4) definition is added to the container
>> 5) tag is now in an invalid state as a recalculation would result in a 
>> type of 'definition'
> 
> I added that "preprocessAttribute" method simply because attributes in 
> definitions created with DefinitionTag may be inconsistent, while those 
> created in tiles-defs.xml are consistent after resolving attributes. In 
> fact the "preprocessing" could be executed when the definition in 
> DefinitionTag is created, therefore there won't be need for such a 
> preprocessing in AttributeTag.

Can you help me understand why those created from the factory are 
"consistent"?

We definitely could do this type of thing at creation time - for both 
those defined through the tag and those defined through the factory.  I 
don't really have a strong opinion either way, but my inclination would 
be to resolve the unspecified type 'just in time'. . .

> 
>> On the other hand, the benefit of setting the type after calculation 
>> is that it saves us a couple of nano-seconds because we don't have to 
>> recalculate the next time around (which is basically a couple of 
>> equals operations and a lookup in a map).
> 
> Speaking of performances, there is an issue for that:
> http://issues.apache.org/struts/browse/SB-49

Agreed.  It still behaves as described.

> 
> You have to read "AttributeTag" instead of "InsertTag". I did not update 
> the issue waiting for an answer from you.

It's always been in AttributeTag, correct?  I would say that the 
solution is one of the following:

1) Set the type after resolving it the first time so it can be reused

2) Accept this small overhead in order to allow this property to morph 
as new definitions are registered.

What I don't think we want is to require the tag to differentiate 
between tag created definitions and container created definitions.

Agree?


David


> Thank you.
> 
> Ciao
> Antonio
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 

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


Re: [tiles2] AttributeTag.preprocessAttribute disappearance

Posted by Antonio Petrelli <ap...@apache.org>.
David H. DeWolf ha scritto:
> ummm. . .yes, I specifically remember removing that for a reason, but 
> for the life of me can't remember why.  Perhaps I just wasn't thinking 
> straight.
>
> Good catch, I'd say let's add it back in as it will make the rest of 
> the attribute tag processing a little simpler.
>
> The only reason why we wouldn't want to modify the underlying 
> ComponentAttribute would be if we want to support the case where:
>
> 1) type is calculated
> 2) no valid definition is found matching the name
> 3) type is set to string
> 4) definition is added to the container
> 5) tag is now in an invalid state as a recalculation would result in a 
> type of 'definition'

I added that "preprocessAttribute" method simply because attributes in 
definitions created with DefinitionTag may be inconsistent, while those 
created in tiles-defs.xml are consistent after resolving attributes. In 
fact the "preprocessing" could be executed when the definition in 
DefinitionTag is created, therefore there won't be need for such a 
preprocessing in AttributeTag.

> On the other hand, the benefit of setting the type after calculation 
> is that it saves us a couple of nano-seconds because we don't have to 
> recalculate the next time around (which is basically a couple of 
> equals operations and a lookup in a map).

Speaking of performances, there is an issue for that:
http://issues.apache.org/struts/browse/SB-49

You have to read "AttributeTag" instead of "InsertTag". I did not update 
the issue waiting for an answer from you.
Thank you.

Ciao
Antonio

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


Re: [tiles2] AttributeTag.preprocessAttribute disappearance

Posted by "David H. DeWolf" <dd...@apache.org>.
ummm. . .yes, I specifically remember removing that for a reason, but 
for the life of me can't remember why.  Perhaps I just wasn't thinking 
straight.

Good catch, I'd say let's add it back in as it will make the rest of the 
attribute tag processing a little simpler.

The only reason why we wouldn't want to modify the underlying 
ComponentAttribute would be if we want to support the case where:

1) type is calculated
2) no valid definition is found matching the name
3) type is set to string
4) definition is added to the container
5) tag is now in an invalid state as a recalculation would result in a 
type of 'definition'

or the opposite where a definition is removed, but we currently don't 
support removing definitions.

On the other hand, the benefit of setting the type after calculation is 
that it saves us a couple of nano-seconds because we don't have to 
recalculate the next time around (which is basically a couple of equals 
operations and a lookup in a map).

I could go either way. . .

David






Antonio Petrelli wrote:
> Hi list, and especially David (H. DeWolf)
> I noticed that you renamed AttributeTag.preprocessAttribute into 
> "calculateType", and you removed all the logic that "fixed" the 
> attribute object itself.
> Is this "fixing" code moved anywhere, or is it been removed completely?
> 
> TIA
> Antonio
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 

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