Skip to content

Commit

Permalink
Coba Json
Browse files Browse the repository at this point in the history
  • Loading branch information
MufidJamaluddin committed Nov 6, 2017
1 parent 3b3f030 commit 93fa04f
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 69 deletions.
2 changes: 2 additions & 0 deletions nbproject/build-impl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -999,12 +999,14 @@ exists or setup the property manually. For example like this:
<target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest">
<copyfiles files="${libs.MySQLDriver.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${libs.jstl.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.java-json.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<mkdir dir="${build.web.dir}/META-INF"/>
<manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/>
</target>
<target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir">
<copyfiles files="${libs.MySQLDriver.classpath}" todir="${build.web.dir}/WEB-INF/lib"/>
<copyfiles files="${libs.jstl.classpath}" todir="${build.web.dir}/WEB-INF/lib"/>
<copyfiles files="${file.reference.java-json.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
</target>
<target depends="init" if="dist.ear.dir" name="-clean-webinf-lib">
<delete dir="${build.web.dir}/WEB-INF/lib"/>
Expand Down
6 changes: 3 additions & 3 deletions nbproject/genfiles.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
build.xml.data.CRC32=93eaf31f
build.xml.data.CRC32=2b4716e4
build.xml.script.CRC32=4f7907cb
build.xml.stylesheet.CRC32=[email protected]
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=93eaf31f
nbproject/build-impl.xml.script.CRC32=e6ecef56
nbproject/build-impl.xml.data.CRC32=2b4716e4
nbproject/build-impl.xml.script.CRC32=9cf099e1
nbproject/build-impl.xml.stylesheet.CRC32=[email protected]
8 changes: 4 additions & 4 deletions nbproject/private/private.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
deploy.ant.properties.file=C:\\Users\\AGS\\AppData\\Roaming\\NetBeans\\8.2\\tomcat80.properties
deploy.ant.properties.file=C:\\Users\\mufidjamaluddin\\AppData\\Roaming\\NetBeans\\8.2\\tomcat80.properties
j2ee.platform.is.jsr109=true
j2ee.server.domain=C:/Users/Maulana/AppData/Roaming/NetBeans/8.2/apache-tomcat-8.0.27.0_base
j2ee.server.home=D:/KULIAH/3RD SEMESTER/apache-tomcat-8.5.23-windows-x64/apache-tomcat-8.5.23
j2ee.server.instance=tomcat80:home=D:\\KULIAH\\3RD SEMESTER\\apache-tomcat-8.5.23-windows-x64\\apache-tomcat-8.5.23
j2ee.server.home=D:/xampp/tomcat
j2ee.server.instance=tomcat80:home=D:\\xampp\\tomcat
j2ee.server.middleware=C:/Program Files/Glassfish/glassfish 4.1.1
javac.debug=true
javadoc.preview=true
selected.browser=SL[/Browsers/FirefoxBrowser
user.properties.file=C:\\Users\\Maulana\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
user.properties.file=C:\\Users\\mufidjamaluddin\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
4 changes: 1 addition & 3 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/E:/tugas%20kuliah/tingkat%202/github%20proyek%203/Travlendar/web/Admin-Panel/Teamplate/Header/header.jsp</file>
</group>
<group/>
</open-files>
</project-private>
6 changes: 4 additions & 2 deletions nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@ dist.war=${dist.dir}/${war.name}
endorsed.classpath=\
${libs.javaee-endorsed-api-7.0.classpath}
excludes=
file.reference.java-json.jar=C:\\Users\\mufidjamaluddin\\Downloads\\java-json\\java-json.jar
includes=**
j2ee.compile.on.save=true
j2ee.copy.static.files.on.save=true
j2ee.deploy.on.save=true
j2ee.platform=1.7-web
j2ee.platform.classpath=${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.6.3.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jaspic-api.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-jni.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar
j2ee.platform.classpath=${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.4.jar:${j2ee.server.home}/lib/ecj-4.6.3.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jaspic-api.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-jni.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/tomcat7-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar
j2ee.server.type=Tomcat
jar.compress=false
javac.classpath=\
${libs.MySQLDriver.classpath}:\
${libs.jstl.classpath}
${libs.jstl.classpath}:\
${file.reference.java-json.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.debug=true
Expand Down
4 changes: 4 additions & 0 deletions nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<file>${libs.jstl.classpath}</file>
<path-in-war>WEB-INF/lib</path-in-war>
</library>
<library dirs="200">
<file>${file.reference.java-json.jar}</file>
<path-in-war>WEB-INF/lib</path-in-war>
</library>
</web-module-libraries>
<web-module-additional-libraries/>
<source-roots>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONException;
import org.json.JSONObject;

@WebServlet(name = "event", urlPatterns = {"/Admin-Panel/event"}) /* URL Controllernya */
public class EventController extends HttpServlet
Expand Down Expand Up @@ -87,6 +89,16 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
/* Jika isi parameter action itu show, maka tampilkan list moda kendaraan */
switch(action)
{
case "calendar":

try {
this.setAttrListJson(request);
} catch (JSONException ex) {
Logger.getLogger(EventController.class.getName()).log(Level.SEVERE, null, ex);
}

request.getRequestDispatcher("CalendarEvent/index.jsp").forward(request, response);
break;
case "show":
// set httprequest atribut dengan list dari database
this.setAttrList(request);
Expand Down Expand Up @@ -302,6 +314,51 @@ private void setAttrList(HttpServletRequest request)
request.setAttribute("eventList", listEvent);
}

/**
*
* @param request
* @throws org.json.JSONException
*/
public void setAttrListJson(HttpServletRequest request) throws JSONException
{
List<Event> listEvent;
int page = 1;
JSONObject jsonObj;

String pagestr = request.getParameter("page");

// Jika parameter page di set
if(pagestr != null)
{
page = Integer.parseInt(pagestr);
}

try
{
listEvent = this.eventDAO.getListFromDB(page);
}
catch (SQLException ex)
{
// ex.printStackTrace();
listEvent = null;
}

if(listEvent != null)
{
jsonObj = new JSONObject();

for(Event objEvent : listEvent)
{
jsonObj.put("title", objEvent.getEvent_name());
jsonObj.put("start", objEvent.getStart_event());
jsonObj.put("end", objEvent.getEnd_event());
}
// dikirimkan ke httprequest atribut
request.setAttribute("jsonList", jsonObj.toString());
}

}

/**
* Method untuk menambahkan objek modatransportasi
* ke httprequest
Expand Down
10 changes: 10 additions & 0 deletions src/java/id/ac/polban/jtk/project3/travlendar2A/Models/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@ public int getLocation_id() {
public void setLocation_id(int location_id) {
this.location_id = location_id;
}

/**
*
* @return
*/
public String toStringJson()
{
return String.format("{ title: %s, start: %s, end: %s }", this.event_name, this.start_event, this.end_event);
}

}


Expand Down
59 changes: 2 additions & 57 deletions web/CalendarEvent/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<script>
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
Expand All @@ -33,62 +33,7 @@
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
{
title: 'All Day Event',
start: '2017-09-01',
},
{
title: 'Long Event',
start: '2017-09-07',
end: '2017-09-10'
},
{
id: 999,
title: 'Repeating Event',
start: '2017-09-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: '2017-09-16T16:00:00'
},
{
title: 'Conference',
start: '2017-09-11',
end: '2017-09-13'
},
{
title: 'Meeting',
start: '2017-09-12T10:30:00',
end: '2017-09-12T12:30:00'
},
{
title: 'Lunch',
start: '2017-09-12T12:00:00'
},
{
title: 'Meeting',
start: '2017-09-12T14:30:00'
},
{
title: 'Happy Hour',
start: '2017-09-12T17:30:00'
},
{
title: 'Dinner',
start: '2017-09-12T20:00:00'
},
{
title: 'Birthday Party',
start: '2017-09-13T07:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2017-09-28'
}
]
events: ${jsonList}
});
});
Expand Down

0 comments on commit 93fa04f

Please sign in to comment.