You are on page 1of 92

1234

51678429ABC9BA43DDE67FA69
1234567869A8BCDECFE
38F898BC93F8FFF

599CF3985678F98BCD 9!3

"A8#F8$39938993F8%8&F3F'
1

(F3F8798)*9C3F8+9E9C8BFFE88,-.-8

123456537

89ABC5DE6FBF4

489ABF4

1232456271897A5BCD27E4F26

F97847E6DB47CBFAB4B4B43DDE67FA694CB7A

123456537

89ABC5DE6FBF4

489ABF4

1232456271897A5BCD27E4F26

B4B43DDE67FA694CB7A

123456537

89ABC5DE6FBF4

489ABF4

1232456271897A5BCD27E4F26

F9784B43DDE67FA69

74B67

123456537

89ABC5DE6FBF4

489ABF4

1232456271897A5BCD27E4F26

D41

123456537

89ABC5DE6FBF4

489ABF4

1232456271897A5BCD27E4F26

F9784 6CB!"#4FAB41

123456537

89ABC5DE6FBF4

489ABF4

1232456271897A5BCD27E4F26

$E6%4&'E4(B9)49A%4*B9F'D6E%F941BD9B4)FC64+F,F4(BC,EBA

123456537

89ABC5DE6FBF4

489ABF4

1897A5BCD27E4F26
F7F27678F4

BC6%F4%9!6-CF64)64)FEF'4!6EB42BD

12345267
1
8949AB59CCA
1
D96EA32596F42A6A29C2C9
9599AE65A23FCFA36A9FA
26A26A25

123456537

89ABC5DE6FBF4

489ABF4

1897A5BCD27E4F26
F7F27678F4

BC6%F4C6BD

A2A6A F26A9!5F9CF7
1
1
1

92"F25B69F23
C2#66B69F23
2333$925B69F23

123456537

89ABC5DE6FBF4

489ABF4

1897A5BCD27E4F26
F7F27678F4

BC6%F4%9!6-CF64)64)FEF'4!6EB4C6BD

%!!5F96F
&63A
DF6

123456537

89ABC5DE6FBF4

489ABF4

1897A5BCD27E4F26
F7F27678F4
BC6%F43DDE67FA6949AC469A

59CC7
D4EF467F241E

'6F7
2 !6F"5

123456537

89ABC5DE6FBF4

489ABF4

1897A5BCD27E4F26
F7F27678F4

.64)FEF'4!97A6949*)EBF)#4AB'%F947FCF4'B'FF9-46)-BA4%B4/&*49)B

A F267
1
1
1

C2#66
92"F25
2333$925

(F26AF)9669EA2A
2A*$

123456537

89ABC5DE6FBF4

489ABF4

1897A5BCD27E4F26
F7F27678F4

.64)FEF'4!97A6949*)EBF)#4AB'%F947FCF4'B9-F%A6!%F94+F,F4(BC,EBA

B32962A3262A
C234F2A!3+

123456537

89ABC5DE6FBF4

489ABF4

1897A5BCD27E4F26
F7F27678F4

.64)FEF'4!97A6949*)EBF)#4AB'%F947FCF4'B9-F%A6!%F94+F,F4(BC,EBA

E9523A6A
2426A5FA
D23E96F97A29A
C2
E9523A29F5A
'6FA
E9523A
6A2426A 3F2 #5DFACF$F
65A
293A
&,*&1

123456537

89ABC5DE6FBF4

489ABF4

1897A5BCD27E4F26
F7F27678F4

.64)FEF'4!97A6949*)EBF)#4AB'%F947FCF4'B9-F%A6!%F94+F,F4(BC,EBA

959A'6FA3F2 #5DFACF$F7
!29F59AC234526A2595FA!3+AFF472CF$7F

123456537

89ABC5DE6FBF4

489ABF4

1897A5BCD27E4F26
F7F27678F4

&B'%F94)B!696647EF4+F,F4(BC,EBA#46'DEB'B9AF64BC,BC06)B414BC,67B

1234
51678429ABC9BA43DDE67FA69
1234567869A8BCDECFE
38F898BC93F8FFF

3FC3E812345678BCD93

A!8"F8#39!938993F8$8%F3F&
1

'F!3F8798()9C3F8*9E9C8BFFE88+,-,8

