You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by mnwicket <le...@gmail.com> on 2008/04/22 02:30:58 UTC

1.4 Generics

Ok, so I starting messing around with the new generics version of
wicket....and I guess I was a little confused as to how many generics there
are.  Silly question is when people are doing development are they turning
off all generic warnings in eclipse...that is if you are using eclipse?

I only ask because I come across components like TextField that takes a
ResourceModel...I understand why the ResourceModel would use a generic but
in this case am I forced to put <String> on the TextField.

Another example is AjaxButton that is being added to a form, what generic do
I use here?  The forms object model type?  What if the form doesn't have a
model, say it is using a ValueMap that is a global member of the form...ie
I've seen this usage in some login example of wicket.

Just looking for some guidance here guys. 
-- 
View this message in context: http://www.nabble.com/1.4-Generics-tp16819308p16819308.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: 1.4 Generics

Posted by mnwicket <le...@gmail.com>.
So I guess when it comes down to it, if you plan on using wicket generics be
prepared to either right a lot of code that doesn't really make sense or
turn off all warnings for generics in your favorite ide.



Johan Compagner wrote:
> 
> this is fine yes:
> 
> TextField<String> tf = new TextField<String>(new
> ResourceModel<String>("key"));
> 
> the tf.getModel() returns a Model<String> else it cant and getModelObject
> also returns a String.
> 
> But i agree for a Button if you dont give a model to it it doesn't make
> sense
> But if you give a model it does make sense.
> 
> But for a Textfield it makes sense that you generify it even without a
> model
> because it does inherit the model from its parent..
> 
> so yes its a bit of a split what is nice and what you want to do.
> 
> johan
> 
> 
> On Tue, Apr 22, 2008 at 3:28 PM, mnwicket <le...@gmail.com> wrote:
> 
>>
>> Thanks Igor....not sure if you really answered what I was getting at
>> though.
>> I understand generics however there are cases in wicket where I'm
>> wondering
>> what is best practices.
>>
>> ie, using your example, a TextField using a ResourceModel, which way
>> would
>> you go;
>>
>> TextField<String> tf = new TextField<String>(new
>> ResourceModel<String>("key"));
>>
>> or just
>>
>> TextField tf = new TextField(new ResourceModel<String>("key"));
>>
>> And what do you use as a generic with the following code block;
>>
>> class MyForm extends Form {
>>
>>   public MyForm() {
>>
>>      add(new AjaxButton('id', this));
>>
>>   }
>>
>> }
>>
>>
>>
>> igor.vaynberg wrote:
>> >
>> > generic type on Component represents the type of the modelobject that
>> > component will hold.
>> >
>> > eg TextField<Integer> tf=new TextField<Integer>(...);
>> > means that tf.getModelObject() is of type Integer
>> >
>> > -igor
>> >
>> >
>> > On Mon, Apr 21, 2008 at 5:30 PM, mnwicket <le...@gmail.com> wrote:
>> >>
>> >>  Ok, so I starting messing around with the new generics version of
>> >>  wicket....and I guess I was a little confused as to how many generics
>> >> there
>> >>  are.  Silly question is when people are doing development are they
>> >> turning
>> >>  off all generic warnings in eclipse...that is if you are using
>> eclipse?
>> >>
>> >>  I only ask because I come across components like TextField that takes
>> a
>> >>  ResourceModel...I understand why the ResourceModel would use a
>> generic
>> >> but
>> >>  in this case am I forced to put <String> on the TextField.
>> >>
>> >>  Another example is AjaxButton that is being added to a form, what
>> >> generic do
>> >>  I use here?  The forms object model type?  What if the form doesn't
>> have
>> >> a
>> >>  model, say it is using a ValueMap that is a global member of the
>> >> form...ie
>> >>  I've seen this usage in some login example of wicket.
>> >>
>> >>  Just looking for some guidance here guys.
>> >>  --
>> >>  View this message in context:
>> >> http://www.nabble.com/1.4-Generics-tp16819308p16819308.html
>> >>  Sent from the Wicket - Dev mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/1.4-Generics-tp16819308p16824264.html
>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/1.4-Generics-tp16819308p16834717.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: 1.4 Generics

Posted by John Patterson <jd...@gmail.com>.
Depending on the degree of analness or laziness you can so easily  
create subclasses like I have here to save myself some keystrokes.

public class Container extends WebMarkupContainer<Object>
{
	public Container(String id)
	{
		super(id);
		setOutputMarkupPlaceholderTag(true);
	}
}

On 24 Apr 2008, at 20:52, mnwicket wrote:

