You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by "Dan Haywood (JIRA)" <ji...@apache.org> on 2015/01/30 15:01:34 UTC
[jira] [Created] (ISIS-1022) Refactor IsisConverterLocator so that
the converters are facets.
Dan Haywood created ISIS-1022:
---------------------------------
Summary: Refactor IsisConverterLocator so that the converters are facets.
Key: ISIS-1022
URL: https://issues.apache.org/jira/browse/ISIS-1022
Project: Isis
Issue Type: Improvement
Components: Core, Viewer: Wicket
Affects Versions: core-1.8.0
Reporter: Dan Haywood
Assignee: Dan Haywood
Priority: Minor
Fix For: core-1.9.0
In ISIS-1012 we introduced the IsisConverterLocator class that inspects the ObjectSpecification and returns a suitable Wicket IConverter implementation.
The implementation of this is a big switch statement.
A better design would be for the IConverter to be made available through a suitable facet, probably as an extension of the existing ValueFacet. This would require updating the appropriate facet factories for all appropriate values.
Note that we don't want Isis to have a dependency on Wicket, and so Isis would need to define its own "parallel" (copy of) IConverter, and have the ValueFacet return this.
Then, in IsisConverterLocator, it would simply be a matter of adapting the Isis' IConverter into a Wicket IConverter.
The final implementation of IsisConverterLocator would be something like:
{code}
final ObjectSpecification objectSpecification = objectAdapter.getSpecification();
ValueFacet vf = objectSpecification.getFacet(ValueFacet.class)
if(vf == null) { return null; }
final org.apache.isis.core.metamodel.IConverter ic = vf.getConverter();
if (ic == null) { return null; }
return new org.apache.wicket.util.convert.IConverter() {
public Object convertToObject(String value, Locale locale) {
return ic.convertToObject(value, locale);
}
public String convertToString(C value, Locale locale) {
return ic.convertToString(value, locale);
}
};
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)