Quantcast

CDI and component constructors

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

CDI and component constructors

pekarna
Hi,

I have a class:

public class UserLinkPanel extends Panel {
   
   @Inject UserManager userManager;

   public UserLinkPanel( String id, final long userId ) {
      super( id, new Model( userManager.byID(userId)) );
   }
}

However, of course, this won't compile, because userManager can't be used before super() was called.
So I've changed it to

   public UserLinkPanel( String id, final long userId ) {
      super( id );
      super.setDefaultModelObject( new Model( userManager.byID(userId)) );
   }

I just wonder - isn't there some trick which would make it shorter?

Thanks,
Ondra
Loading...