>
> I'm glad to see I'm not the only anal developer that hates to see  
> warnings in
> my ide..:)
>
>
> Patrick Angeles wrote:
>>
>> How often do people give models to components like Buttons and Links?
>> Maybe the devs can consider alternate versions of these components  
>> that
>> aren't generic and don't take a model (or assume  
>> IModel&lt;Object&gt;).
>>
>> My code is littered with Link&lt;Object&gt; declarations just to  
>> get rid
>> of the compiler warnings :)
>>
>>
>>
>>
>>
>> Johan Compagner wrote:
>>>
>>> this is fine yes:
>>>
>>> TextField<String> tf = new TextField<String>(new
>>> ResourceModel<String>("key"));
>>>
>>> the tf.getModel() returns a Model<String> else it cant and  
>>> getModelObject
>>> also returns a String.
>>>
>>> But i agree for a Button if you dont give a model to it it  
>>> doesn't make
>>> sense
>>> But if you give a model it does make sense.
>>>
>>> But for a Textfield it makes sense that you generify it even  
>>> without a
>>> model
>>> because it does inherit the model from its parent..
>>>
>>> so yes its a bit of a split what is nice and what you want to do.
>>>
>>> johan
>>>
>>>
>>> On Tue, Apr 22, 2008 at 3:28 PM, mnwicket <le...@gmail.com> wrote:
>>>
>>>>
>>>> Thanks Igor....not sure if you really answered what I was  
>>>> getting at
>>>> though.
>>>> I understand generics however there are cases in wicket where I'm
>>>> wondering
>>>> what is best practices.
>>>>
>>>> ie, using your example, a TextField using a ResourceModel, which  
>>>> way
>>>> would
>>>> you go;
>>>>
>>>> TextField<String> tf = new TextField<String>(new
>>>> ResourceModel<String>("key"));
>>>>
>>>> or just
>>>>
>>>> TextField tf = new TextField(new ResourceModel<String>("key"));
>>>>
>>>> And what do you use as a generic with the following code block;
>>>>
>>>> class MyForm extends Form {
>>>>
>>>>   public MyForm() {
>>>>
>>>>      add(new AjaxButton('id', this));
>>>>
>>>>   }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> igor.vaynberg wrote:
>>>>>
>>>>> generic type on Component represents the type of the  
>>>>> modelobject that
>>>>> component will hold.
>>>>>
>>>>> eg TextField<Integer> tf=new TextField<Integer>(...);
>>>>> means that tf.getModelObject() is of type Integer
>>>>>
>>>>> -igor
>>>>>
>>>>>
>>>>> On Mon, Apr 21, 2008 at 5:30 PM, mnwicket <le...@gmail.com>  
>>>>> wrote:
>>>>>>
>>>>>>  Ok, so I starting messing around with the new generics  
>>>>>> version of
>>>>>>  wicket....and I guess I was a little confused as to how many
>>>> generics
>>>>>> there
>>>>>>  are.  Silly question is when people are doing development are  
>>>>>> they
>>>>>> turning
>>>>>>  off all generic warnings in eclipse...that is if you are using
>>>> eclipse?
>>>>>>
>>>>>>  I only ask because I come across components like TextField that
>>>> takes
>>>> a
>>>>>>  ResourceModel...I understand why the ResourceModel would use a
>>>> generic
>>>>>> but
>>>>>>  in this case am I forced to put <String> on the TextField.
>>>>>>
>>>>>>  Another example is AjaxButton that is being added to a form,  
>>>>>> what
>>>>>> generic do
>>>>>>  I use here?  The forms object model type?  What if the form  
>>>>>> doesn't
>>>> have
>>>>>> a
>>>>>>  model, say it is using a ValueMap that is a global member of the
>>>>>> form...ie
>>>>>>  I've seen this usage in some login example of wicket.
>>>>>>
>>>>>>  Just looking for some guidance here guys.
>>>>>>  --
>>>>>>  View this message in context:
>>>>>> http://www.nabble.com/1.4-Generics-tp16819308p16819308.html
>>>>>>  Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/1.4-Generics-tp16819308p16824264.html
>>>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/1.4-Generics- 
> tp16819308p16850502.html
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>


Re: 1.4 Generics

Posted by Patrick Angeles <pa...@inertiabev.com>.
Heh. It's not just about being anal... I feel like those warnings somehow
slow the IDE down... plus it makes the code harder to read b/c of
highlighting. But you don't want to turn it off because you'll forget about
them, and if you're using generics for other things, you will want to see
those warnings.

Give it some time, they'll iron out the API issues. They could do things
like:

public class Button
{
  public static  Button instance(String id) { return new Button(id); }
  public static <T> Button<T> instance (String id, IModel<T> model) { return
new Button<T>(id, model);}
}

So then the API call would be:

component.add(Button.instance(id));
component.add(Button.instance(id, new MyStringModel()) ;

... etc.

Just one way to do it...



mnwicket wrote:
> 
> I'm glad to see I'm not the only anal developer that hates to see warnings
> in my ide..:)
> 
> 
> Patrick Angeles wrote:
>> 
>> How often do people give models to components like Buttons and Links?
>> Maybe the devs can consider alternate versions of these components that
>> aren't generic and don't take a model (or assume IModel&lt;Object&gt;).
>> 
>> My code is littered with Link&lt;Object&gt; declarations just to get rid
>> of the compiler warnings :)
>> 
>> 
>> 
>> 
>> 
>> Johan Compagner wrote:
>>> 
>>> this is fine yes:
>>> 
>>> TextField<String> tf = new TextField<String>(new
>>> ResourceModel<String>("key"));
>>> 
>>> the tf.getModel() returns a Model<String> else it cant and
>>> getModelObject
>>> also returns a String.
>>> 
>>> But i agree for a Button if you dont give a model to it it doesn't make
>>> sense
>>> But if you give a model it does make sense.
>>> 
>>> But for a Textfield it makes sense that you generify it even without a
>>> model
>>> because it does inherit the model from its parent..
>>> 
>>> so yes its a bit of a split what is nice and what you want to do.
>>> 
>>> johan
>>> 
>>> 
>>> On Tue, Apr 22, 2008 at 3:28 PM, mnwicket <le...@gmail.com> wrote:
>>> 
>>>>
>>>> Thanks Igor....not sure if you really answered what I was getting at
>>>> though.
>>>> I understand generics however there are cases in wicket where I'm
>>>> wondering
>>>> what is best practices.
>>>>
>>>> ie, using your example, a TextField using a ResourceModel, which way
>>>> would
>>>> you go;
>>>>
>>>> TextField<String> tf = new TextField<String>(new
>>>> ResourceModel<String>("key"));
>>>>
>>>> or just
>>>>
>>>> TextField tf = new TextField(new ResourceModel<String>("key"));
>>>>
>>>> And what do you use as a generic with the following code block;
>>>>
>>>> class MyForm extends Form {
>>>>
>>>>   public MyForm() {
>>>>
>>>>      add(new AjaxButton('id', this));
>>>>
>>>>   }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> igor.vaynberg wrote:
>>>> >
>>>> > generic type on Component represents the type of the modelobject that
>>>> > component will hold.
>>>> >
>>>> > eg TextField<Integer> tf=new TextField<Integer>(...);
>>>> > means that tf.getModelObject() is of type Integer
>>>> >
>>>> > -igor
>>>> >
>>>> >
>>>> > On Mon, Apr 21, 2008 at 5:30 PM, mnwicket <le...@gmail.com> wrote:
>>>> >>
>>>> >>  Ok, so I starting messing around with the new generics version of
>>>> >>  wicket....and I guess I was a little confused as to how many
>>>> generics
>>>> >> there
>>>> >>  are.  Silly question is when people are doing development are they
>>>> >> turning
>>>> >>  off all generic warnings in eclipse...that is if you are using
>>>> eclipse?
>>>> >>
>>>> >>  I only ask because I come across components like TextField that
>>>> takes
>>>> a
>>>> >>  ResourceModel...I understand why the ResourceModel would use a
>>>> generic
>>>> >> but
>>>> >>  in this case am I forced to put <String> on the TextField.
>>>> >>
>>>> >>  Another example is AjaxButton that is being added to a form, what
>>>> >> generic do
>>>> >>  I use here?  The forms object model type?  What if the form doesn't
>>>> have
>>>> >> a
>>>> >>  model, say it is using a ValueMap that is a global member of the
>>>> >> form...ie
>>>> >>  I've seen this usage in some login example of wicket.
>>>> >>
>>>> >>  Just looking for some guidance here guys.
>>>> >>  --
>>>> >>  View this message in context:
>>>> >> http://www.nabble.com/1.4-Generics-tp16819308p16819308.html
>>>> >>  Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>>> >>
>>>> >>
>>>> >
>>>> >
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/1.4-Generics-tp16819308p16824264.html
>>>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>>>
>>>>
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/1.4-Generics-tp16819308p16851313.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: 1.4 Generics

Posted by mnwicket <le...@gmail.com>.
I'm glad to see I'm not the only anal developer that hates to see warnings in
my ide..:)


