{"action":"created","comment":{"url":"https://api.github.com/repos/ArcBees/dev-site/pulls/comments/34006026","id":34006026,"diff_hunk":"@@ -0,0 +1,275 @@\n+# GWTP Beginner’s Tutorial - Part 1\t\n+This tutorial is intended for people having no prior knowledge of GWTP who wants to get started right away writing some code. This first part will show you how a basic Presenter can interact with a View by using UiHandler and UiBinder. Chances are that you will need to replicate this over and over again for almost every Presenter you create. This tutorial won’t go much into the details of explaining how GWTP works (we have excellent documentation for that), but rather how the features interact together.\n+\n+\n+## Covered features:\n+Presenter, View, PresenterModule, UiHandler, UiBinder, NameToken and CodeSplit.\n+\n+\n+## Prerequisites\n+1. [Running a project]\n+1. TODO: Provide a pom.xml for this tutorial.\n+\n+\n+## Application Structure\n+```\n+src/main/java/com/arcbees/demo/client/\n+├── application\n+│   ├── ApplicationModule.java\n+│   ├── ApplicationPresenter.java\n+│   ├── ApplicationUiHandlers.java\n+│   ├── ApplicationView.java\n+│   └── ApplicationView.ui.xml\n+├── gin\n+│   └── ClientModule.java\n+└── place\n+    └── NameTokens.java\n+```\n+\n+## Main files and their purpose\n+\n+### ApplicationModule\n+Used to bind everything together using dependency injection.\n+\n+### ApplicationPresenter\n+Contains all of your client-side logic.\n+\n+### ApplicationUiHandlers\n+Used to delegate some of the View actions to the Presenter usually in response of events.\n+\n+### ApplicationView\n+Views handle all the UI-related code for a Presenter.\n+\n+### ApplicationView.ui.xml\n+Used to write html in your view.\n+\n+### ClientModule\n+This is where you setup your PlaceManager.\n+\n+### NameTokens\n+Contains the constants defining your places.\n+\n+\n+## Views and Presenters\n+In a GWTP application, all pages correspond to a View-Presenter pair. The Presenter contains the client side logic and the View only display what it is told to by the Presenter. It is often said that the view should be as dumb as possible.\n+\n+### View\n+Here’s our basic ApplicationView:\n+```java\n+public class ApplicationView extends ViewWithUiHandlers<ApplicationUiHandlers> implements ApplicationPresenter.MyView {\n+    interface Binder extends UiBinder<Widget, ApplicationView> {\n+    }\n+    \n+    @Inject\n+    ApplicationView(\n+            Binder uiBinder) {\n+        initWidget(uiBinder.createAndBindUi(this));\n+    }\n+```\n+\n+We’re going to break it down into simpler part. First, let’s take a look at the class declaration. We have an ApplicationView extending a ViewWithUiHandlers. This specify that ApplicationView will be a View and will also use UiHandlers which I will talk about further in this tutorial. Then the View implements an interface that is declared in the ApplicationPresenter class. This will allow the View to talk to the Presenter.\n+\n+GWTP is heavily relying on [google-gin](https://code.google.com/p/google-gin/) for [dependency injection](https://en.wikipedia.org/wiki/Dependency_injection), thus the presence of a `@Inject` annotation on the constructor.\n+\n+### Presenter\n+This is the ApplicationPresenter:\n+```java\n+public class ApplicationPresenter extends Presenter<ApplicationPresenter.MyView, ApplicationPresenter.MyProxy> implements ApplicationUiHandlers {\n+    @ProxyStandard\n+    @NameToken(NameTokens.home)\n+    interface MyProxy extends ProxyPlace<ApplicationPresenter> {\n+    }\n+    \n+    interface MyView extends View, HasUiHandlers<ApplicationUiHandlers> {\n+    }\n+    \n+    private final PlaceManager placeManager;\n+    \n+    @Inject\n+    ApplicationPresenter(\n+            EventBus eventBus,\n+            MyView view,\n+            MyProxy proxy,\n+            PlaceManager placeManager) {\n+        super(eventBus, view, proxy, RevealType.Root);\n+    \n+        this.placeManager = placeManager;\n+    \n+        getView().setUiHandlers(this);\n+    }\n+}\n+```\n+\n+Let's take a look at the class declaration. `Presenter<ApplicationPresenter.MyView, ApplicationPresenter.MyProxy>` defines the ApplicationPresenter superclass. This means we have to define the interfaces `MyView` and `MyProxy` inside our class, like this:\n+\n+```java\n+interface MyProxy extends ProxyPlace<ApplicationPresenter> {\n+}\n+interface MyView extends View, HasUiHandlers<ApplicationUiHandlers> {\n+}\n+```\n+\n+`@ProxyStandard` annotation is used to specify whether or not your Presenter should use GWT's code splitting feature. In this case, code splitting is not used but we could have simply used the `@ProxyCodeSplit` annotation instead of this one to use code split. You can learn more on [code splitting](http://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html) at GWT Project website.\n+\n+`@NameToken` is used to easily refer to a page in your application. Each page you want to navigate to should have a nameToken associated with it. For instance, this page is called home because it should be the first page a user will see. This will also let you to use the back and forward button of your browser to navigate in your application. We generally refer to a Presenter having a NameToken as a **Place**.","path":"site/src/main/markdown/gwtp_v2/tutorial/index.md","position":114,"original_position":114,"commit_id":"280c78fd23fd6ca6f745aaae29da8f15008552d0","original_commit_id":"280c78fd23fd6ca6f745aaae29da8f15008552d0","user":{"login":"olafleur","id":1068290,"avatar_url":"https://avatars.githubusercontent.com/u/1068290?v=3","gravatar_id":"","url":"https://api.github.com/users/olafleur","html_url":"https://github.com/olafleur","followers_url":"https://api.github.com/users/olafleur/followers","following_url":"https://api.github.com/users/olafleur/following{/other_user}","gists_url":"https://api.github.com/users/olafleur/gists{/gist_id}","starred_url":"https://api.github.com/users/olafleur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olafleur/subscriptions","organizations_url":"https://api.github.com/users/olafleur/orgs","repos_url":"https://api.github.com/users/olafleur/repos","events_url":"https://api.github.com/users/olafleur/events{/privacy}","received_events_url":"https://api.github.com/users/olafleur/received_events","type":"User","site_admin":false},"body":"will also let you ~~to~~ use","created_at":"2015-07-07T03:47:01Z","updated_at":"2015-07-07T03:47:01Z","html_url":"https://github.com/ArcBees/dev-site/pull/107#discussion_r34006026","pull_request_url":"https://api.github.com/repos/ArcBees/dev-site/pulls/107","_links":{"self":{"href":"https://api.github.com/repos/ArcBees/dev-site/pulls/comments/34006026"},"html":{"href":"https://github.com/ArcBees/dev-site/pull/107#discussion_r34006026"},"pull_request":{"href":"https://api.github.com/repos/ArcBees/dev-site/pulls/107"}}},"pull_request":{"url":"https://api.github.com/repos/ArcBees/dev-site/pulls/107","id":38660908,"html_url":"https://github.com/ArcBees/dev-site/pull/107","diff_url":"https://github.com/ArcBees/dev-site/pull/107.diff","patch_url":"https://github.com/ArcBees/dev-site/pull/107.patch","issue_url":"https://api.github.com/repos/ArcBees/dev-site/issues/107","number":107,"state":"open","locked":false,"title":"Added first tutorial part","user":{"login":"Elrhino","id":5719366,"avatar_url":"https://avatars.githubusercontent.com/u/5719366?v=3","gravatar_id":"","url":"https://api.github.com/users/Elrhino","html_url":"https://github.com/Elrhino","followers_url":"https://api.github.com/users/Elrhino/followers","following_url":"https://api.github.com/users/Elrhino/following{/other_user}","gists_url":"https://api.github.com/users/Elrhino/gists{/gist_id}","starred_url":"https://api.github.com/users/Elrhino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Elrhino/subscriptions","organizations_url":"https://api.github.com/users/Elrhino/orgs","repos_url":"https://api.github.com/users/Elrhino/repos","events_url":"https://api.github.com/users/Elrhino/events{/privacy}","received_events_url":"https://api.github.com/users/Elrhino/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-26T15:31:28Z","updated_at":"2015-07-07T03:47:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1cf7880eac2e2e8a42bf3da1d3f591a5c4e4fae2","assignee":{"login":"Chris-V","id":1116964,"avatar_url":"https://avatars.githubusercontent.com/u/1116964?v=3","gravatar_id":"","url":"https://api.github.com/users/Chris-V","html_url":"https://github.com/Chris-V","followers_url":"https://api.github.com/users/Chris-V/followers","following_url":"https://api.github.com/users/Chris-V/following{/other_user}","gists_url":"https://api.github.com/users/Chris-V/gists{/gist_id}","starred_url":"https://api.github.com/users/Chris-V/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chris-V/subscriptions","organizations_url":"https://api.github.com/users/Chris-V/orgs","repos_url":"https://api.github.com/users/Chris-V/repos","events_url":"https://api.github.com/users/Chris-V/events{/privacy}","received_events_url":"https://api.github.com/users/Chris-V/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/ArcBees/dev-site/pulls/107/commits","review_comments_url":"https://api.github.com/repos/ArcBees/dev-site/pulls/107/comments","review_comment_url":"https://api.github.com/repos/ArcBees/dev-site/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ArcBees/dev-site/issues/107/comments","statuses_url":"https://api.github.com/repos/ArcBees/dev-site/statuses/280c78fd23fd6ca6f745aaae29da8f15008552d0","head":{"label":"ArcBees:rl_gwtp_tutorial","ref":"rl_gwtp_tutorial","sha":"280c78fd23fd6ca6f745aaae29da8f15008552d0","user":{"login":"ArcBees","id":853947,"avatar_url":"https://avatars.githubusercontent.com/u/853947?v=3","gravatar_id":"","url":"https://api.github.com/users/ArcBees","html_url":"https://github.com/ArcBees","followers_url":"https://api.github.com/users/ArcBees/followers","following_url":"https://api.github.com/users/ArcBees/following{/other_user}","gists_url":"https://api.github.com/users/ArcBees/gists{/gist_id}","starred_url":"https://api.github.com/users/ArcBees/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArcBees/subscriptions","organizations_url":"https://api.github.com/users/ArcBees/orgs","repos_url":"https://api.github.com/users/ArcBees/repos","events_url":"https://api.github.com/users/ArcBees/events{/privacy}","received_events_url":"https://api.github.com/users/ArcBees/received_events","type":"Organization","site_admin":false},"repo":{"id":26186462,"name":"dev-site","full_name":"ArcBees/dev-site","owner":{"login":"ArcBees","id":853947,"avatar_url":"https://avatars.githubusercontent.com/u/853947?v=3","gravatar_id":"","url":"https://api.github.com/users/ArcBees","html_url":"https://github.com/ArcBees","followers_url":"https://api.github.com/users/ArcBees/followers","following_url":"https://api.github.com/users/ArcBees/following{/other_user}","gists_url":"https://api.github.com/users/ArcBees/gists{/gist_id}","starred_url":"https://api.github.com/users/ArcBees/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArcBees/subscriptions","organizations_url":"https://api.github.com/users/ArcBees/orgs","repos_url":"https://api.github.com/users/ArcBees/repos","events_url":"https://api.github.com/users/ArcBees/events{/privacy}","received_events_url":"https://api.github.com/users/ArcBees/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ArcBees/dev-site","description":"","fork":false,"url":"https://api.github.com/repos/ArcBees/dev-site","forks_url":"https://api.github.com/repos/ArcBees/dev-site/forks","keys_url":"https://api.github.com/repos/ArcBees/dev-site/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ArcBees/dev-site/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ArcBees/dev-site/teams","hooks_url":"https://api.github.com/repos/ArcBees/dev-site/hooks","issue_events_url":"https://api.github.com/repos/ArcBees/dev-site/issues/events{/number}","events_url":"https://api.github.com/repos/ArcBees/dev-site/events","assignees_url":"https://api.github.com/repos/ArcBees/dev-site/assignees{/user}","branches_url":"https://api.github.com/repos/ArcBees/dev-site/branches{/branch}","tags_url":"https://api.github.com/repos/ArcBees/dev-site/tags","blobs_url":"https://api.github.com/repos/ArcBees/dev-site/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ArcBees/dev-site/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ArcBees/dev-site/git/refs{/sha}","trees_url":"https://api.github.com/repos/ArcBees/dev-site/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ArcBees/dev-site/statuses/{sha}","languages_url":"https://api.github.com/repos/ArcBees/dev-site/languages","stargazers_url":"https://api.github.com/repos/ArcBees/dev-site/stargazers","contributors_url":"https://api.github.com/repos/ArcBees/dev-site/contributors","subscribers_url":"https://api.github.com/repos/ArcBees/dev-site/subscribers","subscription_url":"https://api.github.com/repos/ArcBees/dev-site/subscription","commits_url":"https://api.github.com/repos/ArcBees/dev-site/commits{/sha}","git_commits_url":"https://api.github.com/repos/ArcBees/dev-site/git/commits{/sha}","comments_url":"https://api.github.com/repos/ArcBees/dev-site/comments{/number}","issue_comment_url":"https://api.github.com/repos/ArcBees/dev-site/issues/comments{/number}","contents_url":"https://api.github.com/repos/ArcBees/dev-site/contents/{+path}","compare_url":"https://api.github.com/repos/ArcBees/dev-site/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ArcBees/dev-site/merges","archive_url":"https://api.github.com/repos/ArcBees/dev-site/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ArcBees/dev-site/downloads","issues_url":"https://api.github.com/repos/ArcBees/dev-site/issues{/number}","pulls_url":"https://api.github.com/repos/ArcBees/dev-site/pulls{/number}","milestones_url":"https://api.github.com/repos/ArcBees/dev-site/milestones{/number}","notifications_url":"https://api.github.com/repos/ArcBees/dev-site/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ArcBees/dev-site/labels{/name}","releases_url":"https://api.github.com/repos/ArcBees/dev-site/releases{/id}","created_at":"2014-11-04T20:07:58Z","updated_at":"2015-05-04T14:37:33Z","pushed_at":"2015-06-26T20:25:01Z","git_url":"git://github.com/ArcBees/dev-site.git","ssh_url":"git@github.com:ArcBees/dev-site.git","clone_url":"https://github.com/ArcBees/dev-site.git","svn_url":"https://github.com/ArcBees/dev-site","homepage":null,"size":25535,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":6,"forks":3,"open_issues":6,"watchers":1,"default_branch":"master"}},"base":{"label":"ArcBees:develop-gwtp","ref":"develop-gwtp","sha":"398e75a32c819817e511fd46545309fcca613305","user":{"login":"ArcBees","id":853947,"avatar_url":"https://avatars.githubusercontent.com/u/853947?v=3","gravatar_id":"","url":"https://api.github.com/users/ArcBees","html_url":"https://github.com/ArcBees","followers_url":"https://api.github.com/users/ArcBees/followers","following_url":"https://api.github.com/users/ArcBees/following{/other_user}","gists_url":"https://api.github.com/users/ArcBees/gists{/gist_id}","starred_url":"https://api.github.com/users/ArcBees/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArcBees/subscriptions","organizations_url":"https://api.github.com/users/ArcBees/orgs","repos_url":"https://api.github.com/users/ArcBees/repos","events_url":"https://api.github.com/users/ArcBees/events{/privacy}","received_events_url":"https://api.github.com/users/ArcBees/received_events","type":"Organization","site_admin":false},"repo":{"id":26186462,"name":"dev-site","full_name":"ArcBees/dev-site","owner":{"login":"ArcBees","id":853947,"avatar_url":"https://avatars.githubusercontent.com/u/853947?v=3","gravatar_id":"","url":"https://api.github.com/users/ArcBees","html_url":"https://github.com/ArcBees","followers_url":"https://api.github.com/users/ArcBees/followers","following_url":"https://api.github.com/users/ArcBees/following{/other_user}","gists_url":"https://api.github.com/users/ArcBees/gists{/gist_id}","starred_url":"https://api.github.com/users/ArcBees/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArcBees/subscriptions","organizations_url":"https://api.github.com/users/ArcBees/orgs","repos_url":"https://api.github.com/users/ArcBees/repos","events_url":"https://api.github.com/users/ArcBees/events{/privacy}","received_events_url":"https://api.github.com/users/ArcBees/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ArcBees/dev-site","description":"","fork":false,"url":"https://api.github.com/repos/ArcBees/dev-site","forks_url":"https://api.github.com/repos/ArcBees/dev-site/forks","keys_url":"https://api.github.com/repos/ArcBees/dev-site/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ArcBees/dev-site/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ArcBees/dev-site/teams","hooks_url":"https://api.github.com/repos/ArcBees/dev-site/hooks","issue_events_url":"https://api.github.com/repos/ArcBees/dev-site/issues/events{/number}","events_url":"https://api.github.com/repos/ArcBees/dev-site/events","assignees_url":"https://api.github.com/repos/ArcBees/dev-site/assignees{/user}","branches_url":"https://api.github.com/repos/ArcBees/dev-site/branches{/branch}","tags_url":"https://api.github.com/repos/ArcBees/dev-site/tags","blobs_url":"https://api.github.com/repos/ArcBees/dev-site/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ArcBees/dev-site/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ArcBees/dev-site/git/refs{/sha}","trees_url":"https://api.github.com/repos/ArcBees/dev-site/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ArcBees/dev-site/statuses/{sha}","languages_url":"https://api.github.com/repos/ArcBees/dev-site/languages","stargazers_url":"https://api.github.com/repos/ArcBees/dev-site/stargazers","contributors_url":"https://api.github.com/repos/ArcBees/dev-site/contributors","subscribers_url":"https://api.github.com/repos/ArcBees/dev-site/subscribers","subscription_url":"https://api.github.com/repos/ArcBees/dev-site/subscription","commits_url":"https://api.github.com/repos/ArcBees/dev-site/commits{/sha}","git_commits_url":"https://api.github.com/repos/ArcBees/dev-site/git/commits{/sha}","comments_url":"https://api.github.com/repos/ArcBees/dev-site/comments{/number}","issue_comment_url":"https://api.github.com/repos/ArcBees/dev-site/issues/comments{/number}","contents_url":"https://api.github.com/repos/ArcBees/dev-site/contents/{+path}","compare_url":"https://api.github.com/repos/ArcBees/dev-site/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ArcBees/dev-site/merges","archive_url":"https://api.github.com/repos/ArcBees/dev-site/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ArcBees/dev-site/downloads","issues_url":"https://api.github.com/repos/ArcBees/dev-site/issues{/number}","pulls_url":"https://api.github.com/repos/ArcBees/dev-site/pulls{/number}","milestones_url":"https://api.github.com/repos/ArcBees/dev-site/milestones{/number}","notifications_url":"https://api.github.com/repos/ArcBees/dev-site/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ArcBees/dev-site/labels{/name}","releases_url":"https://api.github.com/repos/ArcBees/dev-site/releases{/id}","created_at":"2014-11-04T20:07:58Z","updated_at":"2015-05-04T14:37:33Z","pushed_at":"2015-06-26T20:25:01Z","git_url":"git://github.com/ArcBees/dev-site.git","ssh_url":"git@github.com:ArcBees/dev-site.git","clone_url":"https://github.com/ArcBees/dev-site.git","svn_url":"https://github.com/ArcBees/dev-site","homepage":null,"size":25535,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":6,"forks":3,"open_issues":6,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ArcBees/dev-site/pulls/107"},"html":{"href":"https://github.com/ArcBees/dev-site/pull/107"},"issue":{"href":"https://api.github.com/repos/ArcBees/dev-site/issues/107"},"comments":{"href":"https://api.github.com/repos/ArcBees/dev-site/issues/107/comments"},"review_comments":{"href":"https://api.github.com/repos/ArcBees/dev-site/pulls/107/comments"},"review_comment":{"href":"https://api.github.com/repos/ArcBees/dev-site/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ArcBees/dev-site/pulls/107/commits"},"statuses":{"href":"https://api.github.com/repos/ArcBees/dev-site/statuses/280c78fd23fd6ca6f745aaae29da8f15008552d0"}}}}