1
1

123456537
89ABC5DE6FBF4

489ABF4

1234256789A2BCDE8F42

FEF4DCBB9AF6469646AF4FF94B9BCAFF94
A4B4FEF4DCB742D4F94ABEF846AF4
B9BCFAB4B9 9FF947E6DB

9A24328587A2B
B7258
8542458
36783638
23 5
1

1
1

123456537
89ABC5DE6FBF4

489ABF4

1234256789A2BCDE8F42

!B9BCAFF94E6A4A4"B4FEF4#CB42D
1234567589A5BC9ADE5FD3FE5CF35F55493252C5D4B3
12345759452C359232B5952C35 3B9A3B59DE3552C35E9D9FE5295F5
!9DE3F"3#5D9F2952C59A5F59DE351A$B22A235!9DE3F"3#52C5
2C35F"35952C359DE359A%353F23E5953B9A3B52C59A5F59DE35
12345&75'EE52C359DD9(5B2D3BC33252959A5C9B254F(37
<link rel="stylesheet" type="text/css" href="{foldername}/css/gxt-all.css" />
12345)75'EE52C359DD9(53252959A54932B5"9EAD35*"D5D37
<inherits name='com.extjs.gxt.ui.GXT'/>
12345+75*2553,A3B52C359DD9(5E92437
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
1 12345-75'EE57A2345295D$F3B555493252C5D4B3.
1

1
1

123456537
89ABC5DE6FBF4

489ABF4

1234256789A2BCDE8F42!
128"812

1234567589A5BC9ADE5FD3FE5CF35F55493252C5D4B3

12345267284522948A84B8924
5CD2E47CA1247F941E

1
1

123456537
89ABC5DE6FBF4

489ABF4

1234256789A2BCDE8F42!
128"812

12345759452C359232B5952C35 3B9A3B59DE3552C35E9D9FE5
295F5!9DE3F"3#5D9F2952C59A5F59DE351A$B22A235
!9DE3F"3#52C52C35F"35952C359DE359A%353F23E595
3B9A3B52C59A5F59DE35

714F3F3

FA264F3F3
9B4
1

1
1

123456537
89ABC5DE6FBF4

489ABF4

1234256789A2BCDE8F42!
128"812

12345&75'EE52C359DD9(5B2D3BC33252959A5C9B254F(37
<link rel="stylesheet" type="text/css" href="{foldername}/css/gxt-all.css" />
1E4D64D86D88B258452284F8BC942F852F85466A9492E4D8E27C5
<!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>
1 </table>
1
</body>
</html>

1
1

123456537
89ABC5DE6FBF4

489ABF4

1234256789A2BCDE8F42!
128"812

12345)75'EE52C359DD9(53252959A54932B5"9EAD35*"D5D37
<inherits name='com.extjs.gxt.ui.GXT'/>
1E4D64D86D88B258452284F8BC9
<?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>

1
1

123456537
89ABC5DE6FBF4

489ABF4

1234256789A2BCDE8F42!
128"812

12345+75*2553,A3B52C359DD9(5E92437
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
1E4D64D86D88B258452284F8BC9
<!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>
1 </table>
1
</body>
</html>

1
1

123456537
89ABC5DE6FBF4

489ABF4

1234256789A2BCDE8F42!
128"812

12345-75'EE57A2345295D$F3B555493252C5D4B3.

714453BF649472B2
1
947F954674D8FF91

1
1

123456537
89ABC5DE6FBF4

489ABF4

1234256789A2BCDE8F42!
128"812

12345-75'EE57A2345295D$F3B555493252C5D4B3.

1234
51678429ABC9BA43DDE67FA69
1234567869A8BCDECFE
38F898BC93F8FFF

12345678BCD938 F!D3

"A#8$F8%39#938993F8&8'F3F(
1

)F#3F8798*+9C3F8,9E9C8BFFE88-./.8

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B3

FEF4DCBB9AF6469646AF4FF94BFA4EFA4
8FEFF94B

545B553735

12345567
545B545B675
12345567

545B7657

123456537
89ABC5DE6FBF4

1
1

489ABF4

123456789ABCDE3F8B3

66F643
<!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>

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B3

66F64
EB3ABCDE3
ED3