Patrick Angeles wrote:
> 
> How often do people give models to components like Buttons and Links?
> Maybe the devs can consider alternate versions of these components that
> aren't generic and don't take a model (or assume IModel&lt;Object&gt;).
> 
> My code is littered with Link&lt;Object&gt; declarations just to get rid
> of the compiler warnings :)
> 
> 
> 
> 
> 
> Johan Compagner wrote:
>> 
>> this is fine yes:
>> 
>> TextField<String> tf = new TextField<String>(new
>> ResourceModel<String>("key"));
>> 
>> the tf.getModel() returns a Model<String> else it cant and getModelObject
>> also returns a String.
>> 
>> But i agree for a Button if you dont give a model to it it doesn't make
>> sense
>> But if you give a model it does make sense.
>> 
>> But for a Textfield it makes sense that you generify it even without a
>> model
>> because it does inherit the model from its parent..
>> 
>> so yes its a bit of a split what is nice and what you want to do.
>> 
>> johan
>> 
>> 
>> On Tue, Apr 22, 2008 at 3:28 PM, mnwicket <le...@gmail.com> wrote:
>> 
>>>
>>> Thanks Igor....not sure if you really answered what I was getting at
>>> though.
>>> I understand generics however there are cases in wicket where I'm
>>> wondering
>>> what is best practices.
>>>
>>> ie, using your example, a TextField using a ResourceModel, which way
>>> would
>>> you go;
>>>
>>> TextField<String> tf = new TextField<String>(new
>>> ResourceModel<String>("key"));
>>>
>>> or just
>>>
>>> TextField tf = new TextField(new ResourceModel<String>("key"));
>>>
>>> And what do you use as a generic with the following code block;
>>>
>>> class MyForm extends Form {
>>>
>>>   public MyForm() {
>>>
>>>      add(new AjaxButton('id', this));
>>>
>>>   }
>>>
>>> }
>>>
>>>
>>>
>>> igor.vaynberg wrote:
>>> >
>>> > generic type on Component represents the type of the modelobject that
>>> > component will hold.
>>> >
>>> > eg TextField<Integer> tf=new TextField<Integer>(...);
>>> > means that tf.getModelObject() is of type Integer
>>> >
>>> > -igor
>>> >
>>> >
>>> > On Mon, Apr 21, 2008 at 5:30 PM, mnwicket <le...@gmail.com> wrote:
>>> >>
>>> >>  Ok, so I starting messing around with the new generics version of
>>> >>  wicket....and I guess I was a little confused as to how many
>>> generics
>>> >> there
>>> >>  are.  Silly question is when people are doing development are they
>>> >> turning
>>> >>  off all generic warnings in eclipse...that is if you are using
>>> eclipse?
>>> >>
>>> >>  I only ask because I come across components like TextField that
>>> takes
>>> a
>>> >>  ResourceModel...I understand why the ResourceModel would use a
>>> generic
>>> >> but
>>> >>  in this case am I forced to put <String> on the TextField.
>>> >>
>>> >>  Another example is AjaxButton that is being added to a form, what
>>> >> generic do
>>> >>  I use here?  The forms object model type?  What if the form doesn't
>>> have
>>> >> a
>>> >>  model, say it is using a ValueMap that is a global member of the
>>> >> form...ie
>>> >>  I've seen this usage in some login example of wicket.
>>> >>
>>> >>  Just looking for some guidance here guys.
>>> >>  --
>>> >>  View this message in context:
>>> >> http://www.nabble.com/1.4-Generics-tp16819308p16819308.html
>>> >>  Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>> >>
>>> >>
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/1.4-Generics-tp16819308p16824264.html
>>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>>
>>>
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/1.4-Generics-tp16819308p16850502.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: 1.4 Generics

Posted by Peter Ertl <pe...@gmx.net>.
I suggest using Link<Void> when not using a model (-> java.lang.Void)



Am 23.04.2008 um 19:14 schrieb Igor Vaynberg:

