You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Matthias Keller (JIRA)" <ji...@apache.org> on 2012/08/09 08:58:19 UTC

[jira] [Created] (WICKET-4703) StringResourceModel should provide an overridable getString(Component) method

Matthias Keller created WICKET-4703:
---------------------------------------

             Summary: StringResourceModel should provide an overridable getString(Component) method
                 Key: WICKET-4703
                 URL: https://issues.apache.org/jira/browse/WICKET-4703
             Project: Wicket
          Issue Type: Improvement
          Components: wicket
    Affects Versions: 1.5.7
            Reporter: Matthias Keller


String ResourceModel is not really subclassable to provide additional logic (for example return an empty string if not all properties could be evaluated etc).
Normally, any LDM can be subclassed an it's load() method overridden which does not work here in most cases since the model is wrapped internally and if the SRM was not constructed with an explicit component (but attached later to a component), the load() method of the STM is never evaluated since the AssignmentWrapper calls getString(Component) directly.
This method should be overridable in some way and the javadoc on load() amended to inform programmers that overriding this method will not always lead to the desired goal.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WICKET-4703) StringResourceModel should provide an overridable getString(Component) method

Posted by "Matthias Keller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13433167#comment-13433167 ] 

Matthias Keller commented on WICKET-4703:
-----------------------------------------

Probably the most complete solution to this would be to add a new Method to IComponentAssignedModel like  T getObject(Component)
While this could possibly not be wanted in a bugfix release, it would be good for Wicket 6. For 1.5.x it would be great to at least make getString(Component) protected in StringResourceModel and add a comment to the load() method to tell users that they should override the getString(Component) method instead since load() might not always be called due to the wrapper.
                
> StringResourceModel should provide an overridable getString(Component) method
> -----------------------------------------------------------------------------
>
>                 Key: WICKET-4703
>                 URL: https://issues.apache.org/jira/browse/WICKET-4703
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.5.7
>            Reporter: Matthias Keller
>
> String ResourceModel is not really subclassable to provide additional logic (for example return an empty string if not all properties could be evaluated etc).
> Normally, any LDM can be subclassed an it's load() method overridden which does not work here in most cases since the model is wrapped internally and if the SRM was not constructed with an explicit component (but attached later to a component), the load() method of the STM is never evaluated since the AssignmentWrapper calls getString(Component) directly.
> This method should be overridable in some way and the javadoc on load() amended to inform programmers that overriding this method will not always lead to the desired goal.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WICKET-4703) StringResourceModel should provide an overridable getString(Component) method

Posted by "Sven Meier (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13436779#comment-13436779 ] 

Sven Meier commented on WICKET-4703:
------------------------------------

On further investigation I'm not sure what we gain by making getString() protected. Could you show a sample on what you want to do in an override?
Thanks.
                
> StringResourceModel should provide an overridable getString(Component) method
> -----------------------------------------------------------------------------
>
>                 Key: WICKET-4703
>                 URL: https://issues.apache.org/jira/browse/WICKET-4703
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.5.7
>            Reporter: Matthias Keller
>
> String ResourceModel is not really subclassable to provide additional logic (for example return an empty string if not all properties could be evaluated etc).
> Normally, any LDM can be subclassed an it's load() method overridden which does not work here in most cases since the model is wrapped internally and if the SRM was not constructed with an explicit component (but attached later to a component), the load() method of the STM is never evaluated since the AssignmentWrapper calls getString(Component) directly.
> This method should be overridable in some way and the javadoc on load() amended to inform programmers that overriding this method will not always lead to the desired goal.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WICKET-4703) StringResourceModel should provide an overridable getString(Component) method

Posted by "Sven Meier (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13436282#comment-13436282 ] 

Sven Meier commented on WICKET-4703:
------------------------------------

I've added a comment to #load()'s javadoc and made the method final in WIcket 6.

I'll do some more testing and if no problem shows up I'll make getString(Component) protected.
                
> StringResourceModel should provide an overridable getString(Component) method
> -----------------------------------------------------------------------------
>
>                 Key: WICKET-4703
>                 URL: https://issues.apache.org/jira/browse/WICKET-4703
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.5.7
>            Reporter: Matthias Keller
>
> String ResourceModel is not really subclassable to provide additional logic (for example return an empty string if not all properties could be evaluated etc).
> Normally, any LDM can be subclassed an it's load() method overridden which does not work here in most cases since the model is wrapped internally and if the SRM was not constructed with an explicit component (but attached later to a component), the load() method of the STM is never evaluated since the AssignmentWrapper calls getString(Component) directly.
> This method should be overridable in some way and the javadoc on load() amended to inform programmers that overriding this method will not always lead to the desired goal.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WICKET-4703) StringResourceModel should provide an overridable getString(Component) method

Posted by "Matthias Keller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-4703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437724#comment-13437724 ] 

Matthias Keller commented on WICKET-4703:
-----------------------------------------

Thanks for your thoughts. We subclass StringResourceModel currently for the following two tasks:
- 'DefaultValueStringResourceModel' - This model checks if all expressions were resolved in the String. If they were not, because a model value was null, thus leaving someting like  ${user.name}  in the resulting String, it replaces it entirely with another text.
This allows us to use this model where we're not always sure if there's anything to display and we don't want to subclass the label to check for some model's null values and then show/hide the label accordingly because this splits the logic to between the translation text and the implementation
- 'UnresolvedIgnoringStringResourceModel' - This model is a bit like the above but it just replaces all unresolved variables with the empty String. This is especially interesting if some address needs to be displayed which has null values instead of empty String if any field is not set. So this reduces the result 'Mr Bla Blu, Any Avenue 10 ${address.additionalStreetInfo}, 12435 Town' to 'Mr Bla Blu, Any Avenue 10 , 12435 Town'

Thus what we do is postprocess the result of the mighty StringResourcesModel to achieve what we want. Recreating our own StringResourceModels seems very unnatural here and would involve a lot of copypaste.
However I don't see what you lose by making getString(Component) protected. It allows implementors like us to tailor the model as we need it.
For Wicket 6 however it would be good if for example IComponentAssignedModel would require something like getString(Component) so that all those models would be forced to implement this method and allow subclassing wherever needed.
                
> StringResourceModel should provide an overridable getString(Component) method
> -----------------------------------------------------------------------------
>
>                 Key: WICKET-4703
>                 URL: https://issues.apache.org/jira/browse/WICKET-4703
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.5.7
>            Reporter: Matthias Keller
>
> String ResourceModel is not really subclassable to provide additional logic (for example return an empty string if not all properties could be evaluated etc).
> Normally, any LDM can be subclassed an it's load() method overridden which does not work here in most cases since the model is wrapped internally and if the SRM was not constructed with an explicit component (but attached later to a component), the load() method of the STM is never evaluated since the AssignmentWrapper calls getString(Component) directly.
> This method should be overridable in some way and the javadoc on load() amended to inform programmers that overriding this method will not always lead to the desired goal.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira