Well, you can't make a subclass a different parameterized type than it's parent. It won't work.
You should be using an Integer model for this and using a converter rather than a nested model to make it a string. That's what converters are for. -- Jeremy Thomerson http://www.wickettraining.com On Tue, Nov 17, 2009 at 11:11 PM, smallufo <[email protected]> wrote: > Hi all > > I've already converted most of my code from 1.3 to 1.4 , except this > situation : > > Label intToStringLabel = new Label("intToString" , new > PropertyModel(this , "integer") > { > @Override > public Object getObject() > { > int value = ((Integer) super.getObject()).intValue(); > > switch(value) > { > case 1: return "one"; > case 2: return "two"; > case 3: return "three"; > } > return ""; > } > }); > add(intToStringLabel); > > In the code , I want to output Integer of 1,2,3 to "one" , "two" and > "three" > > In the code , PropertyModel is not parameterized , so I change to : > new PropertyModel<Integer>(this , "integer") > and eclipse warns getObject() 's return type should be Integer > But what I want to return is String , not Integer . This doesn't work. > > OK , then , I change my code to > new PropertyModel<String>(this , "integer") > > and eclipse warns > ((Integer) super.getObject()).intValue(); > Cannot cast from String to Integer. > > I don't know what else can I do , How to parameterize this situation ? >
