development GWT / Grails WA2 question

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

development GWT / Grails WA2 question

nathandunn

Had a very good question from one of our users that I thought might be helpful to others.

> Hello,
>
> I am working for i5k project now,
> and I realized that I fully don’t understand how the front-end parts of Apollo works.
>
> Ex.
> “OrganismPanel.java/OrganismPanel.ui.xml” should communicate with OrganismRestService.java
> But I can’t figure out how are they put together? There is no clues in the codes.
>
> Is there some short descriptions of how many tech (DOJO? GWT? BOOTSTRAP3?) are used and the relationship between them. or is there some recommended tutorial for learning it?
>
> thanks
Answer from Colin:

> @ifishlin good questions! I think it is good to understand the "basic" componenents. We do have documentation about the architecture if you are curious too.http://webapollo.readthedocs.org/en/latest/Architecture.html
>
> The libraries that you mentioned are used in different ways on the front end
>
> 1) The GWT component represents the "annotator panel" or sidebar in Apollo2
> 2) The Bootstrap library is simply used to customize the look-and-feel of the GWT sidebar (we use GwtBootstrap3 specifically)
> 3) The Dojo framework is the javascript that runs inside the genome browser for the WebApollo plugin, so it is not used on the sidebar
>
> The OrganismPanel.java and OrganismPanel.ui.xml are part of the GWT code. It is basically java that gets converted to javascript in the webbrowser. This java->javascript conversion is kind of unconventional, but it is a good framework for frontend.
>
> If you want to change the sidebar, make sure to run apollo using "./apollo devmode" because this will allow the GWT java code to be recompiled instantly so that you don't have to recompile or redeploy the WebApollo every time you make a change.
>
> If you want to modify other frontend components, or create new frontend components based off of the web services, check out the web services API, and also check out the grails pages too (these are .gsp files). These gsp files can easily update the database and make useful frontend pages too, for example, the canned comments pages use this (grails-app/views/cannedComment/edit.gsp)
>
> Hope that helps

Further answer from Nathan:


> Sorry for the delay. These github issues were getting swallowed in my junk box.
>
> More doc here on both GWT, Grails 2.4.5, and DOJO

- http://www.gwtproject.org/
- http://grails.github.io/grails-doc/2.4.5/
- http://dojotoolkit.org/reference-guide/1.10/dojo/doc.html

> :
>
> With respect to the GWT it makes REST calls to the grails code. It does this using "XXXRestService" calls. e.g., in OrgansimPanel
>
>     private void updateOrganismInfo(boolean forceReload) {
>         OrganismRestService.updateOrganismInfo(singleSelectionModel.getSelectedObject(), forceReload);
>     }
>
> It sends a request via the RestService taking callbacks:
>
>         RestService.sendRequest(requestCallback, "organism/updateOrganismInfo", "data=" + organismInfoObject.toString());
>
> which corresponds to the controller "OrganismController" and the action "updateOrganismInfo". The callback, just like with normal ajax, dictates what happens locally on the function returning.
>
> The updateOrganismInfo code does quite a few things:
>
>     @Transactional  // this is a write-transaction method (everything else is read-only)
>     def updateOrganismInfo() {
>         JSONObject organismJson = request.JSON?:JSON.parse(params.data.toString()) as JSONObject  // get either a JSON websocket or a REST service JSON input
>         try {
>             permissionService.checkPermissions(organismJson, PermissionEnum.ADMINISTRATE) // check permissions for organism or better admin
>             Organism organism = Organism.findById(organismJson.id)
>   // . . .
>             render findAllOrganisms()
>
> // the methods need to return like this
> findAllOrganisms(){
> JSONArray jsonArray = new JSONArray()
> // . . . populate it
>    render jsonArray as JSON
> }








This list is for the Apollo Annotation Editing Tool. Info at http://genomearchitect.org/
If you wish to unsubscribe from the Apollo List: 1. From the address with which you subscribed to the list, send a message to [hidden email] | 2. In the subject line of your email type: unsubscribe apollo | 3. Leave the message body blank.