You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@tiles.apache.org by "mck (JIRA)" <ji...@apache.org> on 2017/02/23 09:58:44 UTC
[jira] [Commented] (TILES-586) improve
AttributeContext.getLocalAttribute for value retrieval
[ https://issues.apache.org/jira/browse/TILES-586?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15880202#comment-15880202 ]
mck commented on TILES-586:
---------------------------
[~hurelhuyag], could you provide more explanation, and even a patch?
I'm unsure what you mean by {{AttributeContext.getLocalAttribute}} being too verbose, and how it might be improved. The code snippet you provide only offers a way to use {{AttributeContext.getLocalAttribute}} that permits specifying a default value.
> improve AttributeContext.getLocalAttribute for value retrieval
> --------------------------------------------------------------
>
> Key: TILES-586
> URL: https://issues.apache.org/jira/browse/TILES-586
> Project: Tiles
> Issue Type: Improvement
> Affects Versions: 3.0.7
> Reporter: hurelhuyag
> Priority: Minor
>
> AttributeContext.getLocalAttribute usage is to verbose. I think AttributeContext should be improved. This is my currently using BaseViewPreparer.
> {code:java}
> public abstract class BaseViewPreparer implements ViewPreparer {
> @SuppressWarnings("unchecked")
> protected <T> T getLocalAttribute(String name, AttributeContext attributeContext, T defaultValue){
> Attribute attribute = attributeContext.getLocalAttribute(name);
> if (attribute != null){
> return (T) attribute.getValue();
> }else{
> return defaultValue;
> }
> }
> @Override
> public abstract void execute(Request tilesContext, AttributeContext attributeContext);
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)