gwt_slide
TRANSCRIPT
� �
�����������ABCBA��DDE��FA���
���������A�BCDECF����E�������F�����������BC��F����F�F����F
��CF�������F����BCD !�
"A����#F���$�����������F�%�&F�F�'
(F����F��������)��*C���F��+EC��BF�F�E�• �,-.-�
� �
������������A�BCD��E�F����� ���������� �ABC�DE�FB����F��� �����AB����F��
�F������E�D�B���CBFAB��B���B���DDE��FA����C��B�A
� �
������������A�BCD��E�F����� ���������� �ABC�DE�FB����F��� �����AB����F��
�B���B���DDE��FA����C��B�A�
� �
������������A�BCD��E�F����� ���������� �ABC�DE�FB����F��� �����AB����F��
�F�����B���DDE��FA���
�����B�����
� �
������������A�BCD��E�F����� ���������� �ABC�DE�FB����F��� �����AB����F��
��D������
� �
������������A�BCD��E�F����� ���������� �ABC�DE�FB����F��� �����AB����F��
�F���� �CB!�"#��F�AB�����
� �
������������A�BCD��E�F����� ���������� �ABC�DE�FB����F��� �����AB����F��
$E�%�&�'��E�(B)��A�%�*BF'D�E%F��B�D��B�)FC��+F,F�(BC,EBA�
� �
���A�BCD��E�F������F���F�������F���
� ���������� �ABC�DE�FB����F��� �����AB����F��
�BC�%�F�%�!�-�CF���)��)FEF'�!�EB������BD�
��������� ��AB�CCA� D�EA����F��A�����A�����C�C��
����AE���A���FCFA����A��FA��������A������A�����
� �
���A�BCD��E�F������F���F�������F���
� ���������� �ABC�DE�FB����F��� �����AB����F��
�BC�%�F��C����BD�
�A����A�����A F����A!�F�CF�� ���"F���B���F���� C���#�����B���F���� �����$���B���F���
� �
���A�BCD��E�F������F���F�������F���
� ���������� �ABC�DE�FB����F��� �����AB����F��
�BC�%�F�%�!�-�CF���)��)FEF'�!�EB��C�������BD�
%!!�F��F��&����AD�F��
� �
���A�BCD��E�F������F���F�������F���
� ���������� �ABC�DE�FB����F��� �����AB����F��
�BC�%�F��DDE��FA����AC�����A�
��CC�
��D����E���F������F����E�
'����F���
���� !�F"��
� �
���A�BCD��E�F������F���F�������F���
� ���������� �ABC�DE�FB����F��� �����AB����F��
.��)FEF'�!��A����*�)�EB��F)#�AB'�%F��FCF�'B'F�F-���)-BA�%B�/&*���)B�
�A F������ C���#������ ���"F���� �����$���
(F����A�F)���EA��A����A�*�$
� �
���A�BCD��E�F������F���F�������F���
� ���������� �ABC�DE�FB����F��� �����AB����F��
.��)FEF'�!��A����*�)�EB��F)#�AB'�%F��FCF�'B-F%A�!%F�+F,F�(BC,EBA�
B����A������AC���F��A!��+�
� �
���A�BCD��E�F������F���F�������F���
� ���������� �ABC�DE�FB����F��� �����AB����F��
.��)FEF'�!��A����*�)�EB��F)#�AB'�%F��FCF�'B-F%A�!%F�+F,F�(BC,EBA�
E�����A�����A�����A��F�A���C�
E�����A�����A�����A������A�������A&,*&-
D��E�F���A����AE�����A������F�A'����F��A�F� #�DFA�CF�$F�
� �
���A�BCD��E�F������F���F�������F���
� ���������� �ABC�DE�FB����F��� �����AB����F��
.��)FEF'�!��A����*�)�EB��F)#�AB'�%F��FCF�'B-F%A�!%F�+F,F�(BC,EBA�
���A'����F��A�F� #�DFA�CF�$F��!�����F��AC������A�����FA!��+�A��FF����CF�$��F
� �
���A�BCD��E�F������F���F�������F���
� ���������� �ABC�DE�FB����F��� �����AB����F��
&B'�%F�)B!������EF���+F,F�(BC,EBA#��'DEB'BAF����BC,BC0��)B������BC,��B�
� �
�����������ABCBA��DDE��FA���
���������A�BCDECF����E�������F�����������BC��F����F�F����F
��FC���E���������BCD���
A��!�"F���#���!�������F�$�%F�F�&
'F��!�F��������(��)C���F��*EC��BF�F�E�• �+,-,�
� �
���������A�BCDE�F������� ���������� �ABC�DE�FB����F��� �����AB����F��
�FEF��DCB�BAF��������AF�F�F��B�BCAF�F���A������B��FEF��DC��B����D���F��ABEF����AF��BBCFAB��B�� F�F���E�D�B
A������������A�B�����B������������������������������������� �
� �
���������A�BCDE�F������� ���������� �ABC�DE�FB����F��� �����AB����F��
!B�BCAF�F����E��A���A�����"B��FEF��#C��B���D�
���������A�BCADE�FD��FE��CF���F���������������C�����D��B��
�������������C��������B����C�� ��BA���B��DE�������C��E��DFE���F�!�DE���F"�#�D�F�������C����A���F���DE�����A$B���A���!�DE���F"�#����C��C���F"�����C���DE����A%������F��E������BA���B����C����A���F���DE����
�����&��'EE��C���DD���(�B��D�BC�������A��CB���F(��<link rel="stylesheet" type="text/css" href="{foldername}/css/gxt-all.css" />
�����)��'EE��C���DD���(����������A�������B�"EAD��*"D���D��<inherits name='com.extjs.gxt.ui.GXT'/>
�����+���*��������,A���B��C���DD���(�E������<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
�����-��'EE��A��������D�$�F���B������������������C�����D��B�.
� �
���������A�BCADE�FD��FE��CF���F���������������C�����D��B��
���������A�BCDE�F������!�����"������
� ���������� �ABC�DE�FB����F��� �����AB����F��
����������������A��B����CD�E��CA����F������E�
� �
�������������C��������B����C�� ��BA���B��DE�������C��E��DFE���F�!�DE���F"�#�D�F�������C��A���F���DE�����A$B���A���!�DE���F"�#����C��C���F"�����C���DE����A%������F��E������BA���B����C����A���F���DE����
���������A�BCDE�F������!�����"������
� ���������� �ABC�DE�FB����F��� �����AB����F��
������F�����F� F�A�����F�����F��B���
� �
�����&��'EE��C���DD���(�B��D�BC�������A��CB���F(��<link rel="stylesheet" type="text/css" href="{foldername}/css/gxt-all.css" />
���������A�BCDE�F������!�����"������
� ���������� �ABC�DE�FB����F��� �����AB����F��
<!doctype html><html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="gxt/css/gxt-all.css" /> <link type="text/css" rel="stylesheet" href="Ipk.css"> <title>Web Application Starter Project</title> <script type="text/javascript" language="javascript" src="ipk/ipk.nocache.js"></script> </head> <body> <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> <noscript> <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif"> Your web browser must have JavaScript enabled in order for this application to display correctly. </div> </noscript> <h1>Web Application Starter Project</h1> <table align="center"> <tr> <td colspan="2" style="font-weight:bold;">Please enter your name:</td> </tr> <tr> <td id="nameFieldContainer"></td> <td id="sendButtonContainer"></td> </tr> <tr> <td colspan="2" style="color:red;" id="errorLabelContainer"></td> </tr> </table> </body></html>
�E����D��D���D���B��������������F�BC����F�����F��������A����E�D�E��C���
� �
�����)��'EE��C���DD���(����������A�������B�"EAD��*"D���D��<inherits name='com.extjs.gxt.ui.GXT'/>
���������A�BCDE�F������!�����"������
� ���������� �ABC�DE�FB����F��� �����AB����F��
�E�������D��D���D���B��������������F�BC�<?xml version="1.0" encoding="UTF-8"?><module rename-to='ipk'> <!-- Inherit the core Web Toolkit stuff. --> <inherits name='com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. You can change --> <!-- the theme of your GWT application by uncommenting --> <!-- any one of the following lines. --> <inherits name='com.google.gwt.user.theme.standard.Standard'/> <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> --> <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<inherits name='com.extjs.gxt.ui.GXT'/>
<!-- Specify the app entry point class. --> <entry-point class='com.ft.project.client.Ipk'/>
<!-- Specify the paths for translatable code --> <source path='client'/> <source path='shared'/>
</module>
� �
�����+���*��������,A���B��C���DD���(�E������<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
���������A�BCDE�F������!�����"������
� ���������� �ABC�DE�FB����F��� �����AB����F��
�E����D��D���D���B��������������F�BC�<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link type="text/css" rel="stylesheet" href="Ipk.css">
<link rel="stylesheet" type="text/css" href="gxt/css/gxt-all.css" /> <title>Web Application Starter Project</title> <script type="text/javascript" language="javascript" src="ipk/ipk.nocache.js"></script> </head> <body> <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> <noscript> <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif"> Your web browser must have JavaScript enabled in order for this application to display correctly. </div> </noscript> <h1>Web Application Starter Project</h1> <table align="center"> <tr> <td colspan="2" style="font-weight:bold;">Please enter your name:</td> </tr> <tr> <td id="nameFieldContainer"></td> <td id="sendButtonContainer"></td> </tr> <tr> <td colspan="2" style="color:red;" id="errorLabelContainer"></td> </tr> </table> </body></html>
� �
�����-��'EE��A��������D�$�F���B������������������C�����D��B�.
���������A�BCDE�F������!�����"������
� ���������� �ABC�DE�FB����F��� �����AB����F��
�������������B�F���������B������F�����������D�F��F��
� �
�����-��'EE��A��������D�$�F���B������������������C�����D��B�.
���������A�BCDE�F������!�����"������
� ���������� �ABC�DE�FB����F��� �����AB����F��
� �
�����������ABCBA��DDE��FA���
���������A�BCDECF����E�������F�����������BC��F����F�F����F
��������BCD����� F!D��
"A��#�$F���%���#�������F�&�'F�F�(
)F��#�F��������*��+C���F��,EC��BF�F�E�• �-./.�
� �
��������ABCDE�F����B��� ���������� �ABC�DE�FB����F��� �����AB����F��
�FEF��DCB�BAF��������AF�F�F��B���FA�EF���A��FEF�F��B��
������B��������� ������B����B������
������B�����
��������
��������
� �
��������ABCDE�F����B��� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F������������
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link type="text/css" rel="stylesheet" href="Ipk.css">
<link rel="stylesheet" type="text/css" href="gxt/css/gxt-all.css" /> <title>Indeks Prestasi Mahasiswa</title> <script type="text/javascript" language="javascript" src="ipk/ipk.nocache.js"></script> </head> <body> <div id="main"></div> </body></html>
� �
��������ABCDE�F����B��� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F���EB������ABCDE��E��D�������
package com.ft.project.client;
import com.extjs.gxt.ui.client.Style.LayoutRegion;import com.extjs.gxt.ui.client.widget.ContentPanel;import com.extjs.gxt.ui.client.widget.Viewport;import com.extjs.gxt.ui.client.widget.layout.BorderLayout;import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;import com.google.gwt.core.client.EntryPoint;import com.google.gwt.user.client.ui.RootPanel;
public class Ipk implements EntryPoint {
public void onModuleLoad() {ContentPanel cpMhs=new ContentPanel();cpMhs.setHeading("Daftar Mahasiswa");
ContentPanel cpMk=new ContentPanel();cpMk.setHeading("Daftar Mata Kuliah");
ContentPanel cpNilai=new ContentPanel();cpNilai.setHeading("Daftar Nilai");
Viewport vp = new Viewport();vp.setLayout(new BorderLayout());
vp.add(cpMhs, new BorderLayoutData(LayoutRegion.CENTER));
BorderLayoutData east=new BorderLayoutData(LayoutRegion.EAST);east.setSplit(true);east.setSize(0.5f);vp.add(cpMk, east);
BorderLayoutData south=new BorderLayoutData(LayoutRegion.SOUTH);south.setSplit(true);south.setSize(0.5f);vp.add(cpNilai, south);
RootPanel rp=RootPanel.get("main");rp.add(vp);
}}
� �
��������ABCDE�F����B��� ���������� �ABC�DE�FB����F��� �����AB����F��
�������B���DDE��FA���
�ABC
DEAF
E�B
DEAF
���B�
DEAF
� �
��������ABCDE�F��B�D�� �D!�"B��AB��DA
� ���������� �ABC�DE�FB����F��� �����AB����F��
E�������������������������������������� ��!"��#!����������$
%����&�����������E����&������'����$���D �� E���F�� ���F�� !EE�"F���
package com.ft.project.client;
import com.extjs.gxt.ui.client.event.EventType;
public class AppEvents {public static final EventType Init = new EventType();
}
� �
��������ABCDE�F��B�D�� �D!�"B��AB��DA
� ���������� �ABC�DE�FB����F��� �����AB����F��
%����&�����������E����&������"��#$���D��� E���F�� ���F�� D"� !EE#�F�package com.ft.project.client.mvc;
import com.extjs.gxt.ui.client.Style.LayoutRegion;import com.extjs.gxt.ui.client.mvc.AppEvent;import com.extjs.gxt.ui.client.mvc.Controller;import com.extjs.gxt.ui.client.mvc.View;import com.extjs.gxt.ui.client.widget.ContentPanel;import com.extjs.gxt.ui.client.widget.Viewport;import com.extjs.gxt.ui.client.widget.layout.BorderLayout;import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;import com.ft.project.client.AppEvents;import com.google.gwt.user.client.ui.RootPanel;
public class AppView extends View {
public AppView(Controller controller) {super(controller);
}
@Override protected void handleEvent(AppEvent event) {if(event.getType()==AppEvents.Init) {
initUI();}
}
����(����������������������������)))
� �
��������ABCDE�F��B�D�� �D!�"B��AB��DA
� ���������� �ABC�DE�FB����F��� �����AB����F��
���(����� �����������������������)))protected void initUI() {
ContentPanel cpMhs=new ContentPanel();cpMhs.setHeading("Daftar Mahasiswa (MVC)");
ContentPanel cpMk=new ContentPanel();cpMk.setHeading("Daftar Mata Kuliah (MVC)");
ContentPanel cpNilai=new ContentPanel();cpNilai.setHeading("Daftar Nilai (MVC)");
Viewport vp = new Viewport();vp.setLayout(new BorderLayout());
vp.add(cpMhs, new BorderLayoutData(LayoutRegion.CENTER));
BorderLayoutData east=new BorderLayoutData(LayoutRegion.EAST);east.setSplit(true);east.setSize(0.5f);vp.add(cpMk, east);
BorderLayoutData south=new BorderLayoutData(LayoutRegion.SOUTH);south.setSplit(true);south.setSize(0.5f);vp.add(cpNilai, south);
RootPanel rp=RootPanel.get("main");rp.add(vp);
}}
� �
��������ABCDE�F��B�D�� �D!�"B��AB��DA
� ���������� �ABC�DE�FB����F��� �����AB����F��
%����&���������������������$���D��� E���F�� ���F�� D"� !EE$�������F�package com.ft.project.client.mvc;
import com.extjs.gxt.ui.client.event.EventType;import com.extjs.gxt.ui.client.mvc.AppEvent;import com.extjs.gxt.ui.client.mvc.Controller;import com.ft.project.client.AppEvents;
public class AppController extends Controller {private AppView appView;
public AppController() {registerEventTypes(AppEvents.Init);
}
@Override protected void initialize() {super.initialize();appView=new AppView(this);
}
@Overridepublic void handleEvent(AppEvent event) {
EventType ev=event.getType();if(ev==AppEvents.Init){
forwardToView(appView, event);}
}}
� �
��������ABCDE�F��B�D�� �D!�"B��AB��DA
� ���������� �ABC�DE�FB����F��� �����AB����F��
�� ������������D��� E���F�� ���F�� �E%
package com.ft.project.client;
import com.extjs.gxt.ui.client.mvc.Dispatcher;import com.ft.project.client.mvc.AppController;import com.google.gwt.core.client.EntryPoint;
public class Ipk implements EntryPoint {
public void onModuleLoad() {Dispatcher dispatcher = Dispatcher.get();dispatcher.addController(new AppController());dispatcher.dispatch(AppEvents.Init);
}}
� �
��������ABCDE�F����B��� ���������� �ABC�DE�FB����F��� �����AB����F��
�������B���DDE��FA���
� �
�����������ABCBA��DDE��FA���
���������A�BCDECF����E�������F�����������BC��F����F�F����F
��������BCD����� DE����F�� DED��
!A��"�#F���$���"�������F�%�&F�F�'
(F��"�F��������)��*C���F��+EC��BF�F�E�• �,-.-�
� �
��������ABCDE�F��B���������B�B��� ���������� �ABC�DE�FB����F��� �����AB����F��
����������AB�C�CAC�DCB���D�A�
���EF�B��C�����E������CA�
DF�����F�B�F��F�B�������FB������FC��BDF�����B F�B�EE��������
� �
��������ABCDE�F��B���������B�B��� ���������� �ABC�DE�FB����F��� �����AB����F��
�B�DFA�F���EB�B���AD���������� �C�!E��C�A��FEF����CB�A�C��E����FEF��DC��B���D�
� �
��������ABCDE�F��B���������B�B��� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F���"�#��$���%�<?xml version="1.0" encoding="UTF-8"?><module rename-to='ipk'> <!-- Inherit the core Web Toolkit stuff. --> <inherits name='com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. You can change --> <!-- the theme of your GWT application by uncommenting --> <!-- any one of the following lines. --> <inherits name='com.google.gwt.user.theme.standard.Standard'/> <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> --> <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits --> <inherits name='com.extjs.gxt.ui.GXT'/>
<!-- Specify the app entry point class. --> <entry-point class='com.ft.project.client.Ipk'/>
<!-- Specify the paths for translatable code --> <source path='client'/> <source path='shared'/>
<extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.rpc.SerializableException"/> <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.ChangeListenerCollection"/> <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.ClickListenerCollection"/> <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.FocusListenerCollection"/> <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.FormHandlerCollection"/> <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.KeyboardListenerCollection"/> <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.LoadListenerCollection"/> <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.MouseListenerCollection"/> <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.MouseWheelListenerCollection"/> <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.PopupListenerCollection"/> <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.ScrollListenerCollection"/> <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.TabListenerCollection"/> <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.TableListenerCollection"/> <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.TreeListenerCollection"/></module>
� �
��������ABCDE�F��B���������B�B��� ���������� �ABC�DE�FB����F��� �����AB����F��
�CBFAB��BC�FE��F�EB��EF���EB%�&���ABCDE���'�AD��(�DA�
package com.ft.project.shared;
import java.io.Serializable;
@SuppressWarnings("serial")public class User implements Serializable {
private String name;private String password;
public User() {super();
}public User(String name, String password) {
super();this.name = name;this.password = password;
}
public String getName() {return name;
}public void setName(String name) {
this.name = name;}
public String getPassword() {return password;
}public void setPassword(String password) {
this.password = password;}
public void clear() {this.name=null;this.password=null;
}
public void copy(final User from) {this.name=from.name;this.password=from.password;
}}
� �
��������ABCDE�F��B���������B�B��� ���������� �ABC�DE�FB����F��� �����AB����F��
��FA��ABC�F�B�EB%�&���ABCDE��E��D���)DE�A��*)DA+�ED�
package com.ft.project.client;
import com.ft.project.shared.User;import com.google.gwt.user.client.rpc.RemoteService;import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("security")public interface SecurityService extends RemoteService {
Boolean login(User user) throws Exception;}
� �
��������ABCDE�F��B���������B�B��� ���������� �ABC�DE�FB����F��� �����AB����F��
��FA��ABC�F�B�EB%�&���ABCDE��E��D���)DE�A��*)DA+�ED,�*�E�
package com.ft.project.client;
import com.ft.project.shared.User;import com.google.gwt.user.client.rpc.AsyncCallback;
public interface SecurityServiceAsync {void login(User user, AsyncCallback<Boolean> callback);
}
� �
��������ABCDE�F��B���������B�B��� ���������� �ABC�DE�FB����F��� �����AB����F��
��FA��EF����B��AB BC!��B BC!EBA�EB%�&���ABCDE���DA+DA�)DE�A��*)DA+�ED"%���
package com.ft.project.server;
import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;
import com.ft.project.client.SecurityService;import com.ft.project.shared.User;import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@SuppressWarnings("serial")public class SecurityServiceImpl extends RemoteServiceServlet implements SecurityService {
@Override public Boolean login(User user) throws Exception {try {
Class.forName("org.postgresql.Driver");Connection c =DriverManager.getConnection(
"jdbc:postgresql://127.0.0.1/unp", user.getName(), user.getPassword());
c.close();} catch (ClassNotFoundException cnfe) {
throw new RuntimeException(cnfe.getMessage());} catch (SQLException se) {
throw new RuntimeException(se.getMessage());}return true;
}}
� �
��������ABCDE�F��B���������B�B��� ���������� �ABC�DE�FB����F��� �����AB����F��
"F�AFC�F��BC!EBA��B��FEF��$D!��%��
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app> <!-- Servlets --> <servlet> <servlet-name>securityServlet</servlet-name> <servlet-class>com.ft.project.server.SecurityServiceImpl</servlet-class> </servlet> <servlet-mapping> <servlet-name>securityServlet</servlet-name> <url-pattern>/ipk/security</url-pattern> </servlet-mapping> <!-- Default page to serve --> <welcome-file-list> <welcome-file>Ipk.html</welcome-file> </welcome-file-list>
</web-app>
� �
��������ABCDE�F��B���������B�B��� ���������� �ABC�DE�FB����F��� �����AB����F��
�B�F�AFC�F�#!BA�$�%���F�&$�%���B��FEF��,���+D����
package com.ft.project.client;
import com.extjs.gxt.ui.client.event.EventType;
public class AppEvents {public static final EventType Init = new EventType();public static final EventType Login = new EventType();public static final EventType OnLogin = new EventType();
}
� �
��������ABCDE�F��B���������B�B��� ���������� �ABC�DE�FB����F��� �����AB����F��
�CBFAB�EB%�&���ABCDE��E��D����B���-���B��package com.ft.project.client;
import com.extjs.gxt.ui.client.event.ButtonEvent;import com.extjs.gxt.ui.client.event.Listener;import com.extjs.gxt.ui.client.event.MessageBoxEvent;import com.extjs.gxt.ui.client.event.SelectionListener;import com.extjs.gxt.ui.client.mvc.Dispatcher;import com.extjs.gxt.ui.client.widget.Dialog;import com.extjs.gxt.ui.client.widget.MessageBox;import com.extjs.gxt.ui.client.widget.button.Button;import com.extjs.gxt.ui.client.widget.form.TextField;import com.extjs.gxt.ui.client.widget.layout.FormLayout;import com.ft.project.shared.User;import com.google.gwt.core.client.GWT;import com.google.gwt.user.client.rpc.AsyncCallback;
public class LoginDialog extends Dialog {
private TextField<String> userName;private TextField<String> password;protected Button login;private final SecurityServiceAsync mProxy;private User user;
�C��A�FBD�A�D��������A�E��CDFBA������
� �
��������ABCDE�F��B���������B�B��� ���������� �ABC�DE�FB����F��� �����AB����F��
public LoginDialog() {super();
mProxy = GWT.create(SecurityService.class);user=new User();
FormLayout layout = new FormLayout(); layout.setLabelWidth(90); layout.setDefaultWidth(155); setLayout(layout);
setModal(true); userName = new TextField<String>(); userName.setFieldLabel("Username"); add(userName); password = new TextField<String>(); password.setFieldLabel("Password"); password.setPassword(true); add(password); login=new Button("login"); login.addSelectionListener(new SelectionListener<ButtonEvent>() { public void componentSelected(ButtonEvent ce) { onLogin(); } }); addButton(login);}
��A�FB�A����C�������A��E��F�A������
� �
��������ABCDE�F��B���������B�B��� ���������� �ABC�DE�FB����F��� �����AB����F��
@Override public void onAttach() {super.onAttach();userName.setValue("");password.setValue("");user.clear();setFocusWidget(userName);
}
private void onLogin() {user.setName(userName.getValue());user.setPassword(password.getValue());mProxy.login(user, new AsyncCallback<Boolean>() {
public void onFailure(Throwable caught) {MessageBox.alert("Login", caught.getMessage(),
new Listener<MessageBoxEvent>(){@Override public void handleEvent(MessageBoxEvent be){
setFocusWidget(userName);}
});}public void onSuccess(Boolean ok) {
Dispatcher dispatcher = Dispatcher.get();dispatcher.dispatch(AppEvents.OnLogin);LoginDialog.this.hide();
}});
}
public User getUser() {return user;
}}
��A�FB�A����C�������A��E��F�A������
� �
��������ABCDE�F��B���������B�B��� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F���,��.B��AB��DA�
package com.ft.project.client.mvc;
import com.extjs.gxt.ui.client.event.EventType;import com.extjs.gxt.ui.client.mvc.AppEvent;import com.extjs.gxt.ui.client.mvc.Controller;import com.ft.project.client.AppEvents;import com.ft.project.client.LoginDialog;
public class AppController extends Controller {private AppView appView;private LoginDialog login;
public AppController() {registerEventTypes(AppEvents.Init);registerEventTypes(AppEvents.Login);registerEventTypes(AppEvents.OnLogin);
}
@Override protected void initialize() {super.initialize();appView=new AppView(this);
}
@Override public void handleEvent(AppEvent event) {EventType ev=event.getType();if(ev==AppEvents.Init){
forwardToView(appView, event);} else if(ev==AppEvents.Login) {
if(login==null) {login=new LoginDialog();
}login.show();
} else if(ev==AppEvents.OnLogin) {login.hide();
}}
}
� �
��������ABCDE�F��B���������B�B��� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F���,��/�D$�
protected void initUI() {ContentPanel cpMhs=new ContentPanel();cpMhs.setHeading("Daftar Mahasiswa (MVC)");ToolBar tb=new ToolBar();Button btn=new Button("Logout");btn.addSelectionListener(new SelectionListener<ButtonEvent>(){
@Override public void componentSelected(ButtonEvent ce) {Dispatcher.get().dispatch(AppEvents.Login);
}});tb.add(btn);cpMhs.setTopComponent(tb);
… selanjutnya tidak berubah ...}
� �
��������ABCDE�F��B���������B�B��� ���������� �ABC�DE�FB����F��� �����AB����F��
���D�EB�EFE��������'B���DDE��FA���
� �
�����������ABCBA��DDE��FA���
���������A�BCDECF����E�������F�����������BC��F����F�F����F
��������BCD����� F!�FC��F�F����F
"A��#�$F���%���#�������F�&�'F�F�(
)F��#�F��������*��+C���F��,EC��BF�F�E�• �-./.�
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
����������AB�C�CAC�DCB���D�A�
DF�����F�B������B���������B����B�F� F�B����!��FB������FC"#BDF���$�B�F!B�EE��������
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
�CBFAB��BC�FE��F�EB��EF���EB������ABCDE�����AD������������
package com.ft.project.shared;
import java.io.Serializable;
@SuppressWarnings("serial")public class Mahasiswa implements BeanModelTag, Serializable {
private int id;private String nim;private String name;
public Mahasiswa(){}public Mahasiswa(int id, String nim, String name) {
super();this.id = id;this.nim = nim;this.name = name;
}public int getId() {
return id;}public void setId(int id) {
this.id = id;}public String getNim() {
return nim;}public void setNim(String nim) {
this.nim = nim;}public String getName() {
return name;}public void setName(String name) {
this.name = name;}public void copy(final Mahasiswa from) {
this.id = from.id;this.nim = from.nim;this.name = from.name;
}}
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
��FA��ABC�F�B�EB������ABCDE��E��D�������������DA��ED�
package com.ft.project.client;
import com.extjs.gxt.ui.client.data.ListLoadResult;import com.ft.project.shared.Mahasiswa;import com.ft.project.shared.User;import com.google.gwt.user.client.rpc.RemoteService;import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("mahasiswa")public interface MahasiswaService extends RemoteService {
public ListLoadResult<Mahasiswa> query(User user) throws Exception;}
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
��FA��ABC�F�B�EB������ABCDE��E��D�������������DA��ED �!�E�
package com.ft.project.client;
import com.extjs.gxt.ui.client.data.ListLoadResult;import com.ft.project.shared.Mahasiswa;import com.ft.project.shared.User;import com.google.gwt.user.client.rpc.AsyncCallback;
public interface MahasiswaServiceAsync {public void query(User user, AsyncCallback<ListLoadResult<Mahasiswa>> callback);
}
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
��FA��EF����B��AB�BC���B�BC�EBA�EB������ABCDE���DA�DA�����������DA��ED"����
package com.ft.project.server;
import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.util.ArrayList;import java.util.List;
import com.extjs.gxt.ui.client.data.BaseListLoadResult;import com.extjs.gxt.ui.client.data.ListLoadResult;import com.ft.project.client.MahasiswaService;import com.ft.project.shared.Mahasiswa;import com.ft.project.shared.User;import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@SuppressWarnings("serial")public class MahasiswaServiceImpl extends RemoteServiceServlet implements MahasiswaService {
EC��AF�BD�A�D��������A����CD�BA������
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
@Override public ListLoadResult<Mahasiswa> query(User user) throws Exception {List<Mahasiswa> mhs=new ArrayList<Mahasiswa>();Connection c=null;try {
Class.forName("org.postgresql.Driver");c =DriverManager.getConnection("jdbc:postgresql://127.0.0.1/unp", user.getName(), user.getPassword());c.setAutoCommit(false);c.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
Statement stmt=c.createStatement();stmt.execute("BEGIN");stmt.close();
PreparedStatement prepStmt = c.prepareStatement("SELECT * FROM ft.mahasiswa_query()");ResultSet rs = prepStmt.executeQuery();while (rs.next()) {
mhs.add( new Mahasiswa(rs.getInt("i_id"), rs.getString("s_nim"), rs.getString("s_nama") ));
}rs.close();prepStmt.close();
c.commit();c.close();
} catch (ClassNotFoundException cnfe) {throw new RuntimeException(cnfe.getMessage());
} catch (SQLException se) {if(c!=null && !c.isClosed()) {
c.rollback();c.close();
}throw new RuntimeException(se.getMessage());
}return new BaseListLoadResult<Mahasiswa>(mhs);
}}
��AF�B�A�E��C�������A�������A������
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
�F�AFC�F��BC�EBA��B��FEF���D#�����<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app> <!-- Servlets --> <servlet> <servlet-name>securityServlet</servlet-name> <servlet-class>com.ft.project.server.SecurityServiceImpl</servlet-class> </servlet> <servlet-mapping> <servlet-name>securityServlet</servlet-name> <url-pattern>/ipk/security</url-pattern> </servlet-mapping>
<servlet> <servlet-name>mahasiswaServlet</servlet-name> <servlet-class>com.ft.project.server.MahasiswaServiceImpl</servlet-class> </servlet> <servlet-mapping> <servlet-name>mahasiswaServlet</servlet-name> <url-pattern>/ipk/mahasiswa</url-pattern> </servlet-mapping> <!-- Default page to serve --> <welcome-file-list> <welcome-file>Ipk.html</welcome-file> </welcome-file-list>
</web-app>
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
�B�F�AFC�F�!�BA��B�CB�� F�F���"F��B��FEF�� ����D����package com.ft.project.client;
import com.extjs.gxt.ui.client.event.EventType;
public class AppEvents {public static final EventType Init = new EventType();public static final EventType Login = new EventType();public static final EventType OnLogin = new EventType();public static final EventType GetUser = new EventType();public static final EventType RefreshMahasiswa = new EventType();
}
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
�CBFAB�#FBE�EB������ABCDE��E��D������$D����D�����������package com.ft.project.client.widget;
import java.util.ArrayList;import java.util.List;
import com.extjs.gxt.ui.client.data.BaseListLoader;import com.extjs.gxt.ui.client.data.BeanModel;import com.extjs.gxt.ui.client.data.BeanModelReader;import com.extjs.gxt.ui.client.data.ListLoadResult;import com.extjs.gxt.ui.client.data.ListLoader;import com.extjs.gxt.ui.client.data.LoadEvent;import com.extjs.gxt.ui.client.data.RpcProxy;import com.extjs.gxt.ui.client.event.ButtonEvent;import com.extjs.gxt.ui.client.event.Listener;import com.extjs.gxt.ui.client.event.LoadListener;import com.extjs.gxt.ui.client.event.MessageBoxEvent;import com.extjs.gxt.ui.client.event.SelectionListener;import com.extjs.gxt.ui.client.mvc.Dispatcher;import com.extjs.gxt.ui.client.store.ListStore;import com.extjs.gxt.ui.client.widget.ContentPanel;import com.extjs.gxt.ui.client.widget.MessageBox;import com.extjs.gxt.ui.client.widget.button.Button;import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;import com.extjs.gxt.ui.client.widget.grid.ColumnModel;import com.extjs.gxt.ui.client.widget.grid.EditorGrid;import com.extjs.gxt.ui.client.widget.layout.FitLayout;import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;import com.ft.project.client.AppEvents;import com.ft.project.client.MahasiswaService;import com.ft.project.client.MahasiswaServiceAsync;import com.ft.project.shared.Mahasiswa;import com.ft.project.shared.User;import com.google.gwt.core.client.GWT;import com.google.gwt.user.client.rpc.AsyncCallback;
EC��AF�BD�A�D��������A����CD�BA������
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
public class PanelMahasiswa extends ContentPanel {private MahasiswaServiceAsync proxy;private EditorGrid<BeanModel> grid;
public PanelMahasiswa() {super();setHeading("Daftar Mahasiswa");setTopComponent(createToolbar());
ListStore<BeanModel> store=createStore();ColumnModel cm=createColumnModel();grid=new EditorGrid<BeanModel>(store, cm);grid.setLoadMask(true);
setLayout(new FitLayout());add(grid);
}
��AF�B�A�E��C�������A�������A������
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
private ToolBar createToolbar() {final Button btnLogout=new Button("Logout");final Button btnRefresh=new Button("Refresh");SelectionListener<ButtonEvent> lsn=new SelectionListener<ButtonEvent>(){
@Override public void componentSelected(ButtonEvent ce) {Button btn=ce.getButton();if(btn==btnLogout) {
Dispatcher.get().dispatch(AppEvents.Login);} else if(btn==btnRefresh) {
refresh();}
}};btnLogout.addSelectionListener(lsn);btnRefresh.addSelectionListener(lsn);ToolBar tb=new ToolBar();tb.add(btnLogout);tb.add(btnRefresh);return tb;
}
��AF�B�A�E��C�������A�������A������
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
private ColumnModel createColumnModel() {List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig(); column.setId("nim"); column.setHeader("NIM"); column.setWidth(150);configs.add(column);
column = new ColumnConfig(); column.setId("name"); column.setHeader("Name"); column.setWidth(200);configs.add(column);
return new ColumnModel(configs); }
��AF�B�A�E��C�������A�������A������
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
private ListStore<BeanModel> createStore() {proxy=GWT.create(MahasiswaService.class);RpcProxy<ListLoadResult<Mahasiswa>> rpc = new RpcProxy<ListLoadResult<Mahasiswa>>() {
@Override public void load(Object loadConfig, AsyncCallback<ListLoadResult<Mahasiswa>> callback) {
User usr=new User();Dispatcher.get().dispatch(AppEvents.GetUser, usr);proxy.query(usr,callback);
} }; final ListLoader<ListLoadResult<BeanModel>> loader =
new BaseListLoader<ListLoadResult<BeanModel>>( rpc, new BeanModelReader());
loader.addLoadListener(new LoadListener(){@Override public void loaderLoadException(LoadEvent le) {
super.loaderLoadException(le);MessageBox.alert("Mahasiswa", le.exception.getMessage
(), new Listener<MessageBoxEvent>(){@Override public void handleEvent(MessageBoxEvent be){}
});
}});return new ListStore<BeanModel>(loader);
}
��AF�B�A�E��C�������A�������A������
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
public void refresh() {grid.getStore().getLoader().load(null);
}}
��AF�B�A�E��C�������A�������A������
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F��� ��%�D��public class AppView extends View {
private PanelMahasiswa cpMhs=new PanelMahasiswa();public AppView(Controller controller) {
super(controller);}@Override protected void handleEvent(AppEvent event) {
if(event.getType()==AppEvents.Init) {initUI();
} else if(event.getType()==AppEvents.RefreshMahasiswa) {cpMhs.refresh();
}}protected void initUI() {
cpMhs=new PanelMahasiswa();
ContentPanel cpMk=new ContentPanel();cpMk.setHeading("Daftar Mata Kuliah (MVC)");
ContentPanel cpNilai=new ContentPanel();cpNilai.setHeading("Daftar Nilai (MVC)");
Viewport vp = new Viewport();vp.setLayout(new BorderLayout());
vp.add(cpMhs, new BorderLayoutData(LayoutRegion.CENTER));
BorderLayoutData east=new BorderLayoutData(LayoutRegion.EAST);east.setSplit(true);east.setSize(0.5f);vp.add(cpMk, east);
BorderLayoutData south=new BorderLayoutData(LayoutRegion.SOUTH);south.setSplit(true);south.setSize(0.5f);vp.add(cpNilai, south);
RootPanel rp=RootPanel.get("main");rp.add(vp);
}}
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F��� ��&B��AB��DA�public class AppController extends Controller {
private AppView appView;private LoginDialog login;
public AppController() {registerEventTypes(AppEvents.Init);registerEventTypes(AppEvents.Login);registerEventTypes(AppEvents.OnLogin);
registerEventTypes(AppEvents.GetUser);registerEventTypes(AppEvents.RefreshMahasiswa);
}
@Override protected void initialize() {super.initialize();appView=new AppView(this);
}
@Overridepublic void handleEvent(AppEvent event) {
EventType ev=event.getType();if(ev==AppEvents.Init){
forwardToView(appView, event);} else if(ev==AppEvents.Login) {
if(login==null) {login=new LoginDialog();
}login.show();
} else if(ev==AppEvents.OnLogin) {login.hide();
Dispatcher.get().dispatch(AppEvents.RefreshMahasiswa);} else if(ev==AppEvents.GetUser) {
User usr=(User)event.getData();usr.copy(login.getUser());
} else if(ev==AppEvents.RefreshMahasiswa) {forwardToView(appView, event);
}}
}
� �
��������ABCDE�F������A����������� ���������� �ABC�DE�FB����F��� �����AB����F��
���D�EB�EFE��������$B���DDE��FA���
� �
�����������ABCBA��DDE��FA���
���������A�BCDECF����E�������F�����������BC��F����F�F����F
��������BCD�����������F�F����F
A��!�"F���#���!�������F�$�%F�F�&
'F��!�F��������(��)C���F��*EC��BF�F�E�• �+,-,�
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
����������AB�C�CAC�DCB���D�A�
DF��F���B������B���������B����B�F��F�B������FB������FC!BDF���#�B�FB�EE��������
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F����ABC�F�B�EB������ABCDE��E��D�������������DA��ED�
package com.ft.project.client;
import com.extjs.gxt.ui.client.data.ListLoadResult;import com.ft.project.shared.Mahasiswa;import com.ft.project.shared.User;import com.google.gwt.user.client.rpc.RemoteService;import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("mahasiswa")public interface MahasiswaService extends RemoteService {
public ListLoadResult<Mahasiswa> query(User user) throws Exception;public List<Mahasiswa> update(User user, List<Mahasiswa> mhs) throws Exception;
}
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
��FA��ABC�F�B�EB������ABCDE��E��D�������������DA��ED�� �E�
package com.ft.project.client;
import com.extjs.gxt.ui.client.data.ListLoadResult;import com.ft.project.shared.Mahasiswa;import com.ft.project.shared.User;import com.google.gwt.user.client.rpc.AsyncCallback;
public interface MahasiswaServiceAsync {public void query(User user, AsyncCallback<ListLoadResult<Mahasiswa>> callback);public void update(User user, List<Mahasiswa> mhs, AsyncCallback<List<Mahasiswa>> callback);
}
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F���EB������ABCDE���DA�DA�����������DA��ED!����@Override public List<Mahasiswa> update(User user, List<Mahasiswa> mhs) throws Exception {
List<Mahasiswa> mhsOut=new ArrayList<Mahasiswa>();Connection c=null;try {
Class.forName("org.postgresql.Driver");c =DriverManager.getConnection("jdbc:postgresql://127.0.0.1/unp", user.getName(), user.getPassword());c.setAutoCommit(false);c.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
Statement stmt=c.createStatement();stmt.execute("BEGIN");stmt.close();
PreparedStatement prepStmt = c.prepareStatement("SELECT * FROM ft.mahasiswa_update(?,?,?)");for(Mahasiswa m : mhs) {
prepStmt.setInt(1, m.getId());prepStmt.setString(2, m.getNim());prepStmt.setString(3, m.getName());ResultSet rs=prepStmt.executeQuery();rs.next();mhsOut.add(new Mahasiswa(rs.getInt("i_id"),
rs.getString("s_nim"),rs.getString("s_nama")
));rs.close();
}prepStmt.close();
c.commit();c.close();
} catch (ClassNotFoundException cnfe) {throw new RuntimeException(cnfe.getMessage());
} catch (SQLException se) {if(c!=null && !c.isClosed()) {
c.rollback();c.close();
}throw new RuntimeException(se.getMessage());
}return mhsOut;
}
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F�����D�����������
private ToolBar createToolbar() {final Button btnLogout=new Button("Logout");final Button btnRefresh=new Button("Refresh");
final Button btnAdd=new Button("Add");final Button btnSave=new Button("Save");SelectionListener<ButtonEvent> lsn=new SelectionListener<ButtonEvent>(){
@Override public void componentSelected(ButtonEvent ce) {Button btn=ce.getButton();if(btn==btnLogout) {
Dispatcher.get().dispatch(AppEvents.Login);} else if(btn==btnRefresh) {
refresh();
} else if(btn==btnAdd) {add();
} else if(btn==btnSave) {save();
}}
};btnLogout.addSelectionListener(lsn);btnRefresh.addSelectionListener(lsn);
btnAdd.addSelectionListener(lsn);btnSave.addSelectionListener(lsn);ToolBar tb=new ToolBar();tb.add(btnLogout);tb.add(btnRefresh);
tb.add(btnAdd);tb.add(btnSave);return tb;
}
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F�����D�����������private void add() {
BeanModelFactory factory = BeanModelLookup.get().getFactory(Mahasiswa.class);grid.getStore().insert( factory.createModel(new Mahasiswa()), 0 );
}
private void save() {final List<Record> rec=grid.getStore().getModifiedRecords();if(rec.isEmpty()) {
return;}final List<Mahasiswa> mhs=new ArrayList<Mahasiswa>();for(Record r : rec) {
BeanModel bm=(BeanModel)r.getModel();mhs.add( (Mahasiswa)bm.getBean() );
}User usr=new User();Dispatcher.get().dispatch(AppEvents.GetUser, usr);proxy.update(usr, mhs, new AsyncCallback<List<Mahasiswa>>(){
@Override public void onFailure(Throwable caught) {MessageBox.alert("Mahasiswa", caught.getMessage
(), new Listener<MessageBoxEvent>(){@Override public void handleEvent(MessageBoxEvent be){}
});
}@Override public void onSuccess(List<Mahasiswa> result) {
for(int r=0,rl=result.size();r<rl;++r){mhs.get(r).copy(result.get(r));
}for(Record r : rec){
r.commit(false);}
}});
}
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F�����D�����������
private ColumnModel createColumnModel() {List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
CellEditor textEditor=new CellEditor(new TextField<String>());
ColumnConfig column = new ColumnConfig(); column.setId("nim"); column.setHeader("NIM"); column.setWidth(150);
column.setEditor(textEditor);configs.add(column);
column = new ColumnConfig(); column.setId("name"); column.setHeader("Name"); column.setWidth(200);
column.setEditor(textEditor);configs.add(column);
return new ColumnModel(configs); }
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
���D�EB�EFE���������B���DDE��FA���
� �
�����������ABCBA��DDE��FA���
���������A�BCDECF����E�������F�����������BC��F����F�F����F
��������BCD����� F!����F�F����F
"A��#�$F���%���#�������F�&�'F�F�(
)F��#�F��������*��+C���F��,EC��BF�F�E�• �-./.�
� �
��������ABCDE�F����������������� ���������� �ABC�DE�FB����F��� �����AB����F��
����������AB�C�CAC�DCB���D�A�
DF����E��B������B���������B����B�F� F�B����!��FB������FC"#BDF�����B�F!B�EE��������
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F����ABC�F�B�EB������ABCDE��E��D�������������DA �ED�
package com.ft.project.client;
import com.extjs.gxt.ui.client.data.ListLoadResult;import com.ft.project.shared.Mahasiswa;import com.ft.project.shared.User;import com.google.gwt.user.client.rpc.RemoteService;import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("mahasiswa")public interface MahasiswaService extends RemoteService {
public ListLoadResult<Mahasiswa> query(User user) throws Exception;public List<Mahasiswa> update(User user, List<Mahasiswa> mhs) throws Exception;public Boolean del(User user, List<Integer> ids) throws Exception;
}
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
��FA��ABC�F�B�EB������ABCDE��E��D�������������DA �ED!�"�E�
package com.ft.project.client;
import com.extjs.gxt.ui.client.data.ListLoadResult;import com.ft.project.shared.Mahasiswa;import com.ft.project.shared.User;import com.google.gwt.user.client.rpc.AsyncCallback;
public interface MahasiswaServiceAsync {public void query(User user, AsyncCallback<ListLoadResult<Mahasiswa>> callback);public void update(User user, List<Mahasiswa> mhs, AsyncCallback<List<Mahasiswa>> callback);
public void del(User user, List<Integer> ids, AsyncCallback<Boolean> callback);}
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
�CBFAB�EB������ABCDE���DA DA�B��#AD�$%&��'!AA�"�
package com.ft.project.server;
import java.sql.Array;import java.sql.ResultSet;import java.sql.SQLException;import java.util.Arrays;import java.util.List;import java.util.Map;
//source: http://valgogtech.blogspot.com/2009/02/passing-arrays-to-postgresql-database.htmlpublic class PostgreSQLInt4Array implements Array {
private final int[] intArray;private final String stringValue;
public PostgreSQLInt4Array(int[] intArray) {this.intArray = intArray;this.stringValue = intArrayToPostgreSQLInt4ArrayString(intArray);
}
public PostgreSQLInt4Array(List<Integer> ints) {int count=ints.size();this.intArray=new int[count];for(int i=0;i<count;++i){
this.intArray[i]=ints.get(i);}this.stringValue = intArrayToPostgreSQLInt4ArrayString(this.intArray);
}
EC��AF�BD�A�D��������A����CD�BA������
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
public String toString() { return stringValue;
}
public static String intArrayToPostgreSQLInt4ArrayString(int[] a) { if ( a == null ) { return "NULL"; } final int al = a.length; if ( al == 0 ) { return "{}"; } StringBuilder sb = new StringBuilder( 2 + al * 7 ); // as we usually operate with 6 digit
numbers + 1 symbol for a delimiting comma sb.append('{'); for (int i = 0; i < al; i++) { if ( i > 0 ) sb.append(','); sb.append(a[i]); } sb.append('}'); return sb.toString();
}
��AF�B�A�E��C�������A�������A������
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
public static String intArrayToCommaSeparatedString(int[] a) { if ( a == null ) { return "NULL"; } final int al = a.length; if ( al == 0 ) { return ""; } StringBuilder sb = new StringBuilder( al * 7 ); // as we usually operate with 6 digit
numbers + 1 symbol for a delimiting comma for (int i = 0; i < al; i++) { if ( i > 0 ) sb.append(','); sb.append(a[i]); } return sb.toString();
} @Override public void free() throws SQLException {}
@Override public Object getArray() throws SQLException {return intArray == null ? null : Arrays.copyOf(intArray, intArray.length);
}
@Override public Object getArray(Map<String, Class<?>> map) throws SQLException {return getArray();
}
@Override public Object getArray(long index, int count) throws SQLException {return intArray == null ? null : Arrays.copyOfRange(intArray, (int)index, (int)index +
count );}
��AF�B�A�E��C�������A�������A������
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
@Override public Object getArray(long index, int count, Map<String, Class<?>> map)throws SQLException {
return getArray(index, count);}
@Override public int getBaseType() throws SQLException {return java.sql.Types.INTEGER;
}
@Override public String getBaseTypeName() throws SQLException {return "int4";
}
@Override public ResultSet getResultSet() throws SQLException {throw new UnsupportedOperationException();
}
@Override public ResultSet getResultSet(Map<String, Class<?>> map)throws SQLException {
throw new UnsupportedOperationException();}
@Override public ResultSet getResultSet(long index, int count) throws SQLException {throw new UnsupportedOperationException();
}
@Override public ResultSet getResultSet(long index, int count,Map<String, Class<?>> map) throws SQLException {
throw new UnsupportedOperationException();}
}
��AF�B�A�E��C�������A�������A������
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F���EB������ABCDE���DA DA�����������DA �ED&����@Override public Boolean del(User user, List<Integer> ids) throws Exception {
Connection c=null;try {
Class.forName("org.postgresql.Driver");c =DriverManager.getConnection(
"jdbc:postgresql://127.0.0.1/unp", user.getName(), user.getPassword());c.setAutoCommit(false);c.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
Statement stmt=c.createStatement();stmt.execute("BEGIN");stmt.close();
PreparedStatement prepStmt = c.prepareStatement("SELECT ft.mahasiswa_delete(?)");prepStmt.setArray(1, new PostgreSQLInt4Array(ids));prepStmt.execute();prepStmt.close();
c.commit();c.close();
} catch (ClassNotFoundException cnfe) {throw new RuntimeException(cnfe.getMessage());
} catch (SQLException se) {if(c!=null && !c.isClosed()) {
c.rollback();c.close();
}throw new RuntimeException(se.getMessage());
}return true;
}
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F�����D�����������
private ToolBar createToolbar() {final Button btnLogout=new Button("Logout");final Button btnRefresh=new Button("Refresh");final Button btnAdd=new Button("Add");final Button btnSave=new Button("Save");
final Button btnDel=new Button("Delete");SelectionListener<ButtonEvent> lsn=new SelectionListener<ButtonEvent>(){
@Override public void componentSelected(ButtonEvent ce) {Button btn=ce.getButton();if(btn==btnLogout) {
Dispatcher.get().dispatch(AppEvents.Login);} else if(btn==btnRefresh) {
refresh();} else if(btn==btnAdd) {
add();} else if(btn==btnSave) {
save();
} else if(btn==btnDel) {del();
}}
};btnLogout.addSelectionListener(lsn);btnRefresh.addSelectionListener(lsn);btnAdd.addSelectionListener(lsn);btnSave.addSelectionListener(lsn);
btnDel.addSelectionListener(lsn);ToolBar tb=new ToolBar();tb.add(btnLogout);tb.add(btnRefresh);tb.add(btnAdd);tb.add(btnSave);
tb.add(btnDel);return tb;
}
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
�������F�����D�����������
private void del() {CellSelectionModel<BeanModel> sel=(CellSelectionModel<BeanModel>)grid.getSelectionModel();final BeanModel bm=sel.getSelectCell().model;if(bm==null) {
return;}final List<Integer> id=new ArrayList<Integer>();Mahasiswa mhs=(Mahasiswa)bm.getBean();id.add(mhs.getId());MessageBox.confirm("Mahasiswa", "Yakin akan menghapus?",
new Listener<MessageBoxEvent>(){public void handleEvent(MessageBoxEvent me){
if(me.getButtonClicked().getText().equalsIgnoreCase("Yes")){User usr=new User();Dispatcher.get().dispatch(AppEvents.GetUser, usr);proxy.del(usr, id, new AsyncCallback<Boolean>(){
@Override public void onFailure(Throwable caught) {MessageBox.alert("Mahasiswa", caught.getMessage
(), new Listener<MessageBoxEvent>(){@Override public void handleEvent(MessageBoxEvent be){}
});
}@Override public void onSuccess(Boolean result) {
grid.getStore().remove(bm);}
});}
}});
}
� �
��������ABCDE�F���������������� ���������� �ABC�DE�FB����F��� �����AB����F��
���D�EB�EFE���������B���DDE��FA���