Confusion on constructor injection docs

View: New views
2 Messages — Rating Filter:   Alert me  

Confusion on constructor injection docs

by Dave Murray-Rust-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Firstly, thanks for a great framework!

I've just spent a while banging my head against constructor injection,  
and discovered it's because all of the involved attributes need to  
have a name parameter, so these forms don't work:

public class A {
        @Attribute
        String name
        public A( @Attribute String name ) { this.name = name; }
}
public class B {
        @Attribute(name="name")
        String name
        public B( @Attribute String name ) { this.name = name; }
}
public class C {
        @Attribute
        String name
        public C( @Attribute(name="name") String name ) { this.name = name; }
}

it has to be:

public class D {
        @Attribute(name="name")
        String name
        public D( @Attribute(name="name") String name ) { this.name = name; }
}

So I think the docs should make this clear, as the error message  
doesn't help immediately (e.g. "Annotations do not match for 'name' in  
class C").

Also, could it not default to looking at the field name?

Thanks!
dave

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support

Re: Confusion on constructor injection docs

by Niall Gallagher-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Thanks for the feedback, ill make sure to improve this. Also, I think I will add support for.

public class C {
   @Attribute
   String name
   public C( @Attribute(name="name") String name ) {
     this.name = name;
   }
}

Thanks,
Niall


--- On Wed, 10/7/09, Dave Murray-Rust <d.murray-rust@...> wrote:

> From: Dave Murray-Rust <d.murray-rust@...>
> Subject: [Simple-support] Confusion on constructor injection docs
> To: simple-support@...
> Date: Wednesday, October 7, 2009, 10:10 AM
> Firstly, thanks for a great
> framework!
>
> I've just spent a while banging my head against constructor
> injection, 
> and discovered it's because all of the involved attributes
> need to 
> have a name parameter, so these forms don't work:
>
> public class A {
>     @Attribute
>     String name
>     public A( @Attribute String name ) {
> this.name = name; }
> }
> public class B {
>     @Attribute(name="name")
>     String name
>     public B( @Attribute String name ) {
> this.name = name; }
> }
> public class C {
>     @Attribute
>     String name
>     public C( @Attribute(name="name") String
> name ) { this.name = name; }
> }
>
> it has to be:
>
> public class D {
>     @Attribute(name="name")
>     String name
>     public D( @Attribute(name="name") String
> name ) { this.name = name; }
> }
>
> So I think the docs should make this clear, as the error
> message 
> doesn't help immediately (e.g. "Annotations do not match
> for 'name' in 
> class C").
>
> Also, could it not default to looking at the field name?
>
> Thanks!
> dave
>
> --
> The University of Edinburgh is a charitable body,
> registered in
> Scotland, with registration number SC005336.
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference
> in SF, CA
> is the only developer event you need to attend this year.
> Jumpstart your
> developing skills, take BlackBerry mobile applications to
> market and stay
> ahead of the curve. Join us from November 9 - 12, 2009.
> Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Simple-support mailing list
> Simple-support@...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>


     

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support