package com.ft.project.client;
import
import
import
import
import
import
import

com.extjs.gxt.ui.client.Style.LayoutRegion;
com.extjs.gxt.ui.client.widget.ContentPanel;
com.extjs.gxt.ui.client.widget.Viewport;
com.extjs.gxt.ui.client.widget.layout.BorderLayout;
com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
com.google.gwt.core.client.EntryPoint;
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");
1
rp.add(vp);

1
}
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B3

19434B43DDE67FA69

89AB9C
DEA9F

9EB
DEA9F

B
DEA9F
1

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8BD4 D!4
"B3ABDA

E4567145657 63!"46#!8573367$
%5&3115E2234&549'651$D 4 EF4 67F24 !EE"F243
package com.ft.project.client;
import com.extjs.gxt.ui.client.event.EventType;
public class AppEvents {
public static final EventType Init = new EventType();
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8BD4 D!4
"B3ABDA

%5&3115E2234&54"46#$D 4 EF4 67F24 D" !EE#7F


package com.ft.project.client.mvc;
import
import
import
import
import
import
import
import
import
import

com.extjs.gxt.ui.client.Style.LayoutRegion;
com.extjs.gxt.ui.client.mvc.AppEvent;
com.extjs.gxt.ui.client.mvc.Controller;
com.extjs.gxt.ui.client.mvc.View;
com.extjs.gxt.ui.client.widget.ContentPanel;
com.extjs.gxt.ui.client.widget.Viewport;
com.extjs.gxt.ui.client.widget.layout.BorderLayout;
com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
com.ft.project.client.AppEvents;
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();
}
}

43(5636745)))

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8BD4 D!4
"B3ABDA

3(5 7431663)))
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);
}

1
1

123456537
89ABC5DE6FBF4

123456789ABCDE3F8BD4 D!4
"B3ABDA

489ABF4

%5&31158573367$D4 EF4 67F24 D" !EE$2466F


package com.ft.project.client.mvc;
import
import
import
import

com.extjs.gxt.ui.client.event.EventType;
com.extjs.gxt.ui.client.mvc.AppEvent;
com.extjs.gxt.ui.client.mvc.Controller;
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);
}
@Override
public void handleEvent(AppEvent event) {
EventType ev=event.getType();
if(ev==AppEvents.Init){
forwardToView(appView, event);
}
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8BD4 D!4
"B3ABDA

6 67D4 EF4 67F24 1E%


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);
}
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B3

19434B43DDE67FA69

1234
51678429ABC9BA43DDE67FA69
1234567869A8BCDECFE
38F898BC93F8FFF

12345678BCD938 DE8F8 DED3

!A"8#F8$39"938993F8%8&F3F'
1

(F"3F8798)*9C3F8+9E9C8BFFE88,-.-8

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B88BB3

12324567898AB29C5CAC5DCB252D2A5
484EF2B5C235E5CA
DF253F3B3FFB
54553FB34FCB
DF6567B FB5EE675472
1

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B88BB3

BDFAF946EB
B3AD44 C!ECA4
FEF46CBAC64E64FEF4DCB4
2D

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B88BB3

66F64"#$32%
<?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
<extend-configuration-property
<extend-configuration-property
<extend-configuration-property
<extend-configuration-property
<extend-configuration-property
<extend-configuration-property
<extend-configuration-property
<extend-configuration-property
<extend-configuration-property
<extend-configuration-property
<extend-configuration-property
<extend-configuration-property
<extend-configuration-property

</module>

-->
-->

name="rpc.blacklist"
name="rpc.blacklist"
name="rpc.blacklist"
name="rpc.blacklist"
name="rpc.blacklist"
name="rpc.blacklist"
name="rpc.blacklist"
name="rpc.blacklist"
name="rpc.blacklist"
name="rpc.blacklist"
name="rpc.blacklist"
name="rpc.blacklist"
name="rpc.blacklist"
name="rpc.blacklist"

value="com.google.gwt.user.client.rpc.SerializableException"/>
value="com.google.gwt.user.client.ui.ChangeListenerCollection"/>
value="com.google.gwt.user.client.ui.ClickListenerCollection"/>
value="com.google.gwt.user.client.ui.FocusListenerCollection"/>
value="com.google.gwt.user.client.ui.FormHandlerCollection"/>
value="com.google.gwt.user.client.ui.KeyboardListenerCollection"/>
value="com.google.gwt.user.client.ui.LoadListenerCollection"/>
value="com.google.gwt.user.client.ui.MouseListenerCollection"/>
value="com.google.gwt.user.client.ui.MouseWheelListenerCollection"/>
value="com.google.gwt.user.client.ui.PopupListenerCollection"/>
value="com.google.gwt.user.client.ui.ScrollListenerCollection"/>
value="com.google.gwt.user.client.ui.TabListenerCollection"/>
value="com.google.gwt.user.client.ui.TableListenerCollection"/>
value="com.google.gwt.user.client.ui.TreeListenerCollection"/>

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B88BB3
package com.ft.project.shared;

CBFAB4BC6FE6FEB47EF4
EB%&3ABCDE3'AD(DA

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;
}

