No casting is required.  Try this:

BaseClass baseObject = null;
DropDownChoice<BaseClass> dropDown = new DropDownChoice<BaseClass>("id");
dropDown.getChoiceRenderer().getDisplayValue(null);

This will compile (it won't run because you'll get an NPE if the
display value method doesn't accept null).  As I said, you don't have
to declare your local variable "dropDown" with type variable
wildcards.



On Sat, Jun 13, 2009 at 6:23 AM, Martin
Makundi<martin.maku...@koodaripalvelut.com> wrote:
> No. The compiler does not allow. If DropDownChoice is of type <?
> extends BaseClass> then the problem is that it assumes that
> getChoiceRenderer() is also of type <? extends BaseClass>. Now at
> runtime, because of the wildcard, I do not know what class I have, and
> I absolutely cannot use the renderer. The only workaround is to cast
> the renderer into <BaseClass> (which it actually is!!) and that works,
> but the warning remains.
>
> Tricky....
>
> **
> Martin
>
> 2009/6/13 James Carman <jcar...@carmanconsulting.com>:
>> But, the compiler only knows what you're allowed to do by the type of
>> the variable.  You do not need to declare your variables with the
>> wildcards.
>>
>> On Fri, Jun 12, 2009 at 6:31 PM, Cristi Manole<cristiman...@gmail.com> wrote:
>>> declaration is not the problem. from what i remember from generics (I might
>>> be wrong), you're not allowed to instantiate "generically". you have to tell
>>> the compiler exactly what type you want. at runtime it has no idea about
>>> generics.
>>>
>>> On Sat, Jun 13, 2009 at 12:41 AM, James Carman
>>> <ja...@carmanconsulting.com>wrote:
>>>
>>>> Just because the constructor is declared that way (with the ?) doesn't mean
>>>> you have to declare your variables that way.
>>>>
>>>> On Jun 12, 2009 4:43 PM, "Martin Makundi" <
>>>> martin.maku...@koodaripalvelut.com> wrote:
>>>>
>>>> > new DropDownChoice<BaseClass> ?
>>>>
>>>> Maybe ...
>>>>
>>>> **
>>>> Martin
>>>>
>>>> > > On Fri, Jun 12, 2009 at 6:06 AM, Martin > Makundi<
>>>> martin.maku...@koodaripalvelut.com> wrote: >>...
>>>>
>>>
>>>
>>>
>>> --
>>> Cristi Manole
>>>
>>> Nova Creator Software
>>> www.novacreator.com
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to