Gwt parte 01
-
Upload
rafael-adriano -
Category
Documents
-
view
2.179 -
download
0
Transcript of Gwt parte 01
![Page 1: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/1.jpg)
R A F A E L A D R IA N O
GWTGoogle Web Toolkit
Parte 01
![Page 2: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/2.jpg)
Introdução
É um framework desenvolvido pela Google, que facilita a criação de aplicativos web, sem preocupar-se com compatibilidade de navegadores e manutenção de código JavaScript.
![Page 3: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/3.jpg)
Ambiente
IDE Eclipse;
Suporte a linguagem Java;
Google Suite Plugin;
Facilita configuração do projeto GWT.
![Page 4: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/4.jpg)
Projeto
Estrutura do projeto;
Servidor;
Cliente;
Configuração (Módulo);
Web;
Biblioteca.
![Page 5: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/5.jpg)
Prática
Criação do projeto;
Nome: Teste;
Pacote: br.udesc.
![Page 6: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/6.jpg)
Módulo
XML;
Nome do módulo;
Bibliotecas;
Ponto de entrada;
Lado cliente.
![Page 7: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/7.jpg)
Prática
Criando um módulo;
Criar html;
Inserir módulo no html.
![Page 8: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/8.jpg)
Ponto de entrada
EntryPoint;
onModuleLoad.
![Page 9: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/9.jpg)
Prática
Criando ponto de entrada;
Registrar no XML do módulo.
![Page 10: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/10.jpg)
Teste
Compilar;
Executar;
Browser;
Plugin;
Sucesso.
![Page 11: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/11.jpg)
Widgets
São mini aplicações projetadas para serem executadas como aplicações individuais ou add-on(adicionáveis) em páginas Web;
No GWT são basicamente os componentes para se montar uma página web.
![Page 12: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/12.jpg)
Prática
Criar um VerticalPanel;
Criar um HorizontalPanel;
Criar um Label;
Criar um TextBox;
Criar um Button.
![Page 13: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/13.jpg)
Comunicação
Suporta JSON e XML;
GWT RPC é um protocolo semelhante ao tradicional Java RMI, bastando criar uma interface e especificar os métodos remotos que se desejam ser chamados;
Serializa automaticamente os argumentos/parâmetros;
Todas suas chamadas são assíncronas;
Suporta transmitir exceções.
![Page 14: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/14.jpg)
Comunicação - GWT RPC
![Page 15: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/15.jpg)
Prática
GWT RPC;
Criar interface no pacote client; Interface estende RemoteService; Gerar Async pelo plugin no pacote client; Anotar a interface com @RemoteServiceRelativePath(“servletName”);
Criar pacote server; Implementar interface no pacote server;
Implementação estende RemoteServiceServlet;
Implementação é um servlet;
Registrar o servlet no web.xml; Integrar com a tela.
![Page 16: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/16.jpg)
Internacionalização
Suporta três técnicas de implementação;
Static String Internacionalization;
Dynamic String Internacionalization;
Extending or implementing Localizable.
![Page 17: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/17.jpg)
Prática
Static String Internacionalization;
Criar duas interfaces; MinhasConstants estende a interface Constants; MinhasMessages estende a interface Messages;
Criar dois arquivos properties; MinhasConstants_pt_BR.properties; MinhasMessages_pt_BR.properties;
Registrar locale pt_BR no XML do módulo; <extend-property name="locale" values="pt_BR"/>;
Registrar no XML do módulo caso necessite formatar data; <inherits name="com.google.gwt.i18n.I18N"/>;
Criar constantes e mensagens; Integrar com a tela.
![Page 18: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/18.jpg)
JSNI
JavaScript Native Interface;
Responsável por permitir a codificação de JavaScriptno meio de código Java;
Métodos JSNI são declarados nativamente e o bloco
delimitado entre /*-{ e }-*/;
Muito usado para criação de novos componentes.
![Page 19: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/19.jpg)
Prática
Criar método nativo;
Invocar método.
public native void showMessage(String msg)/*-{$wnd.alert(msg);
}-*/;
![Page 20: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/20.jpg)
SmartClient
Biblioteca JavaScript; Desenvolvida pela Isomorphic Software;
Utilização do lado client é gratuita;
URL: http://www.smartclient.com/;
Integração SmartClient com GWT; Projeto SmartGWT;
OpenSource;
URL: http://code.google.com/p/smartgwt/;
Mais componentes;
Componentes ricos.
![Page 21: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/21.jpg)
Prática
Baixar biblioteca;
Adicionar jars no classpath do projeto; smartgwt.jar;
smartgwt-skins.jar;
Registrar no biblioteca no XML do módulo; <inherits name="com.smartgwt.SmartGwt"/>;
Criar um ListGrid; Campos Nome e Idade;
Popular.
![Page 22: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/22.jpg)
Deploy/Prática
Compilação;
Biblioteca; Adicionar bibliotecas necessárias na WEB-INF/lib;
Publicação;
Copiar pasta war e publicar no TomCat.
![Page 23: Gwt parte 01](https://reader034.fdocumentos.tips/reader034/viewer/2022052214/55a4f7231a28ab6d628b45e5/html5/thumbnails/23.jpg)
Continua...