1
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B88BB3

FA429ABCF7B4EB%&3ABCDE3ED3)DEA3*)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;
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B88BB3

FA429ABCF7B4
EB%&3ABCDE3ED3)DEA3*)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);
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B88BB3

FA4EF41BAB BC!67B BC!EBA4


EB%&3ABCDE3DA+DA)DEA3*)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;
1
1
}
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B88BB3

"FAFCF94BC!EBA4B4FEF4$D!2%
<?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>

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B88BB3

B9FAFCF94#!B9A4$%694F94&9$%694B4FEF4,1+D3
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();
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B88BB3

CBFAB4EB%&3ABCDE3ED3B-B
package com.ft.project.client;
import
import
import
import
import
import
import
import
import
import
import
import
import

com.extjs.gxt.ui.client.event.ButtonEvent;
com.extjs.gxt.ui.client.event.Listener;
com.extjs.gxt.ui.client.event.MessageBoxEvent;
com.extjs.gxt.ui.client.event.SelectionListener;
com.extjs.gxt.ui.client.mvc.Dispatcher;
com.extjs.gxt.ui.client.widget.Dialog;
com.extjs.gxt.ui.client.widget.MessageBox;
com.extjs.gxt.ui.client.widget.button.Button;
com.extjs.gxt.ui.client.widget.form.TextField;
com.extjs.gxt.ui.client.widget.layout.FormLayout;
com.ft.project.shared.User;
com.google.gwt.core.client.GWT;
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;
1
private User user;

C32AFBD2A5D8523242A5E87CDFBA25

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B88BB3

32AFB2A527C523242A598E83F4A25
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();
}
});
1
addButton(login);

1
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B88BB3

32AFB2A527C523242A598E83F4A25
@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;
1}
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

66F64
,.B3ABDA

123456789ABCDE3F8B88BB3
package com.ft.project.client.mvc;
import
import
import
import
import

com.extjs.gxt.ui.client.event.EventType;
com.extjs.gxt.ui.client.mvc.AppEvent;
com.extjs.gxt.ui.client.mvc.Controller;
com.ft.project.client.AppEvents;
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();
}1
}

1
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B88BB3

66F64,/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 ...
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8B88BB3

D6EB4EFE419434'B43DDE67FA69

1234
51678429ABC9BA43DDE67FA69
1234567869A8BCDECFE
38F898BC93F8FFF

12345678BCD938 F!3FC8FFF

"A#8$F8%39#938993F8&8'F3F(
1

)F#3F8798*+9C3F8,9E9C8BFFE88-./.8

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F83A8

12324567898AB29C5CAC5DCB252D2A5
DF253F3B545B
553735B57B3F FB
545!53FB34FC"#B
DF656$7BF!B5EE675472
1

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F83A8

CBFAB4BC6FE6FEB47EF4
EB3ABCDE3AD


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;
}1

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F83A8

FA429ABCF7B4
EB3ABCDE3ED3DAED
package com.ft.project.client;
import
import
import
import
import

