This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 63356

Summary: no generic support for beans in form editor
Product: guibuilder Reporter: calvin <calvin>
Component: CodeAssignee: issues@guibuilder <issues>
Severity: blocker    
Priority: P3    
Version: 4.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description calvin 2005-08-30 16:38:41 UTC
If you use a custom bean that supports generics it is not possible to declare
the variable type with the generic.


You have created a gui component that shows a list of items. call it MyListViewer.

MyListViewer is a bean, but also supports generics. so you can instance it like

MyListViewer<SomeEntity> viewer = new MyListViewer<SomeEntity>();

But if you added MyListViewer to the palette and create it as a bean in the gui
editor, the editor will instance it as. 

MyListViewer viewer = new MyListViewer();

In the current Netbeans form editor you can create the creation statement
yourself (this is properly because you want to support sub classes of the bean)
but you cannot define the generic type so the best you can get from the form
editor as it is for now is.

MyListViewer viewer = new MyListViewer<SomeEntity>();


The current workaround i use for now is to create your own alias variable that
supports generics.

MyListViewer<SomeEntity> viewerAlias = (MyListViewer<SomeEntity>) viewer;

This makes is possible for me to use the bean and generics properties of the
bean at the same time. but it is a far from perfect solution.

Possible solutions:

Add a new property under "code" where you select the generic type of the bean.

I know that this is properly a rare situation, but as people begin using
generics the value of this enhancement will increase.

Comment 1 Jan Stola 2006-03-02 09:06:03 UTC
*** Issue 73072 has been marked as a duplicate of this issue. ***
Comment 2 Jan Stola 2006-03-02 09:12:51 UTC
I agree that there should be a support like this. We will return
to this issue once we switch NetBeans trunk builds to JDK 5.0
- that should be soon.

We will be able to recognize whether the bean is generyfied
and what are its type variables and will be able to provide a better

I know that we can implement this already using Reflection API,
but it seems a little weird to use Reflection classes
(like TypeVariable) via Reflection API ;-).
Comment 3 brviking 2006-03-02 16:42:52 UTC
Even being weird implement using Reflection, is a little effort to solve problem
that become very common, since own Sun is investing on migration (from 1.3 and
1.4 to 5.0).

At all, big projects moving to generics will use lots of custom controls, not
basic swing ones... On my own, I have at last one component extending each main
component from Swing, plus specialized ones (like CustomerSearcher,
AccountSearcher, and so on). All of these use a custom base component that is
being generified right now...

Is not possible to release a GUI editor with property for generic type based on
reflection until a more elegant solution is developed?

Comment 4 Tomas Pavek 2007-08-08 10:30:10 UTC
This has been already implemented for 6.0, see issue 77086.

*** This issue has been marked as a duplicate of 77086 ***