Results 1 to 4 of 4
  1. #1
    code4susant's Avatar
    code4susant is offline Member
    Join Date
    Feb 2009
    Location
    Athens,GA USA
    Posts
    2
    Rep Power
    0

    Default Binding Converter for an Array

    Suppose I have a model like below:

    Model{
    int[] order = new int[] {1,2,3,4};
    }

    I want to bind this to a textfield`s text property. I have written a converter extending org.jdesktop.beansbinding.Converter<Integer[],String>.

    But it is not working issuing a ClassCastException at the definition of the class.

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Note that an int[] cannot be implicitly or (explicitly) cast to an Integer[].

  3. #3
    code4susant's Avatar
    code4susant is offline Member
    Join Date
    Feb 2009
    Location
    Athens,GA USA
    Posts
    2
    Rep Power
    0

    Default

    Yes, I realized this later. When I used the converter as extending Converter<int[],String>, it worked. I was under the impression that while using generics I must use a class type rather than a primitive.

    Thanks for your help

  4. #4
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    5

    Default

    int is a primative; whereas int[] is not. You pass the int[] as a reference.
    My Hobby Project: LegacyClone

Similar Threads

  1. Question about early binding
    By Jary316 in forum New To Java
    Replies: 5
    Last Post: 12-17-2008, 06:12 AM
  2. [SOLVED] Key binding Q
    By playwin2 in forum New To Java
    Replies: 3
    Last Post: 11-04-2008, 06:04 AM
  3. Spring binding in jsp
    By Pierre Javason in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 05-05-2008, 12:21 PM
  4. Dynamic Binding
    By javarishi in forum New To Java
    Replies: 3
    Last Post: 04-09-2008, 11:17 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •