You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Mathieu Carbou (JIRA)" <ji...@apache.org> on 2008/12/05 20:44:44 UTC
[jira] Created: (WICKET-1968) PropertyModel not easily extendable
PropertyModel not easily extendable
-----------------------------------
Key: WICKET-1968
URL: https://issues.apache.org/jira/browse/WICKET-1968
Project: Wicket
Issue Type: Bug
Components: wicket
Affects Versions: 1.4-RC1
Reporter: Mathieu Carbou
We wanted to create a LodableDetacheableProeprtyModel like this:
public abstract class DetachablePropertyModel<T> extends PropertyModel<T> {
public DetachablePropertyModel(String expression) {
super(new LoadableDetachableModel<Object>() {
protected Object load() {
return DetachablePropertyModel.this.load();
}
}, expression);
}
protected abstract Object load();
}
But this is not possible. Since we cannot access a method of a not yest instanciated class.
So we wanted to chang to this:
public abstract class DetachablePropertyModel<T> extends PropertyModel<T> {
public DetachablePropertyModel(String expression) {
super();
setChainedModel(new LoadableDetachableModel<Object>() {
protected Object load() {
return DetachablePropertyModel.this.load();
}
});
}
protected abstract Object load();
}
But the constructor of AbstractPropertyModel requires a model and also (and here is the issue) check for null argument:
public AbstractPropertyModel(final Object modelObject)
{
if (modelObject == null)
{
throw new IllegalArgumentException("Parameter modelObject cannot be null");
}
target = modelObject;
}
So the only way to bypass this was to call the super constructor like this:
public abstract class DetachablePropertyModel<T> extends PropertyModel<T> {
public DetachablePropertyModel(String expression) {
super(expression, expression);
setChainedModel(new LoadableDetachableModel<Object>() {
protected Object load() {
return DetachablePropertyModel.this.load();
}
});
}
protected abstract Object load();
}
By giving the expression to the super class, and giving the expression also as the object, it works. But it is not correct...
I think a redesign of AbstractPropertyModel would be necessary: to use the method setChainedModel on AbstractPropertyModel , we currently need to first have the object instanciated with a non null model.... Which is not what we may want...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (WICKET-1968) PropertyModel not easily extendable
Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-1968?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Igor Vaynberg resolved WICKET-1968.
-----------------------------------
Resolution: Won't Fix
Assignee: Igor Vaynberg
you can use composition to extend the propertymodel functionality instead of inheritance
> PropertyModel not easily extendable
> -----------------------------------
>
> Key: WICKET-1968
> URL: https://issues.apache.org/jira/browse/WICKET-1968
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC1
> Reporter: Mathieu Carbou
> Assignee: Igor Vaynberg
>
> We wanted to create a LodableDetacheableProeprtyModel like this:
> public abstract class DetachablePropertyModel<T> extends PropertyModel<T> {
> public DetachablePropertyModel(String expression) {
> super(new LoadableDetachableModel<Object>() {
> protected Object load() {
> return DetachablePropertyModel.this.load();
> }
> }, expression);
> }
> protected abstract Object load();
> }
> But this is not possible. Since we cannot access a method of a not yest instanciated class.
> So we wanted to chang to this:
> public abstract class DetachablePropertyModel<T> extends PropertyModel<T> {
> public DetachablePropertyModel(String expression) {
> super();
> setChainedModel(new LoadableDetachableModel<Object>() {
> protected Object load() {
> return DetachablePropertyModel.this.load();
> }
> });
> }
> protected abstract Object load();
> }
> But the constructor of AbstractPropertyModel requires a model and also (and here is the issue) check for null argument:
> public AbstractPropertyModel(final Object modelObject)
> {
> if (modelObject == null)
> {
> throw new IllegalArgumentException("Parameter modelObject cannot be null");
> }
> target = modelObject;
> }
> So the only way to bypass this was to call the super constructor like this:
> public abstract class DetachablePropertyModel<T> extends PropertyModel<T> {
> public DetachablePropertyModel(String expression) {
> super(expression, expression);
> setChainedModel(new LoadableDetachableModel<Object>() {
> protected Object load() {
> return DetachablePropertyModel.this.load();
> }
> });
> }
> protected abstract Object load();
> }
> By giving the expression to the super class, and giving the expression also as the object, it works. But it is not correct...
> I think a redesign of AbstractPropertyModel would be necessary: to use the method setChainedModel on AbstractPropertyModel , we currently need to first have the object instanciated with a non null model.... Which is not what we may want...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.