com.extjs.gxt.ui.client.data.ListLoadResult;
com.ft.project.shared.Mahasiswa;
com.ft.project.shared.User;
com.google.gwt.user.client.rpc.RemoteService;
com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@RemoteServiceRelativePath("mahasiswa")
public interface MahasiswaService extends RemoteService {
public ListLoadResult<Mahasiswa> query(User user) throws Exception;
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F83A8

FA429ABCF7B4
EB3ABCDE3ED3DAED !E
package com.ft.project.client;
import
import
import
import

com.extjs.gxt.ui.client.data.ListLoadResult;
com.ft.project.shared.Mahasiswa;
com.ft.project.shared.User;
com.google.gwt.user.client.rpc.AsyncCallback;

public interface MahasiswaServiceAsync {


public void query(User user, AsyncCallback<ListLoadResult<Mahasiswa>> callback);
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F83A8

FA4EF41BABBC67BBCEBA4EB3ABCDE3DADADAED"
package com.ft.project.server;
import
import
import
import
import
import
import
import

java.sql.Connection;
java.sql.DriverManager;
java.sql.PreparedStatement;
java.sql.ResultSet;
java.sql.SQLException;
java.sql.Statement;
java.util.ArrayList;
java.util.List;

import
import
import
import
import
import

com.extjs.gxt.ui.client.data.BaseListLoadResult;
com.extjs.gxt.ui.client.data.ListLoadResult;
com.ft.project.client.MahasiswaService;
com.ft.project.shared.Mahasiswa;
com.ft.project.shared.User;
com.google.gwt.user.server.rpc.RemoteServiceServlet;

@SuppressWarnings("serial")
public class MahasiswaServiceImpl extends RemoteServiceServlet implements MahasiswaService {

EC32AFBD2A5D8523242A587CDBA25

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F83A8

32AFB2A5E27C523242A598834A25
@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();

1
}

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);
1

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F83A8

FAFCF94BCEBA4B4FEF4D#2
<?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>

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F83A8

B9FAFCF94!B9A41BCB8 F8F6"F4B4FEF4 1D3


package com.ft.project.client;
import com.extjs.gxt.ui.client.event.EventType;
public class AppEvents {
public static final EventType
public static final EventType
public static final EventType
public static final EventType
public static final EventType
}

Init = new EventType();


Login = new EventType();
OnLogin = new EventType();
GetUser = new EventType();
RefreshMahasiswa = new EventType();

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F83A8

CBFAB4#F9BE4EB3ABCDE3ED3$D39D
package com.ft.project.client.widget;
import java.util.ArrayList;
import java.util.List;
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
1import
import
import

com.extjs.gxt.ui.client.data.BaseListLoader;
com.extjs.gxt.ui.client.data.BeanModel;
com.extjs.gxt.ui.client.data.BeanModelReader;
com.extjs.gxt.ui.client.data.ListLoadResult;
com.extjs.gxt.ui.client.data.ListLoader;
com.extjs.gxt.ui.client.data.LoadEvent;
com.extjs.gxt.ui.client.data.RpcProxy;
com.extjs.gxt.ui.client.event.ButtonEvent;
com.extjs.gxt.ui.client.event.Listener;
com.extjs.gxt.ui.client.event.LoadListener;
com.extjs.gxt.ui.client.event.MessageBoxEvent;
com.extjs.gxt.ui.client.event.SelectionListener;
com.extjs.gxt.ui.client.mvc.Dispatcher;
com.extjs.gxt.ui.client.store.ListStore;
com.extjs.gxt.ui.client.widget.ContentPanel;
com.extjs.gxt.ui.client.widget.MessageBox;
com.extjs.gxt.ui.client.widget.button.Button;
com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
com.extjs.gxt.ui.client.widget.grid.ColumnModel;
com.extjs.gxt.ui.client.widget.grid.EditorGrid;
com.extjs.gxt.ui.client.widget.layout.FitLayout;
com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
com.ft.project.client.AppEvents;
com.ft.project.client.MahasiswaService;
com.ft.project.client.MahasiswaServiceAsync;
com.ft.project.shared.Mahasiswa;
com.ft.project.shared.User;
1
com.google.gwt.core.client.GWT;
com.google.gwt.user.client.rpc.AsyncCallback;

EC32AFBD2A5D8523242A587CDBA25

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F83A8

32AFB2A5E27C523242A598834A25
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);
}
1

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F83A8

32AFB2A5E27C523242A598834A25
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;
}
1

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F83A8

32AFB2A5E27C523242A598834A25
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);
}
1

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F83A8

32AFB2A5E27C523242A598834A25
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);
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F83A8