> right. if you dont use the model inside a component then the generic
> is pretty useless, so either do not declare it and add @SupressWarning
> or simply Link<Object>. I often use Link with model object, so for me
> the generic makes sense. It is just too bad java doesnt have a
> shortcut to disable the generic without warnings so you can do Link<?>
> foo=new Link<?>(...)
>
> -igor
>
>
> On Wed, Apr 23, 2008 at 10:08 AM, Patrick Angeles
> <pa...@inertiabev.com> wrote:
>>
>> How often do people give models to components like Buttons and  
>> Links? Maybe
>> the devs can consider alternate versions of these components that  
>> aren't
>> generic and don't take a model (or assume IModel).
>>
>> My code is littered with Link declarations just to get rid of the  
>> compiler
>> warnings :)
>>
>>
>>
>>
>>
>>
>>
>> Johan Compagner wrote:
>>>
>>> this is fine yes:
>>>
>>> TextField<String> tf = new TextField<String>(new
>>> ResourceModel<String>("key"));
>>>
>>> the tf.getModel() returns a Model<String> else it cant and  
>>> getModelObject
>>> also returns a String.
>>>
>>> But i agree for a Button if you dont give a model to it it doesn't  
>>> make
>>> sense
>>> But if you give a model it does make sense.
>>>
>>> But for a Textfield it makes sense that you generify it even  
>>> without a
>>> model
>>> because it does inherit the model from its parent..
>>>
>>> so yes its a bit of a split what is nice and what you want to do.
>>>
>>> johan
>>>
>>>
>>> On Tue, Apr 22, 2008 at 3:28 PM, mnwicket <le...@gmail.com> wrote:
>>>
>>>>
>>>> Thanks Igor....not sure if you really answered what I was getting  
>>>> at
>>>> though.
>>>> I understand generics however there are cases in wicket where I'm
>>>> wondering
>>>> what is best practices.
>>>>
>>>> ie, using your example, a TextField using a ResourceModel, which  
>>>> way
>>>> would
>>>> you go;
>>>>
>>>> TextField<String> tf = new TextField<String>(new
>>>> ResourceModel<String>("key"));
>>>>
>>>> or just
>>>>
>>>> TextField tf = new TextField(new ResourceModel<String>("key"));
>>>>
>>>> And what do you use as a generic with the following code block;
>>>>
>>>> class MyForm extends Form {
>>>>
>>>> public MyForm() {
>>>>
>>>>   add(new AjaxButton('id', this));
>>>>
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> igor.vaynberg wrote:
>>>>>
>>>>> generic type on Component represents the type of the modelobject  
>>>>> that
>>>>> component will hold.
>>>>>
>>>>> eg TextField<Integer> tf=new TextField<Integer>(...);
>>>>> means that tf.getModelObject() is of type Integer
>>>>>
>>>>> -igor
>>>>>
>>>>>
>>>>> On Mon, Apr 21, 2008 at 5:30 PM, mnwicket <le...@gmail.com>  
>>>>> wrote:
>>>>>>
>>>>>> Ok, so I starting messing around with the new generics version of
>>>>>> wicket....and I guess I was a little confused as to how many  
>>>>>> generics
>>>>>> there
>>>>>> are.  Silly question is when people are doing development are  
>>>>>> they
>>>>>> turning
>>>>>> off all generic warnings in eclipse...that is if you are using
>>>> eclipse?
>>>>>>
>>>>>> I only ask because I come across components like TextField that  
>>>>>> takes
>>>> a
>>>>>> ResourceModel...I understand why the ResourceModel would use a
>>>> generic
>>>>>> but
>>>>>> in this case am I forced to put <String> on the TextField.
>>>>>>
>>>>>> Another example is AjaxButton that is being added to a form, what
>>>>>> generic do
>>>>>> I use here?  The forms object model type?  What if the form  
>>>>>> doesn't
>>>> have
>>>>>> a
>>>>>> model, say it is using a ValueMap that is a global member of the
>>>>>> form...ie
>>>>>> I've seen this usage in some login example of wicket.
>>>>>>
>>>>>> Just looking for some guidance here guys.
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/1.4-Generics-tp16819308p16819308.html
>>>>>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/1.4-Generics-tp16819308p16824264.html
>>>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>> --
>> View this message in context: http://www.nabble.com/1.4-Generics-tp16819308p16834716.html
>>
>>
>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>
>>


Re: 1.4 Generics

Posted by Jonathan Locke <jo...@gmail.com>.

if it works completely, that definitely belongs in our FAQ.  nice trick.


igor.vaynberg wrote:
> 
> hmm, interesting approach, thanks!
> 
> -igor
> 
> 
> On Wed, Apr 23, 2008 at 12:58 PM, Peter Ertl <pe...@gmx.net> wrote:
>> I suggest using Link<Void> when not using a model (-> java.lang.Void)
>>
>>
>>
>>  Am 23.04.2008 um 19:14 schrieb Igor Vaynberg:
>>
>>
>>
>>
>> > right. if you dont use the model inside a component then the generic
>> > is pretty useless, so either do not declare it and add @SupressWarning
>> > or simply Link. I often use Link with model object, so for me
>> > the generic makes sense. It is just too bad java doesnt have a
>> > shortcut to disable the generic without warnings so you can do Link<?>
>> > foo=new Link<?>(...)
>> >
>> > -igor
>> >
>> >
>> > On Wed, Apr 23, 2008 at 10:08 AM, Patrick Angeles
>> > <pa...@inertiabev.com> wrote:
>> >
>> > >
>> > > How often do people give models to components like Buttons and Links?
>> Maybe
>> > > the devs can consider alternate versions of these components that
>> aren't
>> > > generic and don't take a model (or assume IModel).
>> > >
>> > > My code is littered with Link declarations just to get rid of the
>> compiler
>> > > warnings :)
>> > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > > Johan Compagner wrote:
>> > >
>> > > >
>> > > > this is fine yes:
>> > > >
>> > > > TextField<String> tf = new TextField<String>(new
>> > > > ResourceModel<String>("key"));
>> > > >
>> > > > the tf.getModel() returns a Model<String> else it cant and
>> getModelObject
>> > > > also returns a String.
>> > > >
>> > > > But i agree for a Button if you dont give a model to it it doesn't
>> make
>> > > > sense
>> > > > But if you give a model it does make sense.
>> > > >
>> > > > But for a Textfield it makes sense that you generify it even
>> without a
>> > > > model
>> > > > because it does inherit the model from its parent..
>> > > >
>> > > > so yes its a bit of a split what is nice and what you want to do.
>> > > >
>> > > > johan
>> > > >
>> > > >
>> > > > On Tue, Apr 22, 2008 at 3:28 PM, mnwicket <le...@gmail.com>
>> wrote:
>> > > >
>> > > >
>> > > > >
>> > > > > Thanks Igor....not sure if you really answered what I was getting
>> at
>> > > > > though.
>> > > > > I understand generics however there are cases in wicket where I'm
>> > > > > wondering
>> > > > > what is best practices.
>> > > > >
>> > > > > ie, using your example, a TextField using a ResourceModel, which
>> way
>> > > > > would
>> > > > > you go;
>> > > > >
>> > > > > TextField<String> tf = new TextField<String>(new
>> > > > > ResourceModel<String>("key"));
>> > > > >
>> > > > > or just
>> > > > >
>> > > > > TextField tf = new TextField(new ResourceModel<String>("key"));
>> > > > >
>> > > > > And what do you use as a generic with the following code block;
>> > > > >
>> > > > > class MyForm extends Form {
>> > > > >
>> > > > > public MyForm() {
>> > > > >
>> > > > >   add(new AjaxButton('id', this));
>> > > > >
>> > > > > }
>> > > > >
>> > > > > }
>> > > > >
>> > > > >
>> > > > >
>> > > > > igor.vaynberg wrote:
>> > > > >
>> > > > > >
>> > > > > > generic type on Component represents the type of the
>> modelobject
>> that
>> > > > > > component will hold.
>> > > > > >
>> > > > > > eg TextField<Integer> tf=new TextField<Integer>(...);
>> > > > > > means that tf.getModelObject() is of type Integer
>> > > > > >
>> > > > > > -igor
>> > > > > >
>> > > > > >
>> > > > > > On Mon, Apr 21, 2008 at 5:30 PM, mnwicket <le...@gmail.com>
>> wrote:
>> > > > > >
>> > > > > > >
>> > > > > > > Ok, so I starting messing around with the new generics
>> version
>> of
>> > > > > > > wicket....and I guess I was a little confused as to how many
>> generics
>> > > > > > > there
>> > > > > > > are.  Silly question is when people are doing development are
>> they
>> > > > > > > turning
>> > > > > > > off all generic warnings in eclipse...that is if you are
>> using
>> > > > > > >
>> > > > > >
>> > > > > eclipse?
>> > > > >
>> > > > > >
>> > > > > > >
>> > > > > > > I only ask because I come across components like TextField
>> that
>> takes
>> > > > > > >
>> > > > > >
>> > > > > a
>> > > > >
>> > > > > >
>> > > > > > > ResourceModel...I understand why the ResourceModel would use
>> a
>> > > > > > >
>> > > > > >
>> > > > > generic
>> > > > >
>> > > > > >
>> > > > > > > but
>> > > > > > > in this case am I forced to put <String> on the TextField.
>> > > > > > >
>> > > > > > > Another example is AjaxButton that is being added to a form,
>> what
>> > > > > > > generic do
>> > > > > > > I use here?  The forms object model type?  What if the form
>> doesn't
>> > > > > > >
>> > > > > >
>> > > > > have
>> > > > >
>> > > > > >
>> > > > > > > a
>> > > > > > > model, say it is using a ValueMap that is a global member of
>> the
>> > > > > > > form...ie
>> > > > > > > I've seen this usage in some login example of wicket.
>> > > > > > >
>> > > > > > > Just looking for some guidance here guys.
>> > > > > > > --
>> > > > > > > View this message in context:
>> > > > > > > http://www.nabble.com/1.4-Generics-tp16819308p16819308.html
>> > > > > > > Sent from the Wicket - Dev mailing list archive at
>> Nabble.com.
>> > > > > > >
>> > > > > > >
>> > > > > > >
>> > > > > >
>> > > > > >
>> > > > > >
>> > > > >
>> > > > > --
>> > > > > View this message in context:
>> > > > > http://www.nabble.com/1.4-Generics-tp16819308p16824264.html
>> > > > > Sent from the Wicket - Dev mailing list archive at Nabble.com.
>> > > > >
>> > > > >
>> > > > >
>> > > >
>> > > >
>> > > >
>> > >
>> > > --
>> > > View this message in context:
>> http://www.nabble.com/1.4-Generics-tp16819308p16834716.html
>> > >
>> > >
>> > > Sent from the Wicket - Dev mailing list archive at Nabble.com.
>> > >
>> > >
>> > >
>> >
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/1.4-Generics-tp16819308p16924572.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: 1.4 Generics

Posted by Igor Vaynberg <ig...@gmail.com>.
hmm, interesting approach, thanks!

-igor


On Wed, Apr 23, 2008 at 12:58 PM, Peter Ertl <pe...@gmx.net> wrote:
> I suggest using Link<Void> when not using a model (-> java.lang.Void)
>
>
>
>  Am 23.04.2008 um 19:14 schrieb Igor Vaynberg:
>
>
>
>
> > right. if you dont use the model inside a component then the generic
> > is pretty useless, so either do not declare it and add @SupressWarning
> > or simply Link<Object>. I often use Link with model object, so for me
> > the generic makes sense. It is just too bad java doesnt have a
> > shortcut to disable the generic without warnings so you can do Link<?>
> > foo=new Link<?>(...)
> >
> > -igor
> >
> >
> > On Wed, Apr 23, 2008 at 10:08 AM, Patrick Angeles
> > <pa...@inertiabev.com> wrote:
> >
> > >
> > > How often do people give models to components like Buttons and Links?
> Maybe
> > > the devs can consider alternate versions of these components that aren't
> > > generic and don't take a model (or assume IModel).
> > >
> > > My code is littered with Link declarations just to get rid of the
> compiler
> > > warnings :)
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Johan Compagner wrote:
> > >
> > > >
> > > > this is fine yes:
> > > >
> > > > TextField<String> tf = new TextField<String>(new
> > > > ResourceModel<String>("key"));
> > > >
> > > > the tf.getModel() returns a Model<String> else it cant and
> getModelObject
> > > > also returns a String.
> > > >
> > > > But i agree for a Button if you dont give a model to it it doesn't
> make
> > > > sense
> > > > But if you give a model it does make sense.
> > > >
> > > > But for a Textfield it makes sense that you generify it even without a
> > > > model
> > > > because it does inherit the model from its parent..
> > > >
> > > > so yes its a bit of a split what is nice and what you want to do.
> > > >
> > > > johan
> > > >
> > > >
> > > > On Tue, Apr 22, 2008 at 3:28 PM, mnwicket <le...@gmail.com> wrote:
> > > >
> > > >
> > > > >
> > > > > Thanks Igor....not sure if you really answered what I was getting at
> > > > > though.
> > > > > I understand generics however there are cases in wicket where I'm
> > > > > wondering
> > > > > what is best practices.
> > > > >
> > > > > ie, using your example, a TextField using a ResourceModel, which way
> > > > > would
> > > > > you go;
> > > > >
> > > > > TextField<String> tf = new TextField<String>(new
> > > > > ResourceModel<String>("key"));
> > > > >
> > > > > or just
> > > > >
> > > > > TextField tf = new TextField(new ResourceModel<String>("key"));
> > > > >
> > > > > And what do you use as a generic with the following code block;
> > > > >
> > > > > class MyForm extends Form {
> > > > >
> > > > > public MyForm() {
> > > > >
> > > > >   add(new AjaxButton('id', this));
> > > > >
> > > > > }
> > > > >
> > > > > }
> > > > >
> > > > >
> > > > >
> > > > > igor.vaynberg wrote:
> > > > >
> > > > > >
> > > > > > generic type on Component represents the type of the modelobject
> that
> > > > > > component will hold.
> > > > > >
> > > > > > eg TextField<Integer> tf=new TextField<Integer>(...);
> > > > > > means that tf.getModelObject() is of type Integer
> > > > > >
> > > > > > -igor
> > > > > >
> > > > > >
> > > > > > On Mon, Apr 21, 2008 at 5:30 PM, mnwicket <le...@gmail.com>
> wrote:
> > > > > >
> > > > > > >
> > > > > > > Ok, so I starting messing around with the new generics version
> of
> > > > > > > wicket....and I guess I was a little confused as to how many
> generics
> > > > > > > there
> > > > > > > are.  Silly question is when people are doing development are
> they
> > > > > > > turning
> > > > > > > off all generic warnings in eclipse...that is if you are using
> > > > > > >
> > > > > >
> > > > > eclipse?
> > > > >
> > > > > >
> > > > > > >
> > > > > > > I only ask because I come across components like TextField that
> takes
> > > > > > >
> > > > > >
> > > > > a
> > > > >
> > > > > >
> > > > > > > ResourceModel...I understand why the ResourceModel would use a
> > > > > > >
> > > > > >
> > > > > generic
> > > > >
> > > > > >
> > > > > > > but
> > > > > > > in this case am I forced to put <String> on the TextField.
> > > > > > >
> > > > > > > Another example is AjaxButton that is being added to a form,
> what
> > > > > > > generic do
> > > > > > > I use here?  The forms object model type?  What if the form
> doesn't
> > > > > > >
> > > > > >
> > > > > have
> > > > >
> > > > > >
> > > > > > > a
> > > > > > > model, say it is using a ValueMap that is a global member of the
> > > > > > > form...ie
> > > > > > > I've seen this usage in some login example of wicket.
> > > > > > >
> > > > > > > Just looking for some guidance here guys.
> > > > > > > --
> > > > > > > View this message in context:
> > > > > > > http://www.nabble.com/1.4-Generics-tp16819308p16819308.html
> > > > > > > Sent from the Wicket - Dev mailing list archive at Nabble.com.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > > --
> > > > > View this message in context:
> > > > > http://www.nabble.com/1.4-Generics-tp16819308p16824264.html
> > > > > Sent from the Wicket - Dev mailing list archive at Nabble.com.
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> > > --
> > > View this message in context:
> http://www.nabble.com/1.4-Generics-tp16819308p16834716.html
> > >
> > >
> > > Sent from the Wicket - Dev mailing list archive at Nabble.com.
> > >
> > >
> > >
> >
>
>

