commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Pratt <thechrispr...@gmail.com>
Subject Re: [BeanUtils] Debugging BeanMap
Date Fri, 11 Nov 2011 18:43:32 GMT
I simplified my test case and I think I may have found the culprit.  I was
expecting the BeanMap to handle dot notation properly, but it appears I was
mistaken.  The following doesn't seem to work:

  public static void main (String... args) throws ADKException, IOException {
    Student student = new Student();
    Map studmap = new BeanMap(student);
    studmap.put("id",4242);
    studmap.put("name.firstname","Chris");
    studmap.put("name.lastname","Pratt");
    student.dump();
  } //main


I get an IllegalArgumentException that Student has no property called
name.firstname.  Is there any way around this?  BeanMap isn't really useful
to me if it doesn't support the object hierarchy that a bean engenders?
  (*Chris*)

On Thu, Nov 10, 2011 at 5:06 PM, Maurizio Cucchiara
<mcucchiara@apache.org>wrote:

> I'm not sure this is what you are looking for, I'm assuming you are
> trying to write into the student bean, I hope this will be useful (it
> works on my side):
>
>    @Test
>    public void testBeanMap() throws Exception {
>         Student student = new Student();
>         BeanMap map = new BeanMap(student);
>        assertNotNull(map);
>        map.put("id", 1);
>        map.put("course", new Course("course name"));
>        assertEquals(1, student.getId());
>        assertEquals("course name",student.getCourse().getName());
>     }
>
>
> Twitter     :http://www.twitter.com/m_cucchiara
> G+          :https://plus.google.com/107903711540963855921
> Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
>
> Maurizio Cucchiara
>
>
>
> On 11 November 2011 01:51, Chris Pratt <thechrispratt@gmail.com> wrote:
> > StringMapAdaptor
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message