Althought it is not final and does not contain final methods it is still not
so extensible as expected.

The idea is to delegate the real work from AssignmentWrapper back  to
ResourceModel class, for instance:

        private class AssignmentWrapper extends AbstractReadOnlyModel implements
IWrapModel {
                private final Component component;

                public AssignmentWrapper(Component component) {
                        this.component = component;
                }

                public void detach() {
                        super.detach();
                        ResourceModel.this.detach();
                }

                public Object getObject() {
                        return ResourceModel.this.getResourceString(component);
                }

                public IModel getWrappedModel() {
                        return ResourceModel.this;
                }

        }

public class ResourceModel() {
  public String getResourceString(Component component) {
     return
Application.get().getResourceSettings().getLocalizer().getString(getKey(),
component, getDefaultValue();
}

the latter use getters instead of access to fields to allow overriding the
way how keys are constructed.

As the result it won't be difficult to extend ResourceModel to provide
localization for bean property names, menu item labels and so forth.

Actually it is not so difficult to accomplish the same with my own class but
it clutters the code and does not make classes consistent, so I had to
replace the use of basic ResourceModel class with my own one.

-- 
View this message in context: 
http://www.nabble.com/ResourceModel-class-isn%27t-extensible-tp22675204p22675204.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to