Re: 1.4 Generics

Posted by Peter Ertl <pe...@gmx.net>.
I suggest using Link<Void> when not using a model (-> java.lang.Void)



Am 23.04.2008 um 19:14 schrieb Igor Vaynberg:

> right. if you dont use the model inside a component then the generic
> is pretty useless, so either do not declare it and add @SupressWarning
> or simply Link<Object>. I often use Link with model object, so for me
> the generic makes sense. It is just too bad java doesnt have a
> shortcut to disable the generic without warnings so you can do Link<?>
> foo=new Link<?>(...)
>
> -igor
>
>
> On Wed, Apr 23, 2008 at 10:08 AM, Patrick Angeles
> <pa...@inertiabev.com> wrote:
>>
>> How often do people give models to components like Buttons and  
>> Links? Maybe
>> the devs can consider alternate versions of these components that  
>> aren't
>> generic and don't take a model (or assume IModel).
>>
>> My code is littered with Link declarations just to get rid of the  
>> compiler
>> warnings :)
>>
>>
>>
>>
>>
>>
>>
>> Johan Compagner wrote:
>>>
>>> this is fine yes:
>>>
>>> TextField<String> tf = new TextField<String>(new
>>> ResourceModel<String>("key"));
>>>
>>> the tf.getModel() returns a Model<String> else it cant and  
>>> getModelObject
>>> also returns a String.
>>>
>>> But i agree for a Button if you dont give a model to it it doesn't  
>>> make
>>> sense
>>> But if you give a model it does make sense.
>>>
>>> But for a Textfield it makes sense that you generify it even  
>>> without a
>>> model
>>> because it does inherit the model from its parent..
>>>
>>> so yes its a bit of a split what is nice and what you want to do.
>>>
>>> johan
>>>
>>>
>>> On Tue, Apr 22, 2008 at 3:28 PM, mnwicket <le...@gmail.com> wrote:
>>>
>>>>
>>>> Thanks Igor....not sure if you really answered what I was getting  
>>>> at
>>>> though.
>>>> I understand generics however there are cases in wicket where I'm
>>>> wondering
>>>> what is best practices.
>>>>
>>>> ie, using your example, a TextField using a ResourceModel, which  
>>>> way
>>>> would
>>>> you go;
>>>>
>>>> TextField<String> tf = new TextField<String>(new
>>>> ResourceModel<String>("key"));
>>>>
>>>> or just
>>>>
>>>> TextField tf = new TextField(new ResourceModel<String>("key"));
>>>>
>>>> And what do you use as a generic with the following code block;
>>>>
>>>> class MyForm extends Form {
>>>>
>>>> public MyForm() {
>>>>
>>>>    add(new AjaxButton('id', this));
>>>>
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> igor.vaynberg wrote:
>>>>>
>>>>> generic type on Component represents the type of the modelobject  
>>>>> that
>>>>> component will hold.
>>>>>
>>>>> eg TextField<Integer> tf=new TextField<Integer>(...);
>>>>> means that tf.getModelObject() is of type Integer
>>>>>
>>>>> -igor
>>>>>
>>>>>
>>>>> On Mon, Apr 21, 2008 at 5:30 PM, mnwicket <le...@gmail.com>  
>>>>> wrote:
>>>>>>
>>>>>> Ok, so I starting messing around with the new generics version of
>>>>>> wicket....and I guess I was a little confused as to how many  
>>>>>> generics
>>>>>> there
>>>>>> are.  Silly question is when people are doing development are  
>>>>>> they
>>>>>> turning
>>>>>> off all generic warnings in eclipse...that is if you are using
>>>> eclipse?
>>>>>>
>>>>>> I only ask because I come across components like TextField that  
>>>>>> takes
>>>> a
>>>>>> ResourceModel...I understand why the ResourceModel would use a
>>>> generic
>>>>>> but
>>>>>> in this case am I forced to put <String> on the TextField.
>>>>>>
>>>>>> Another example is AjaxButton that is being added to a form, what
>>>>>> generic do
>>>>>> I use here?  The forms object model type?  What if the form  
>>>>>> doesn't
>>>> have
>>>>>> a
>>>>>> model, say it is using a ValueMap that is a global member of the
>>>>>> form...ie
>>>>>> I've seen this usage in some login example of wicket.
>>>>>>
>>>>>> Just looking for some guidance here guys.
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/1.4-Generics-tp16819308p16819308.html
>>>>>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/1.4-Generics-tp16819308p16824264.html
>>>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>> --
>> View this message in context: http://www.nabble.com/1.4-Generics-tp16819308p16834716.html
>>
>>
>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>
>>


Re: 1.4 Generics

Posted by Igor Vaynberg <ig...@gmail.com>.
right. if you dont use the model inside a component then the generic
is pretty useless, so either do not declare it and add @SupressWarning
or simply Link<Object>. I often use Link with model object, so for me
the generic makes sense. It is just too bad java doesnt have a
shortcut to disable the generic without warnings so you can do Link<?>
foo=new Link<?>(...)

-igor


On Wed, Apr 23, 2008 at 10:08 AM, Patrick Angeles
<pa...@inertiabev.com> wrote:
>
>  How often do people give models to components like Buttons and Links? Maybe
>  the devs can consider alternate versions of these components that aren't
>  generic and don't take a model (or assume IModel).
>
>  My code is littered with Link declarations just to get rid of the compiler
>  warnings :)
>
>
>
>
>
>
>
>  Johan Compagner wrote:
>  >
>  > this is fine yes:
>  >
>  > TextField<String> tf = new TextField<String>(new
>  > ResourceModel<String>("key"));
>  >
>  > the tf.getModel() returns a Model<String> else it cant and getModelObject
>  > also returns a String.
>  >
>  > But i agree for a Button if you dont give a model to it it doesn't make
>  > sense
>  > But if you give a model it does make sense.
>  >
>  > But for a Textfield it makes sense that you generify it even without a
>  > model
>  > because it does inherit the model from its parent..
>  >
>  > so yes its a bit of a split what is nice and what you want to do.
>  >
>  > johan
>  >
>  >
>  > On Tue, Apr 22, 2008 at 3:28 PM, mnwicket <le...@gmail.com> wrote:
>  >
>  >>
>  >> Thanks Igor....not sure if you really answered what I was getting at
>  >> though.
>  >> I understand generics however there are cases in wicket where I'm
>  >> wondering
>  >> what is best practices.
>  >>
>  >> ie, using your example, a TextField using a ResourceModel, which way
>  >> would
>  >> you go;
>  >>
>  >> TextField<String> tf = new TextField<String>(new
>  >> ResourceModel<String>("key"));
>  >>
>  >> or just
>  >>
>  >> TextField tf = new TextField(new ResourceModel<String>("key"));
>  >>
>  >> And what do you use as a generic with the following code block;
>  >>
>  >> class MyForm extends Form {
>  >>
>  >>   public MyForm() {
>  >>
>  >>      add(new AjaxButton('id', this));
>  >>
>  >>   }
>  >>
>  >> }
>  >>
>  >>
>  >>
>  >> igor.vaynberg wrote:
>  >> >
>  >> > generic type on Component represents the type of the modelobject that
>  >> > component will hold.
>  >> >
>  >> > eg TextField<Integer> tf=new TextField<Integer>(...);
>  >> > means that tf.getModelObject() is of type Integer
>  >> >
>  >> > -igor
>  >> >
>  >> >
>  >> > On Mon, Apr 21, 2008 at 5:30 PM, mnwicket <le...@gmail.com> wrote:
>  >> >>
>  >> >>  Ok, so I starting messing around with the new generics version of
>  >> >>  wicket....and I guess I was a little confused as to how many generics
>  >> >> there
>  >> >>  are.  Silly question is when people are doing development are they
>  >> >> turning
>  >> >>  off all generic warnings in eclipse...that is if you are using
>  >> eclipse?
>  >> >>
>  >> >>  I only ask because I come across components like TextField that takes
>  >> a
>  >> >>  ResourceModel...I understand why the ResourceModel would use a
>  >> generic
>  >> >> but
>  >> >>  in this case am I forced to put <String> on the TextField.
>  >> >>
>  >> >>  Another example is AjaxButton that is being added to a form, what
>  >> >> generic do
>  >> >>  I use here?  The forms object model type?  What if the form doesn't
>  >> have
>  >> >> a
>  >> >>  model, say it is using a ValueMap that is a global member of the
>  >> >> form...ie
>  >> >>  I've seen this usage in some login example of wicket.
>  >> >>
>  >> >>  Just looking for some guidance here guys.
>  >> >>  --
>  >> >>  View this message in context:
>  >> >> http://www.nabble.com/1.4-Generics-tp16819308p16819308.html
>  >> >>  Sent from the Wicket - Dev mailing list archive at Nabble.com.
>  >> >>
>  >> >>
>  >> >
>  >> >
>  >>
>  >> --
>  >> View this message in context:
>  >> http://www.nabble.com/1.4-Generics-tp16819308p16824264.html
>  >> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>  >>
>  >>
>  >
>  >
>
>  --
>  View this message in context: http://www.nabble.com/1.4-Generics-tp16819308p16834716.html
>
>
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>
>

Re: 1.4 Generics

Posted by Patrick Angeles <pa...@inertiabev.com>.
How often do people give models to components like Buttons and Links? Maybe
the devs can consider alternate versions of these components that aren't
generic and don't take a model (or assume IModel).

My code is littered with Link declarations just to get rid of the compiler
warnings :)





