chain the two models:

class numstringmodel extends abstractreadonlymodel<string> {

  private final imodel<integer> intmodel;


  public numstringmodel(imodel<integer> intmodel) { this.intmodel=intmodel; }

  public string getobject() {
       int val=intmodel.getobject();
       switch (val) ....

   }

   public void detach() {
         intmodel.detach();
    }
}


add(new label(.., new numstringmodel(new propertymodel(...

-igor

On Tue, Nov 17, 2009 at 9: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 ?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to