You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Brett Ryan <br...@gmail.com> on 2015/06/04 09:17:49 UTC
MenuItem EL rendering
I'm wondering if it's possible to have MenuItem's evaluate EL expressions. As an example, given the following:
<definition name="customers/orders" extends="customers/base">
<put-list-attribute name="breadcrumbs">
<item value="${customer.id}" link="/customers/${customer.id}" />
<item value="Orders" link="/customers/${customer.id}/salesOrders" />
<item value="${order.id}" link="/customers/${customer.id}/salesOrders/${order.id}" />
</put-list-attribute>
<put-list-attribute name="body" cascade="true" inherit="true">
<add-attribute value="/WEB-INF/views/customers/cust-orders.jsp" />
</put-list-attribute>
</definition>
It would be really cool for each of the expressions to evaluate.
I see that the MenuItem support is now in tiles-compat, is there an alternate (better?) way of achieving this?
Re: MenuItem EL rendering
Posted by "BR Brett Ryan (3456)" <Br...@johnsands.com.au>.
Have now updated the diff to include test cases.
I am wondering why evaluation tests are done in the implementations instead of at tiles-core where it's defined? This means there's a lot of duplicated tests for a method that's not been overridden.
> On 12 Jun 2015, at 14:12, Brett Ryan <br...@johnsands.com.au> wrote:
>
> Alrighty, I've implemented the support just the way I want it, and wondered if I could contribute it back.
>
> What I've done is created a new interface (ExpressionAware) which provides the following method:
>
> void evaluateExpressions(AttributeEvaluator, Request)
>
> This is then called from AbstractAttributeEvaluator.evaluate(Attribute, Request) which then allows the implementor to update expression values or do set new properties etc. I've implemented this in the MenuItem class to replace its values when called.
>
> I'm yet to write unit-tests, I've tested with the MenuItem and it's working perfectly.
>
> You could take this further by instead of Attribute being wired into the expression awareness in core, it could also implement ExpressionAware to further abstract the expression evaluation.
>
> If the type is enumerable each item will also have its expressions evaluated (as is the case with MenuItem.
>
> Patch attached
>
>
>> On 7 Jun 2015, at 06:15, BR Brett Ryan (3456) <Br...@johnsands.com.au> wrote:
>>
>>
>>>> I see that the MenuItem support is now in tiles-compat, is there an
>>>> alternate (better?) way of achieving this?
>>>
>>>
>>> Have you looked into the SimpleMenuItem code?
>>> I'd take a stub at implementing what you need there from scratch – it's
>>> pretty simple stuff there.
>>
>> I did, and was thinking about doing it, but I couldn't find what it was that performs the EL evaluation. I must admit, it was a Thursday afternoon and I was about to head home so I didn't look terribly hard ;)I'll give it a better look.
>
Re: MenuItem EL rendering
Posted by "BR Brett Ryan (3456)" <Br...@johnsands.com.au>.
I just realised I was working on the svn tree, i'm a dick! Even though there was a big red "fork me on github" banner i still, went to "developers > building" and grabbed it from svn. Will fork with github and create a pull request :)
Sorry about the attachment, not sure what happened, i think my employer now removes them w/out warning.
> On 12 Jun 2015, at 18:47, mck <mc...@apache.org> wrote:
>
>
>
>> Alrighty, I've implemented the support just the way I want it, and
>> wondered if I could contribute it back.
>>
>> What I've done is created a new interface (ExpressionAware) which
>> provides the following method:
>>
>> void evaluateExpressions(AttributeEvaluator, Request)
>>
>> This is then called from AbstractAttributeEvaluator.evaluate(Attribute,
>> Request) which then allows the implementor to update expression values or
>> do set new properties etc. I've implemented this in the MenuItem class to
>> replace its values when called.
>
>
> Fantastic!
> I'm not seeing the patch. But could you anyhow create a jira ticket and
> upload the patch to it.
> I can review it there and we can continue the ongoing development
> discussion on the ticket.
>
> Feel free to create a separate ticket to for optimising the evaluation
> tests back to tiles-core, sounds like a good idea.
>
> ~mck
>
Re: MenuItem EL rendering
Posted by Nicolas Le Bas <ma...@nlebas.net>.
Thanks Brett,
I'll try and have a look at the pull request this weekend. Contributions
are always welcome.
On 15-06-15 04:16 AM, BR Brett Ryan (3456) wrote:
> Pull request now submitted, sorry for all the emails.
Apache projects usually discuss development matters on the dev mailing
list, would you mind joining there?
On 15-06-15 04:16 AM, BR Brett Ryan (3456) wrote:
> I have one question, because I could not figure it out. How do attributes added to a list attribute get evaluated? I could not find anything that processes the contents of list attributes themselves. Interestingly it does work however.
I'm not sure what you mean. A ListAttribute is just an attribute that
has a list as value. There is a specific syntax to build that list, but
evaluation is usually straightforward.
Hope this helps.
Nick.
Re: MenuItem EL rendering
Posted by Nicolas Le Bas <ma...@nlebas.net>.
Thanks Brett,
I'll try and have a look at the pull request this weekend. Contributions
are always welcome.
On 15-06-15 04:16 AM, BR Brett Ryan (3456) wrote:
> Pull request now submitted, sorry for all the emails.
Apache projects usually discuss development matters on the dev mailing
list, would you mind joining there?
On 15-06-15 04:16 AM, BR Brett Ryan (3456) wrote:
> I have one question, because I could not figure it out. How do attributes added to a list attribute get evaluated? I could not find anything that processes the contents of list attributes themselves. Interestingly it does work however.
I'm not sure what you mean. A ListAttribute is just an attribute that
has a list as value. There is a specific syntax to build that list, but
evaluation is usually straightforward.
Hope this helps.
Nick.
Re: MenuItem EL rendering
Posted by "BR Brett Ryan (3456)" <Br...@johnsands.com.au>.
Pull request now submitted, sorry for all the emails.
My implementation now requires the implementor to return a value which is to be used as the replacement. It can be any value or as I've done in the SimpleMenuItem implementation return a copy of itself with the expressions resolved.
It would be beneficial for the attribute classes to be immutable as they would not be thread safe.
I have one question, because I could not figure it out. How do attributes added to a list attribute get evaluated? I could not find anything that processes the contents of list attributes themselves. Interestingly it does work however.
There's probably some extra tests that could be added, namely what happens when the model changes, the tests do show that indeed attribute expansion works, but do not show what happens when the variable values themselves change on subsequent requests. This could be something to look at when we reevaluate the tests.
I'm happy to work on the tests if you like and might start work on first merging them to their higher occurrences.
Note, I've only updated TILES_3_0_X, if you're happy I'll merge this back to trunk.
> On 15 Jun 2015, at 12:44, Brett Ryan <br...@johnsands.com.au> wrote:
>
> I've just been doing further testing and only just realised that the instances created are actually singletons, I thought they were created per request. So once the values are updated they won't change again.
>
> I need to rethink what I've done and get back to you.
>
>
>> On 12 Jun 2015, at 18:47, mck <mc...@apache.org> wrote:
>>
>>
>>
>>> Alrighty, I've implemented the support just the way I want it, and
>>> wondered if I could contribute it back.
>>>
>>> What I've done is created a new interface (ExpressionAware) which
>>> provides the following method:
>>>
>>> void evaluateExpressions(AttributeEvaluator, Request)
>>>
>>> This is then called from AbstractAttributeEvaluator.evaluate(Attribute,
>>> Request) which then allows the implementor to update expression values or
>>> do set new properties etc. I've implemented this in the MenuItem class to
>>> replace its values when called.
>>>
>>
>>
>> Fantastic!
>> I'm not seeing the patch. But could you anyhow create a jira ticket and
>> upload the patch to it.
>> I can review it there and we can continue the ongoing development
>> discussion on the ticket.
>>
>> Feel free to create a separate ticket to for optimising the evaluation
>> tests back to tiles-core, sounds like a good idea.
>>
>> ~mck
>>
>
Re: MenuItem EL rendering
Posted by "BR Brett Ryan (3456)" <Br...@johnsands.com.au>.
Pull request now submitted, sorry for all the emails.
My implementation now requires the implementor to return a value which is to be used as the replacement. It can be any value or as I've done in the SimpleMenuItem implementation return a copy of itself with the expressions resolved.
It would be beneficial for the attribute classes to be immutable as they would not be thread safe.
I have one question, because I could not figure it out. How do attributes added to a list attribute get evaluated? I could not find anything that processes the contents of list attributes themselves. Interestingly it does work however.
There's probably some extra tests that could be added, namely what happens when the model changes, the tests do show that indeed attribute expansion works, but do not show what happens when the variable values themselves change on subsequent requests. This could be something to look at when we reevaluate the tests.
I'm happy to work on the tests if you like and might start work on first merging them to their higher occurrences.
Note, I've only updated TILES_3_0_X, if you're happy I'll merge this back to trunk.
> On 15 Jun 2015, at 12:44, Brett Ryan <br...@johnsands.com.au> wrote:
>
> I've just been doing further testing and only just realised that the instances created are actually singletons, I thought they were created per request. So once the values are updated they won't change again.
>
> I need to rethink what I've done and get back to you.
>
>
>> On 12 Jun 2015, at 18:47, mck <mc...@apache.org> wrote:
>>
>>
>>
>>> Alrighty, I've implemented the support just the way I want it, and
>>> wondered if I could contribute it back.
>>>
>>> What I've done is created a new interface (ExpressionAware) which
>>> provides the following method:
>>>
>>> void evaluateExpressions(AttributeEvaluator, Request)
>>>
>>> This is then called from AbstractAttributeEvaluator.evaluate(Attribute,
>>> Request) which then allows the implementor to update expression values or
>>> do set new properties etc. I've implemented this in the MenuItem class to
>>> replace its values when called.
>>>
>>
>>
>> Fantastic!
>> I'm not seeing the patch. But could you anyhow create a jira ticket and
>> upload the patch to it.
>> I can review it there and we can continue the ongoing development
>> discussion on the ticket.
>>
>> Feel free to create a separate ticket to for optimising the evaluation
>> tests back to tiles-core, sounds like a good idea.
>>
>> ~mck
>>
>
Re: MenuItem EL rendering
Posted by "BR Brett Ryan (3456)" <Br...@johnsands.com.au>.
I've just been doing further testing and only just realised that the instances created are actually singletons, I thought they were created per request. So once the values are updated they won't change again.
I need to rethink what I've done and get back to you.
> On 12 Jun 2015, at 18:47, mck <mc...@apache.org> wrote:
>
>
>
>> Alrighty, I've implemented the support just the way I want it, and
>> wondered if I could contribute it back.
>>
>> What I've done is created a new interface (ExpressionAware) which
>> provides the following method:
>>
>> void evaluateExpressions(AttributeEvaluator, Request)
>>
>> This is then called from AbstractAttributeEvaluator.evaluate(Attribute,
>> Request) which then allows the implementor to update expression values or
>> do set new properties etc. I've implemented this in the MenuItem class to
>> replace its values when called.
>>
>
>
> Fantastic!
> I'm not seeing the patch. But could you anyhow create a jira ticket and
> upload the patch to it.
> I can review it there and we can continue the ongoing development
> discussion on the ticket.
>
> Feel free to create a separate ticket to for optimising the evaluation
> tests back to tiles-core, sounds like a good idea.
>
> ~mck
>
Re: MenuItem EL rendering
Posted by mck <mc...@apache.org>.
> Alrighty, I've implemented the support just the way I want it, and
> wondered if I could contribute it back.
>
> What I've done is created a new interface (ExpressionAware) which
> provides the following method:
>
> void evaluateExpressions(AttributeEvaluator, Request)
>
> This is then called from AbstractAttributeEvaluator.evaluate(Attribute,
> Request) which then allows the implementor to update expression values or
> do set new properties etc. I've implemented this in the MenuItem class to
> replace its values when called.
>
Fantastic!
I'm not seeing the patch. But could you anyhow create a jira ticket and
upload the patch to it.
I can review it there and we can continue the ongoing development
discussion on the ticket.
Feel free to create a separate ticket to for optimising the evaluation
tests back to tiles-core, sounds like a good idea.
~mck
Re: MenuItem EL rendering
Posted by "BR Brett Ryan (3456)" <Br...@johnsands.com.au>.
Alrighty, I've implemented the support just the way I want it, and wondered if I could contribute it back.
What I've done is created a new interface (ExpressionAware) which provides the following method:
void evaluateExpressions(AttributeEvaluator, Request)
This is then called from AbstractAttributeEvaluator.evaluate(Attribute, Request) which then allows the implementor to update expression values or do set new properties etc. I've implemented this in the MenuItem class to replace its values when called.
I'm yet to write unit-tests, I've tested with the MenuItem and it's working perfectly.
You could take this further by instead of Attribute being wired into the expression awareness in core, it could also implement ExpressionAware to further abstract the expression evaluation.
If the type is enumerable each item will also have its expressions evaluated (as is the case with MenuItem.
Patch attached
> On 7 Jun 2015, at 06:15, BR Brett Ryan (3456) <Br...@johnsands.com.au> wrote:
>
>
>>> I see that the MenuItem support is now in tiles-compat, is there an
>>> alternate (better?) way of achieving this?
>>
>>
>> Have you looked into the SimpleMenuItem code?
>> I'd take a stub at implementing what you need there from scratch – it's
>> pretty simple stuff there.
>
> I did, and was thinking about doing it, but I couldn't find what it was that performs the EL evaluation. I must admit, it was a Thursday afternoon and I was about to head home so I didn't look terribly hard ;)I'll give it a better look.
Re: MenuItem EL rendering
Posted by "BR Brett Ryan (3456)" <Br...@johnsands.com.au>.
>> I see that the MenuItem support is now in tiles-compat, is there an
>> alternate (better?) way of achieving this?
>
>
> Have you looked into the SimpleMenuItem code?
> I'd take a stub at implementing what you need there from scratch – it's
> pretty simple stuff there.
I did, and was thinking about doing it, but I couldn't find what it was that performs the EL evaluation. I must admit, it was a Thursday afternoon and I was about to head home so I didn't look terribly hard ;)I'll give it a better look.
Re: MenuItem EL rendering
Posted by mck <mc...@apache.org>.
> I see that the MenuItem support is now in tiles-compat, is there an
> alternate (better?) way of achieving this?
Have you looked into the SimpleMenuItem code?
I'd take a stub at implementing what you need there from scratch – it's
pretty simple stuff there.
~mck