Johan Compagner wrote:
> 
> this is fine yes:
> 
> TextField<String> tf = new TextField<String>(new
> ResourceModel<String>("key"));
> 
> the tf.getModel() returns a Model<String> else it cant and getModelObject
> also returns a String.
> 
> But i agree for a Button if you dont give a model to it it doesn't make
> sense
> But if you give a model it does make sense.
> 
> But for a Textfield it makes sense that you generify it even without a
> model
> because it does inherit the model from its parent..
> 
> so yes its a bit of a split what is nice and what you want to do.
> 
> johan
> 
> 
> On Tue, Apr 22, 2008 at 3:28 PM, mnwicket <le...@gmail.com> wrote:
> 
>>
>> Thanks Igor....not sure if you really answered what I was getting at
>> though.
>> I understand generics however there are cases in wicket where I'm
>> wondering
>> what is best practices.
>>
>> ie, using your example, a TextField using a ResourceModel, which way
>> would
>> you go;
>>
>> TextField<String> tf = new TextField<String>(new
>> ResourceModel<String>("key"));
>>
>> or just
>>
>> TextField tf = new TextField(new ResourceModel<String>("key"));
>>
>> And what do you use as a generic with the following code block;
>>
>> class MyForm extends Form {
>>
>>   public MyForm() {
>>
>>      add(new AjaxButton('id', this));
>>
>>   }
>>
>> }
>>
>>
>>
>> igor.vaynberg wrote:
>> >
>> > generic type on Component represents the type of the modelobject that
>> > component will hold.
>> >
>> > eg TextField<Integer> tf=new TextField<Integer>(...);
>> > means that tf.getModelObject() is of type Integer
>> >
>> > -igor
>> >
>> >
>> > On Mon, Apr 21, 2008 at 5:30 PM, mnwicket <le...@gmail.com> wrote:
>> >>
>> >>  Ok, so I starting messing around with the new generics version of
>> >>  wicket....and I guess I was a little confused as to how many generics
>> >> there
>> >>  are.  Silly question is when people are doing development are they
>> >> turning
>> >>  off all generic warnings in eclipse...that is if you are using
>> eclipse?
>> >>
>> >>  I only ask because I come across components like TextField that takes
>> a
>> >>  ResourceModel...I understand why the ResourceModel would use a
>> generic
>> >> but
>> >>  in this case am I forced to put <String> on the TextField.
>> >>
>> >>  Another example is AjaxButton that is being added to a form, what
>> >> generic do
>> >>  I use here?  The forms object model type?  What if the form doesn't
>> have
>> >> a
>> >>  model, say it is using a ValueMap that is a global member of the
>> >> form...ie
>> >>  I've seen this usage in some login example of wicket.
>> >>
>> >>  Just looking for some guidance here guys.
>> >>  --
>> >>  View this message in context:
>> >> http://www.nabble.com/1.4-Generics-tp16819308p16819308.html
>> >>  Sent from the Wicket - Dev mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/1.4-Generics-tp16819308p16824264.html
>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/1.4-Generics-tp16819308p16834716.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: 1.4 Generics

