History | Log In     View a printable version of the current page.  

Issue Details (XML | Word | Printable)

Key: UBA-6840
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Janak Mulani
Reporter: Etienne Studer
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
ULCBase

Creating a custom cell renderer without an empty constructor does not work and no error message is displayed

Created: 29/Dec/05 11:56 PM   Updated: 29/Apr/08 04:19 PM
Component/s: core
Affects Version/s: ULC 6.0.3
Fix Version/s: UltraLightClient '08


 Description  « Hide
  • extend DefaultComboBoxCellRenderer
  • define a non-empty constructor
  • overwrite typeString and therefore define a own UIProxy component or
  • overwrite any or all of the ICellComponent methods
  • set the renderer on a combo box --> renderer is ignored (createBasicObject() and restoreState() are never called)

At least an error (or even a runtime exception) should be displayed explaining the situation.



 All   Comments   Change History      Sort Order:
Daniel Pfeifer - [24/Jul/06 02:34 PM ]
At the moment CellComponentTemplateStorage.createTemplate(ICellComponent c) is used to create
a template copy of cell renderer component, which is passed in. The template copy is created
via c.getClass().newInstance() but this does not work if
  • the class does not have a no-argument constructor
  • the class or it's no-argument constructor is not public
    If the former does not work, then createTemplate()tries to create a copy via
    c.getClass().getSuperclass().newInstance() but then, the template copy does not
    have the right type anymore.
    (Using ... getSuperclass().newInstance() acts as "workaround" if the c has an
    anonymous (and thus private) class type.

Currently there is no good point, where ULC could a give a hint to the programmer (such
as throwing an exception) in case this behaviour is undesired.

A possible solution would be to offer a new interface e.g.:
public interface ITemplateComponent {
ICellComponent createTemplateCopy();
}
An extension writer could make the cell component implement this interface and then
CellComponentTemplateStorage.createTemplate(ICellComponent c)
could try c.createTemplateCopy() if c implements ITemplateComponent. Otherwise it would
work as before.

Adding the new interface is considered as adding too much additional complexity for
a workaround and therefore it is rejected.


Etienne Studer - [24/Jul/06 05:53 PM ]
That's a bit disappointing, considering how much time I lost trying to debug the no-args issue. Having an explicit ITemplateComponent.createTemplateCopy() API would definitely be much cleaner and less error-prone. There could even be a smooth migration path using if(c instanceof ITemplateComponent){((ITemplateComponent) c).createTemplateCopy();...}else{...}

It seems that Canoo still does not make any attempts to make working with custom renderers any easier


Etienne Studer - [21/Mar/07 03:43 PM ]
Reopened as UBA-7182.

Marcel Rüedi - [17/Dec/07 12:37 PM ]
Alternative the ICellComponent Interface could be changed
public interface ICellComponent extends IProxy {
    public void copyAttributes(ICellComponent source);

    public ICellComponent copy();
    
    public boolean areAttributesEqual(ICellComponent component);
    
    public int attributesHashCode();
}

Migrating existing ICellComponents is easy, just add the following copy method

public ICellComponent copy() {
        ICellComponent newMy = new MyConstructor();
        newMy.copyAttributes(this);
        return newMy;
}

ICellComponents with non-default constructors can create the new Instance as needed


Marcel Rüedi - [17/Dec/07 12:40 PM ]
Another correction would be that the factory interface IComboBoxCellRenderer getComboBoxCellRendererComponent() returns a independent object that can be used without the risk of sideeffects.

Marcel Rüedi - [17/Dec/07 12:58 PM ]
For a minor release we can throw a exception if there is no accessible default-constructor and one of the methods of the ICellComponent interface or typeString is overwritten.

Daniel Grob - [29/Apr/08 04:13 PM ]
ULC now throws a connection if
  • a ICellComponent cannot be instanciated by Class.getInstance()
  • and the ICellComponent implements one of the following methods
    • typeString()
    • copyAttributes()
    • areAttributesEquals()
    • attributesHashCode()