I have trouble implementing the GridSelectionModel (using CheckBoxSelectionModel as an inspiration).
I'd like to create a RadioSelectionModel but I have a ClassCastException when I call my constructor.
Here's my class structure (If needed I put some code but I don't think that's necessary). I'm using list and sublist to show the classes and embedded classes :
class RadioSelectionModel < M > extends GridSelectionModel< M >
interface RadioColumnAppearance < M >
class RadioColumnDefaultAppearance < M >
interface RadioColumnStyle extends CssResource, ColumnHeaderStyles, GridDataTableStyles
interface RadioColumnResources extends ClientBundle
The RadioColumnAppearance
is link to RadioColumnDefaultAppearance
by a gwt.xml file with :
<replace-with
class="com.app.appearance.RadioColumnDefaultAppearance">
<when-type-is
class="com.app.grid.RadioSelectionModel.RadioColumnAppearance" />
</replace-with>
I happened to found that the ClassCastException
is when I call GWT.create( RadioColumnAppearance.class )
but I don't know what is exactly
the problem and how I can solve it
EDIT : Here's the RadioColumnDefaultAppearance code. I believe that the problem is in here because I only have the exception when I call GWT.create. About the error, it's a simple message I get in my browser console Uncaught java.lang.ClassCastException
:
public class RadioColumnDefaultAppearance < M > implements CheckBoxColumnAppearance< M >
{
public interface RadioColumnStyle extends CheckBoxColumnStyle
{
}
public interface RadioColumnResources extends ClientBundle
{
@Source( "/css/RadioColumn.css" )
RadioColumnStyle style();
@Source( "column.png" )
@ImageOptions( repeatStyle = RepeatStyle.Vertical )
ImageResource specialColumn();
@Source( "column_checked.png" )
@ImageOptions( repeatStyle = RepeatStyle.Vertical )
ImageResource specialColumnSelected();
}
private final RadioColumnResources resources;
private final RadioColumnStyle style;
public RadioColumnDefaultAppearance()
{
this( GWT.< RadioColumnResources > create( RadioColumnResources.class ) );
}
public RadioColumnDefaultAppearance( RadioColumnResources resources )
{
this.resources = resources;
this.style = this.resources.style();
StyleInjectorHelper.ensureInjected( style, true );
}
public void renderRadio( Context context, M value, SafeHtmlBuilder sb )
{
sb.appendHtmlConstant( "<div class='x-grid-row-checker'> </div>" );
}
}
Your RadioColumnDefaultAppearance does not implement the RadioColumnAppearance interface. If you want to define a default implementation for an interface, the class must implements that interface otherwise it would not possible to assign an instance of the implementation class to an interface reference.