Posted by Johan Compagner <jc...@gmail.com>.
this is fine yes:

TextField<String> tf = new TextField<String>(new
ResourceModel<String>("key"));

the tf.getModel() returns a Model<String> else it cant and getModelObject
also returns a String.

But i agree for a Button if you dont give a model to it it doesn't make
sense
But if you give a model it does make sense.

But for a Textfield it makes sense that you generify it even without a model
because it does inherit the model from its parent..

so yes its a bit of a split what is nice and what you want to do.

johan


On Tue, Apr 22, 2008 at 3:28 PM, mnwicket <le...@gmail.com> wrote:

>
> Thanks Igor....not sure if you really answered what I was getting at
> though.
> I understand generics however there are cases in wicket where I'm
> wondering
> what is best practices.
>
> ie, using your example, a TextField using a ResourceModel, which way would
> you go;
>
> TextField<String> tf = new TextField<String>(new
> ResourceModel<String>("key"));
>
> or just
>
> TextField tf = new TextField(new ResourceModel<String>("key"));
>
> And what do you use as a generic with the following code block;
>
> class MyForm extends Form {
>
>   public MyForm() {
>
>      add(new AjaxButton('id', this));
>
>   }
>
> }
>
>
>
> igor.vaynberg wrote:
> >
> > generic type on Component represents the type of the modelobject that
> > component will hold.
> >
> > eg TextField<Integer> tf=new TextField<Integer>(...);
> > means that tf.getModelObject() is of type Integer
> >
> > -igor
> >
> >
> > On Mon, Apr 21, 2008 at 5:30 PM, mnwicket <le...@gmail.com> wrote:
> >>
> >>  Ok, so I starting messing around with the new generics version of
> >>  wicket....and I guess I was a little confused as to how many generics
> >> there
> >>  are.  Silly question is when people are doing development are they
> >> turning
> >>  off all generic warnings in eclipse...that is if you are using
> eclipse?
> >>
> >>  I only ask because I come across components like TextField that takes
> a
> >>  ResourceModel...I understand why the ResourceModel would use a generic
> >> but
> >>  in this case am I forced to put <String> on the TextField.
> >>
> >>  Another example is AjaxButton that is being added to a form, what
> >> generic do
> >>  I use here?  The forms object model type?  What if the form doesn't
> have
> >> a
> >>  model, say it is using a ValueMap that is a global member of the
> >> form...ie
> >>  I've seen this usage in some login example of wicket.
> >>
> >>  Just looking for some guidance here guys.
> >>  --
> >>  View this message in context:
> >> http://www.nabble.com/1.4-Generics-tp16819308p16819308.html
> >>  Sent from the Wicket - Dev mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/1.4-Generics-tp16819308p16824264.html
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>
>