32AFB2A5E27C523242A598834A25
public void refresh() {
grid.getStore().getLoader().load(null);
}
}

1
1

123456537
89ABC5DE6FBF4

489ABF4


123456789ABCDE3F83A8

66F64 %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);

1}

1
1

123456537
89ABC5DE6FBF4

489ABF4


123456789ABCDE3F83A8

66F64 &B3ABDA

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);
}
@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();

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);
}
}
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F83A8

D6EB4EFE419434$B43DDE67FA69

1234
51678429ABC9BA43DDE67FA69
1234567869A8BCDECFE
38F898BC93F8FFF

12345678BCD938138FFF

A!8"F8#39!938993F8$8%F3F&
1

'F!3F8798()9C3F8*9E9C8BFFE88+,-,8

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

12324567898AB29C5CAC5DCB252D2A5
DF2F74B545B
553735B57B3F FB
545 53FB34FC B
DF656 BF B5EE675472


1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

66F6429ABCF7B4
EB3ABCDE3ED3DAED
package com.ft.project.client;
import
import
import
import
import

com.extjs.gxt.ui.client.data.ListLoadResult;
com.ft.project.shared.Mahasiswa;
com.ft.project.shared.User;
com.google.gwt.user.client.rpc.RemoteService;
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;


}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

FA429ABCF7B4
EB3ABCDE3ED3DAED E
package com.ft.project.client;
import
import
import
import

com.extjs.gxt.ui.client.data.ListLoadResult;
com.ft.project.shared.Mahasiswa;
com.ft.project.shared.User;
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);


}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

66F64EB3ABCDE3DADADAED!
@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;

1
}

1
1

123456537
89ABC5DE6FBF4

123456789ABCDE3F8138

489ABF4

66F649D
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;
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

66F649D
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);
}
1
}
});
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

66F649D
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);
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

D6EB4EFE419434B43DDE67FA69

1234
51678429ABC9BA43DDE67FA69
1234567869A8BCDECFE
38F898BC93F8FFF

12345678BCD938 F!8FFF

"A#8$F8%39#938993F8&8'F3F(
1

)F#3F8798*+9C3F8,9E9C8BFFE88-./.8

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F88

12324567898AB29C5CAC5DCB252D2A5
DF25E3B545B
553735B57B3F FB
545!53FB34FC"#B
DF6567BF!B5EE675472
1

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

66F6429ABCF7B4
EB3ABCDE3ED3DA ED
package com.ft.project.client;
import
import
import
import
import

com.extjs.gxt.ui.client.data.ListLoadResult;
com.ft.project.shared.Mahasiswa;
com.ft.project.shared.User;
com.google.gwt.user.client.rpc.RemoteService;
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;


}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

FA429ABCF7B4
EB3ABCDE3ED3DA ED!"E
package com.ft.project.client;
import
import
import
import

com.extjs.gxt.ui.client.data.ListLoadResult;
com.ft.project.shared.Mahasiswa;
com.ft.project.shared.User;
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);


}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

CBFAB4EB3ABCDE3DA DA9B3#AD$%&3'!AA"
package com.ft.project.server;
import
import
import
import
import
import

java.sql.Array;
java.sql.ResultSet;
java.sql.SQLException;
java.util.Arrays;
java.util.List;
java.util.Map;

//source: http://valgogtech.blogspot.com/2009/02/passing-arrays-to-postgresql-database.html
public 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);
}
1

EC32AFBD2A5D8523242A587CDBA25

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

32AFB2A5E27C523242A598834A25
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();
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

32AFB2A5E27C523242A598834A25
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 {
1
return intArray == null ? null : Arrays.copyOfRange(intArray,
(int)index, (int)index +
count );
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

32AFB2A5E27C523242A598834A25
@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 {
1
throw new UnsupportedOperationException(); 1
}
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

66F64EB3ABCDE3DA DADA 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());
}
1
return true;

1
}

1
1

123456537
89ABC5DE6FBF4

123456789ABCDE3F8138

489ABF4

66F649D
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;
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

66F649D

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);
}
});
}
}
});
1
}

1
1

123456537
89ABC5DE6FBF4

489ABF4

123456789ABCDE3F8138

D6EB4EFE419434B43DDE67FA69

You might also like