How to use Gin DI in custom ConstraintValidator (Bean Validation)?

2013-03-29 Thread p . kotlyarov1988
For example i have some CodeValidator with dependencies.

public class ExistingCustomsCodeValidator implements 
ConstraintValidatorExistingCustomsCode, String {
@Inject private CustomsCodeService customsCodeService;
@Inject private ProcessingCtx processingCtx;

@Override public void initialize(ExistingCustomsCode 
constraintAnnotation) {}

@Override public boolean isValid(String value, 
ConstraintValidatorContext context) {
return customsCodeService.isValid(value, 
processingCtx.getDeclarationDateTime());
}
}

I can simply inject dependencies on server-side, but i can't imagine how to 
do this on client-side.

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how to use GIN ?

2010-06-28 Thread PhilBeaudoin
Thomas gives very good advice, although I personally never use the
@ImplementedBy annotation (not entirely sure why...).

To complement his answer, if you're interested in saving the
addClickHandler call you may want to take a look at UiBinder the
@UiHandler annotation.

On Jun 27, 3:41 pm, Thomas Broyer t.bro...@gmail.com wrote:
 On 27 juin, 19:39, yves yves.ko...@gmail.com wrote:





  Olivier,

  Thanks for the link.

  If I try to summarize my problem : Which are the conventions that are
  implicitly used by GIN to bind classes ?

  I've already seen gwt-presenter, but it didn't helped me to understand
  how to transform my code to such code  :

  public class AppModule extends AbstractGinModule {

          @Override
          protected void configure() {

                  bind(EventBus.class).to(DefaultEventBus.class);

  bind(MainPresenter.Display.class).to(MainWidget.class);

  bind(MenuPresenter.Display.class).to(MenuWidget.class);

  bind(IssueEditPresenter.Display.class).to(IssueEditWidget.class);

  bind(IssueDisplayPresenter.Display.class).to(IssueDisplayWidget.class);

 If you control all of those classes, and they only exist as an
 interface+implementation class for testing purpose, then I'd rather
 annotate the interfaces with @ImplementedBy, e.g.
   �...@implementedby(MainWidget.class)
    public interface Display { ... }
 That way, GIN will automatically use MainWidget as if you wrote the
 bind().to(); and in case you want to inject some other implementation
 (e.g. in some complex tests), you can use bind().to() without risking
 a duplicate binding.





  Is there any doc explaining what is behind the scene with all these
  bind().to() calls ?

  In my example, if I write something like

  bind(SearchPresenter.Display.class).to(someWidget.class);

  is it equivalent to

                  display = d;
                  display.getSearchButton().addClickHandler(new
  ClickHandler() {

                          @Override
                          public void onClick(ClickEvent event) {
                                  doSearch(event);
                          }

                  });

  and how to tell GIN that I need to call doSearch() ?

 No! GIN is only about dependency injection, i.e. it saves you the
 new, and nothing else.
 With the above bind().to() and an @Inject annotation on the
 bind(Display) method, then when GIN is asked to instantiate a
 SearchPresenter (i.e. when you do not write the new yourself) it'll
 automatically instantiate a SomeWidget and call bind() with it as an
 argument (and when instantiating the SomeWidget, it'll automatically
 instantiate the required dependencies and inject them to @Inject-
 annotated constructor, fields and methods).

 Maybe you should look for Guice tutorials to better understand what
 dependency injection is, and how to configure it with Guice.

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: how to use GIN ?

2010-06-28 Thread yves
Thank you for these explanations, I think I begin to understand GIN.
.. and I'll read the Guice tutorials :-)
(or may be :-( yet another tuto...)

Yves

PS to GIN team :
please make GIN simple to understand for those who don't know Guice
and are just trying to improve their client code.
I only came to GIN because it is used in some MVP explanations.



On 28 juin, 09:00, PhilBeaudoin philippe.beaud...@gmail.com wrote:
 Thomas gives very good advice, although I personally neverusethe
 @ImplementedBy annotation (not entirely sure why...).

 To complement his answer, if you're interested in saving the
 addClickHandler call you may want to take a look at UiBinder the
 @UiHandler annotation.

 On Jun 27, 3:41 pm, Thomas Broyer t.bro...@gmail.com wrote:

  On 27 juin, 19:39, yves yves.ko...@gmail.com wrote:

   Olivier,

   Thanks for the link.

   If I try to summarize my problem : Which are the conventions that are
   implicitly used byGINto bind classes ?

   I've already seen gwt-presenter, but it didn't helped me to understand
   how to transform my code to such code  :

   public class AppModule extends AbstractGinModule {

           @Override
           protected void configure() {

                   bind(EventBus.class).to(DefaultEventBus.class);

   bind(MainPresenter.Display.class).to(MainWidget.class);

   bind(MenuPresenter.Display.class).to(MenuWidget.class);

   bind(IssueEditPresenter.Display.class).to(IssueEditWidget.class);

   bind(IssueDisplayPresenter.Display.class).to(IssueDisplayWidget.class);

  If you control all of those classes, and they only exist as an
  interface+implementation class for testing purpose, then I'd rather
  annotate the interfaces with @ImplementedBy, e.g.
    �...@implementedby(MainWidget.class)
     public interface Display { ... }
  That way,GINwill automaticallyuseMainWidget as if you wrote the
  bind().to(); and in case you want to inject some other implementation
  (e.g. in some complex tests), you canusebind().to() without risking
  a duplicate binding.

   Is there any doc explaining what is behind the scene with all these
   bind().to() calls ?

   In my example, if I write something like

   bind(SearchPresenter.Display.class).to(someWidget.class);

   is it equivalent to

                   display = d;
                   display.getSearchButton().addClickHandler(new
   ClickHandler() {

                           @Override
                           public void onClick(ClickEvent event) {
                                   doSearch(event);
                           }

                   });

   and how to tellGINthat I need to call doSearch() ?

  No!GINis only about dependency injection, i.e. it saves you the
  new, and nothing else.
  With the above bind().to() and an @Inject annotation on the
  bind(Display) method, then whenGINis asked to instantiate a
  SearchPresenter (i.e. when you do not write the new yourself) it'll
  automatically instantiate a SomeWidget and call bind() with it as an
  argument (and when instantiating the SomeWidget, it'll automatically
  instantiate the required dependencies and inject them to @Inject-
  annotated constructor, fields and methods).

  Maybe you should look for Guice tutorials to better understand what
  dependency injection is, and how to configure it with Guice.

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



how to use GIN ?

2010-06-27 Thread yves
Hi Everybody,

I've read the the official tutorial at 
http://code.google.com/p/google-gin/wiki/GinTutorial,
but I still doesn't understand how to use GIN (as it is mainly based
on Guice that I don't know)  and how it could help me :-( Sorry for
the tutorial writer :-)

I'm currently developping an MVP based app mainly inspired by the
google IO 2009 presentation
http://code.google.com/intl/fr/events/io/2009/sessions/GoogleWebToolkitBestPractices.html
and also the article 
http://code.google.com/intl/fr/webtoolkit/articles/mvp-architecture.html.

Here is an example of the code I would like to simplify using DI (as I
understand, GIN could do some part for me) :

public class SearchPresenter implements Presenter {

public interface Display {
HasClickHandlers getSearchButton();
}

Display display;

public void bind(Display d) {
display = d;
display.getSearchButton().addClickHandler(new ClickHandler() {

@Override
public void onClick(ClickEvent event) {
doSearch(event);
}

});
}


As I understand, perhaps I am wrong, GIN could do the bind() for me ?
But, how should I use GIN for that (if it is really suited for this) ?

Thanks for your help !
Yves

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: how to use GIN ?

2010-06-27 Thread olivier nouguier
hi
 Google to gwt-presenter
HIH


On Sun, Jun 27, 2010 at 12:51 PM, yves yves.ko...@gmail.com wrote:

 Hi Everybody,

 I've read the the official tutorial at
 http://code.google.com/p/google-gin/wiki/GinTutorial,
 but I still doesn't understand how to use GIN (as it is mainly based
 on Guice that I don't know)  and how it could help me :-( Sorry for
 the tutorial writer :-)

 I'm currently developping an MVP based app mainly inspired by the
 google IO 2009 presentation

 http://code.google.com/intl/fr/events/io/2009/sessions/GoogleWebToolkitBestPractices.html
 and also the article
 http://code.google.com/intl/fr/webtoolkit/articles/mvp-architecture.html.

 Here is an example of the code I would like to simplify using DI (as I
 understand, GIN could do some part for me) :

 public class SearchPresenter implements Presenter {

public interface Display {
HasClickHandlers getSearchButton();
}

Display display;

public void bind(Display d) {
display = d;
display.getSearchButton().addClickHandler(new ClickHandler()
 {

@Override
public void onClick(ClickEvent event) {
doSearch(event);
}

});
}


 As I understand, perhaps I am wrong, GIN could do the bind() for me ?
 But, how should I use GIN for that (if it is really suited for this) ?

 Thanks for your help !
 Yves

 --
 You received this message because you are subscribed to the Google Groups
 Google Web Toolkit group.
 To post to this group, send email to google-web-tool...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-web-toolkit+unsubscr...@googlegroups.comgoogle-web-toolkit%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/google-web-toolkit?hl=en.




-- 
Computers are useless. They can only give you answers.
- Pablo Picasso -

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: how to use GIN ?

2010-06-27 Thread yves
Olivier,

Thanks for the link.

If I try to summarize my problem : Which are the conventions that are
implicitly used by GIN to bind classes ?

I've already seen gwt-presenter, but it didn't helped me to understand
how to transform my code to such code  :

public class AppModule extends AbstractGinModule {

@Override
protected void configure() {

bind(EventBus.class).to(DefaultEventBus.class);

 
bind(MainPresenter.Display.class).to(MainWidget.class);

 
bind(MenuPresenter.Display.class).to(MenuWidget.class);

 
bind(IssueEditPresenter.Display.class).to(IssueEditWidget.class);

 
bind(IssueDisplayPresenter.Display.class).to(IssueDisplayWidget.class);

}

}

(found here
http://code.google.com/p/gwt-mvp-sample/source/browse/branches/gwt-presenter/src/com/enunes/bit/client/gin/AppModule.java)

Is there any doc explaining what is behind the scene with all these
bind().to() calls ?

In my example, if I write something like

 
bind(SearchPresenter.Display.class).to(someWidget.class);

is it equivalent to

display = d;
display.getSearchButton().addClickHandler(new
ClickHandler() {

@Override
public void onClick(ClickEvent event) {
doSearch(event);
}

});

and how to tell GIN that I need to call doSearch() ?

Thanks !

Yves

On 27 juin, 19:05, olivier nouguier olivier.nougu...@gmail.com
wrote:
 hi
  Google to gwt-presenter
 HIH



 On Sun, Jun 27, 2010 at 12:51 PM, yves yves.ko...@gmail.com wrote:
  Hi Everybody,

  I've read the the official tutorial at
 http://code.google.com/p/google-gin/wiki/GinTutorial,
  but I still doesn't understand how to use GIN (as it is mainly based
  on Guice that I don't know)  and how it could help me :-( Sorry for
  the tutorial writer :-)

  I'm currently developping an MVP based app mainly inspired by the
  google IO 2009 presentation

 http://code.google.com/intl/fr/events/io/2009/sessions/GoogleWebToolk...
  and also the article
 http://code.google.com/intl/fr/webtoolkit/articles/mvp-architecture.html.

  Here is an example of the code I would like to simplify using DI (as I
  understand, GIN could do some part for me) :

  public class SearchPresenter implements Presenter {

         public interface Display {
                 HasClickHandlers getSearchButton();
         }

         Display display;

         public void bind(Display d) {
                 display = d;
                 display.getSearchButton().addClickHandler(new ClickHandler()
  {

                        �...@override
                         public void onClick(ClickEvent event) {
                                 doSearch(event);
                         }

                 });
         }

  As I understand, perhaps I am wrong, GIN could do the bind() for me ?
  But, how should I use GIN for that (if it is really suited for this) ?

  Thanks for your help !
  Yves

  --
  You received this message because you are subscribed to the Google Groups
  Google Web Toolkit group.
  To post to this group, send email to google-web-tool...@googlegroups.com.
  To unsubscribe from this group, send email to
  google-web-toolkit+unsubscr...@googlegroups.comgoogle-web-toolkit%2bunsubscr...@googlegroups.com
  .
  For more options, visit this group at
 http://groups.google.com/group/google-web-toolkit?hl=en.

 --
 Computers are useless. They can only give you answers.
 - Pablo Picasso -

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: how to use GIN ?

2010-06-27 Thread Thomas Broyer


On 27 juin, 19:39, yves yves.ko...@gmail.com wrote:
 Olivier,

 Thanks for the link.

 If I try to summarize my problem : Which are the conventions that are
 implicitly used by GIN to bind classes ?

 I've already seen gwt-presenter, but it didn't helped me to understand
 how to transform my code to such code  :

 public class AppModule extends AbstractGinModule {

         @Override
         protected void configure() {

                 bind(EventBus.class).to(DefaultEventBus.class);

 bind(MainPresenter.Display.class).to(MainWidget.class);

 bind(MenuPresenter.Display.class).to(MenuWidget.class);

 bind(IssueEditPresenter.Display.class).to(IssueEditWidget.class);

 bind(IssueDisplayPresenter.Display.class).to(IssueDisplayWidget.class);

If you control all of those classes, and they only exist as an
interface+implementation class for testing purpose, then I'd rather
annotate the interfaces with @ImplementedBy, e.g.
   @ImplementedBy(MainWidget.class)
   public interface Display { ... }
That way, GIN will automatically use MainWidget as if you wrote the
bind().to(); and in case you want to inject some other implementation
(e.g. in some complex tests), you can use bind().to() without risking
a duplicate binding.

 Is there any doc explaining what is behind the scene with all these
 bind().to() calls ?

 In my example, if I write something like

 bind(SearchPresenter.Display.class).to(someWidget.class);

 is it equivalent to

                 display = d;
                 display.getSearchButton().addClickHandler(new
 ClickHandler() {

                         @Override
                         public void onClick(ClickEvent event) {
                                 doSearch(event);
                         }

                 });

 and how to tell GIN that I need to call doSearch() ?

No! GIN is only about dependency injection, i.e. it saves you the
new, and nothing else.
With the above bind().to() and an @Inject annotation on the
bind(Display) method, then when GIN is asked to instantiate a
SearchPresenter (i.e. when you do not write the new yourself) it'll
automatically instantiate a SomeWidget and call bind() with it as an
argument (and when instantiating the SomeWidget, it'll automatically
instantiate the required dependencies and inject them to @Inject-
annotated constructor, fields and methods).

Maybe you should look for Guice tutorials to better understand what
dependency injection is, and how to configure it with Guice.

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.