Re: 1.4 Generics

Posted by mnwicket <le...@gmail.com>.
Thanks Igor....not sure if you really answered what I was getting at though. 
I understand generics however there are cases in wicket where I'm wondering
what is best practices.

ie, using your example, a TextField using a ResourceModel, which way would
you go;

TextField<String> tf = new TextField<String>(new
ResourceModel<String>("key"));

or just

TextField tf = new TextField(new ResourceModel<String>("key"));

And what do you use as a generic with the following code block;

class MyForm extends Form {

   public MyForm() {

      add(new AjaxButton('id', this));

   }

}



igor.vaynberg wrote:
> 
> generic type on Component represents the type of the modelobject that
> component will hold.
> 
> eg TextField<Integer> tf=new TextField<Integer>(...);
> means that tf.getModelObject() is of type Integer
> 
> -igor
> 
> 
> On Mon, Apr 21, 2008 at 5:30 PM, mnwicket <le...@gmail.com> wrote:
>>
>>  Ok, so I starting messing around with the new generics version of
>>  wicket....and I guess I was a little confused as to how many generics
>> there
>>  are.  Silly question is when people are doing development are they
>> turning
>>  off all generic warnings in eclipse...that is if you are using eclipse?
>>
>>  I only ask because I come across components like TextField that takes a
>>  ResourceModel...I understand why the ResourceModel would use a generic
>> but
>>  in this case am I forced to put <String> on the TextField.
>>
>>  Another example is AjaxButton that is being added to a form, what
>> generic do
>>  I use here?  The forms object model type?  What if the form doesn't have
>> a
>>  model, say it is using a ValueMap that is a global member of the
>> form...ie
>>  I've seen this usage in some login example of wicket.
>>
>>  Just looking for some guidance here guys.
>>  --
>>  View this message in context:
>> http://www.nabble.com/1.4-Generics-tp16819308p16819308.html
>>  Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/1.4-Generics-tp16819308p16824264.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: 1.4 Generics

Posted by Igor Vaynberg <ig...@gmail.com>.
generic type on Component represents the type of the modelobject that
component will hold.

eg TextField<Integer> tf=new TextField<Integer>(...);
means that tf.getModelObject() is of type Integer

-igor


On Mon, Apr 21, 2008 at 5:30 PM, mnwicket <le...@gmail.com> wrote:
>
>  Ok, so I starting messing around with the new generics version of
>  wicket....and I guess I was a little confused as to how many generics there
>  are.  Silly question is when people are doing development are they turning
>  off all generic warnings in eclipse...that is if you are using eclipse?
>
>  I only ask because I come across components like TextField that takes a
>  ResourceModel...I understand why the ResourceModel would use a generic but
>  in this case am I forced to put <String> on the TextField.
>
>  Another example is AjaxButton that is being added to a form, what generic do
>  I use here?  The forms object model type?  What if the form doesn't have a
>  model, say it is using a ValueMap that is a global member of the form...ie
>  I've seen this usage in some login example of wicket.
>
>  Just looking for some guidance here guys.
>  --
>  View this message in context: http://www.nabble.com/1.4-Generics-tp16819308p16819308.html
>  Sent from the Wicket - Dev mailing list archive at Nabble.com.
>
>