From 434b75735048b6ffc57ad568e83edf3a2188dc42 Mon Sep 17 00:00:00 2001 From: runbow Date: Tue, 18 Nov 2014 22:05:01 +0700 Subject: [PATCH 01/58] first commit --- .gitignore | 1 + build.xml | 71 ++ nbproject/ant-deploy.xml | 111 ++ nbproject/build-impl.xml | 1410 ++++++++++++++++++++++++++ nbproject/genfiles.properties | 8 + nbproject/private/private.properties | 7 + nbproject/private/private.xml | 7 + nbproject/project.properties | 88 ++ nbproject/project.xml | 18 + src/conf/MANIFEST.MF | 2 + web/WEB-INF/beans.xml | 6 + web/WEB-INF/web.xml | 24 + web/index.xhtml | 12 + 13 files changed, 1765 insertions(+) create mode 100644 .gitignore create mode 100644 build.xml create mode 100644 nbproject/ant-deploy.xml create mode 100644 nbproject/build-impl.xml create mode 100644 nbproject/genfiles.properties create mode 100644 nbproject/private/private.properties create mode 100644 nbproject/private/private.xml create mode 100644 nbproject/project.properties create mode 100644 nbproject/project.xml create mode 100644 src/conf/MANIFEST.MF create mode 100644 web/WEB-INF/beans.xml create mode 100644 web/WEB-INF/web.xml create mode 100644 web/index.xhtml diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..f3d6549d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/build/ \ No newline at end of file diff --git a/build.xml b/build.xml new file mode 100644 index 00000000..ec29b4ea --- /dev/null +++ b/build.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + Builds, tests, and runs the project IF3110-02-Simple-Blog-Java. + + + diff --git a/nbproject/ant-deploy.xml b/nbproject/ant-deploy.xml new file mode 100644 index 00000000..2d5f8778 --- /dev/null +++ b/nbproject/ant-deploy.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 00000000..67bd8963 --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1410 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set build.web.dir + Must set build.generated.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.war + + + + + + + + + +The Java EE server classpath is not correctly set up - server home directory is missing. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Dj2ee.server.home=<app_server_installation_directory> + + +The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) +or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at +<netbeans_installation>/java<version>/ant/extra folder. +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + Must select a file in the IDE or set jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. + + + Launching ${browse.url} + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 00000000..1d884fd2 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=06f6c257 +build.xml.script.CRC32=a9410f96 +build.xml.stylesheet.CRC32=651128d4@1.43.0.1 +# 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=06f6c257 +nbproject/build-impl.xml.script.CRC32=15cfd731 +nbproject/build-impl.xml.stylesheet.CRC32=5459df51@1.43.0.1 diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties new file mode 100644 index 00000000..36e9206a --- /dev/null +++ b/nbproject/private/private.properties @@ -0,0 +1,7 @@ +deploy.ant.properties.file=C:\\Users\\TOSHIBA\\AppData\\Roaming\\NetBeans\\7.3\\config\\GlassFishEE6\\Properties\\gfv31712819959.properties +j2ee.platform.is.jsr109=true +j2ee.server.domain=C:/Users/TOSHIBA/GlassFish_Server/glassfish/domains/domain1 +j2ee.server.home=C:/Users/TOSHIBA/GlassFish_Server/glassfish +j2ee.server.instance=[C:\\Users\\TOSHIBA\\GlassFish_Server\\glassfish;C:\\Users\\TOSHIBA\\GlassFish_Server\\glassfish\\domains\\domain1]deployer:gfv3ee6wc:localhost:4848 +j2ee.server.middleware=C:/Users/TOSHIBA/GlassFish_Server +user.properties.file=C:\\Users\\TOSHIBA\\AppData\\Roaming\\NetBeans\\7.3\\build.properties diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml new file mode 100644 index 00000000..6a1541c6 --- /dev/null +++ b/nbproject/private/private.xml @@ -0,0 +1,7 @@ + + + + + file:/C:/Users/TOSHIBA/Documents/NetBeansProjects/IF3110-02-Simple-Blog-Java/web/index.xhtml + + diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 00000000..0e5ab538 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,88 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=true +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +auxiliary.org-netbeans-modules-projectapi.jsf_2e_language=Facelets +build.classes.dir=${build.web.dir}/WEB-INF/classes +build.classes.excludes=**/*.java,**/*.form +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +build.web.dir=${build.dir}/web +build.web.excludes=${build.classes.excludes} +client.urlPart= +compile.jsps=false +conf.dir=${source.root}/conf +debug.classpath=${build.classes.dir}:${javac.classpath} +debug.test.classpath=\ + ${run.test.classpath} +display.browser=true +dist.dir=dist +dist.ear.war=${dist.dir}/${war.ear.name} +dist.javadoc.dir=${dist.dir}/javadoc +dist.war=${dist.dir}/${war.name} +endorsed.classpath=\ + ${libs.javaee-endorsed-api-6.0.classpath} +excludes= +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.middleware}/mq/lib/jaxm-api.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar +j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar +j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar +j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar +j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar +j2ee.platform.wsit.classpath= +j2ee.server.type=gfv3ee6 +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.debug=true +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.7 +javac.target=1.7 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.preview=true +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +lib.dir=${web.docbase.dir}/WEB-INF/lib +no.dependencies=false +persistence.xml.dir=${conf.dir} +platform.active=default_platform +resource.dir=setup +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +# Space-separated list of JVM arguments used when running a class with a main method or a unit test +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value): +runmain.jvmargs= +source.encoding=UTF-8 +source.root=src +src.dir=${source.root}/java +test.src.dir=test +war.content.additional= +war.ear.name=${war.name} +war.name=IF3110-02-Simple-Blog-Java.war +web.docbase.dir=web +webinf.dir=web/WEB-INF diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 00000000..7723172d --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,18 @@ + + + org.netbeans.modules.web.project + + + IF3110-02-Simple-Blog-Java + 1.6.5 + + + + + + + + + + + diff --git a/src/conf/MANIFEST.MF b/src/conf/MANIFEST.MF new file mode 100644 index 00000000..59499bce --- /dev/null +++ b/src/conf/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/web/WEB-INF/beans.xml b/web/WEB-INF/beans.xml new file mode 100644 index 00000000..ba9b1015 --- /dev/null +++ b/web/WEB-INF/beans.xml @@ -0,0 +1,6 @@ + + + diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml new file mode 100644 index 00000000..c5e7c738 --- /dev/null +++ b/web/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + javax.faces.PROJECT_STAGE + Development + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/web/index.xhtml b/web/index.xhtml new file mode 100644 index 00000000..c70ee58c --- /dev/null +++ b/web/index.xhtml @@ -0,0 +1,12 @@ + + + + + Facelet Title + + + Hello from Facelets + + + From 932f7bf10deaab77bd695b9ad2135f0cd16d9cf0 Mon Sep 17 00:00:00 2001 From: runbow Date: Wed, 19 Nov 2014 01:58:45 +0700 Subject: [PATCH 02/58] add header --- .gitignore | 3 +- nbproject/build-impl.xml | 7 +- nbproject/genfiles.properties | 6 +- nbproject/private/private.xml | 2 +- nbproject/project.properties | 4 +- nbproject/project.xml | 11 +- web/assets/css/screen.css | 861 ++++++++++++++++++++++++++++++++++ web/assets/img/favicon.ico | Bin 0 -> 799 bytes web/assets/img/pre.png | Bin 0 -> 78 bytes web/header.jsp | 53 +++ web/header.xhtml | 43 ++ web/index.jsp | 84 ++++ web/index.xhtml | 89 +++- 13 files changed, 1148 insertions(+), 15 deletions(-) create mode 100644 web/assets/css/screen.css create mode 100644 web/assets/img/favicon.ico create mode 100644 web/assets/img/pre.png create mode 100644 web/header.jsp create mode 100644 web/header.xhtml create mode 100644 web/index.jsp diff --git a/.gitignore b/.gitignore index f3d6549d..95832e8e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/build/ \ No newline at end of file +/build/ +/dist/ \ No newline at end of file diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 67bd8963..00f42643 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -985,10 +985,15 @@ exists or setup the property manually. For example like this: + + - + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 1d884fd2..d8fb0912 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=06f6c257 +build.xml.data.CRC32=46c52805 build.xml.script.CRC32=a9410f96 build.xml.stylesheet.CRC32=651128d4@1.43.0.1 # 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=06f6c257 -nbproject/build-impl.xml.script.CRC32=15cfd731 +nbproject/build-impl.xml.data.CRC32=46c52805 +nbproject/build-impl.xml.script.CRC32=10627f01 nbproject/build-impl.xml.stylesheet.CRC32=5459df51@1.43.0.1 diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index 6a1541c6..1d444fa7 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -2,6 +2,6 @@ - file:/C:/Users/TOSHIBA/Documents/NetBeansProjects/IF3110-02-Simple-Blog-Java/web/index.xhtml + file:/C:/Users/TOSHIBA/Documents/RAMA/KULIAH/Semester%207/WBD/IF3110-02-Simple-Blog-Java/web/WEB-INF/web.xml diff --git a/nbproject/project.properties b/nbproject/project.properties index 0e5ab538..e6fb8886 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -40,7 +40,9 @@ j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.ja j2ee.platform.wsit.classpath= j2ee.server.type=gfv3ee6 jar.compress=false -javac.classpath= +javac.classpath=\ + ${libs.jsf20.classpath}:\ + ${libs.jsf12.classpath} # Space-separated list of extra javac options javac.compilerargs= javac.debug=true diff --git a/nbproject/project.xml b/nbproject/project.xml index 7723172d..5f12cb7e 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -5,7 +5,16 @@ IF3110-02-Simple-Blog-Java 1.6.5 - + + + ${libs.jsf20.classpath} + WEB-INF/lib + + + ${libs.jsf12.classpath} + WEB-INF/lib + + diff --git a/web/assets/css/screen.css b/web/assets/css/screen.css new file mode 100644 index 00000000..1d8fdf3b --- /dev/null +++ b/web/assets/css/screen.css @@ -0,0 +1,861 @@ +@import url(http://fonts.googleapis.com/css?family=Open+Sans); +@import url(http://fonts.googleapis.com/css?family=Questrial); + +/* Reset & Basics (Inspired by E. Meyers) +================================================== */ +html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, address, cite, code, em, img, small, strong, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, embed, figure, figcaption, footer, header, hgroup, menu, nav, section, summary, time, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; } +article, aside, details, figcaption, figure, footer, header, hgroup, menu, time, nav, section { + display: block; } +html, body, .wrapper { + min-height: 100%; +} + + +/* Body +================================================== */ +html, body { + height: 100%; +} +.wrapper { + min-height: 100%; +} +body { + overflow-x: hidden; + font: 17px/28px ff-meta-serif-web-pro, "Georgia", serif; + color: #333; + background: #fff; +} + + +/* Typography +================================================== */ +h1, h2, h3, h4, h5, h6 { + font-family: "proxima-nova", "helvetica neue", "helvetica", sans-serif; + font-weight: normal; + text-transform: uppercase; + font-weight: 700; + color: #000; + text-rendering: optimizeLegibility; +} + +h1 { + font-size: 50px; + padding-bottom: 30px; +} + +h2 { + font-size: 45px; + padding-bottom: 25px; +} + +h3 { + font-size: 40px; + padding-bottom: 20px; +} + +h4 { + font-size: 35px; + padding-bottom: 15px; +} + +h5 { + font-size: 30px; + padding-bottom: 10px; +} + +p { + margin: 0 0 28px 0; +} + +strong { + font-weight: bold; +} +em { + font-style: italic; +} +sup { + line-height: 0; +} + +small { + font-size: 70%; +} + +cite { + font-size: 80%; + font-style: italic; + } + +/* Teaser +================================================== */ + +header#teaser h1 { + text-transform: none !important; + color: #333; + font-size: 28px !important; + font-weight: 300 !important; +} + + +/* Links +================================================== */ +a { + color: #F40034; + text-decoration: none; + -webkit-transition: color .2s ease-in-out; + -moz-transition: color .2s ease-in-out; + transition: color .2s ease-in-out; +} +a:hover { + color: #F40034; +} + +/* Layout +================================================== */ +/* White container that is the "page" */ +.wrapper { + max-width: 1500px; + margin: 0 auto; + background: #fff; +} + +/* Containers to keep content to a set width */ +.nav, +.art-header-inner, +.footer, +.art-list, +.abt, +.fourohfour { + width: 980px; +} +.nav, +.art-body-inner, +.footer, +.art-list, +.abt, +.fourohfour { + position: relative; + margin: 0 auto; +} + +/* Nav +================================================== */ +.nav { + position: absolute; + top: 0; + left: 50%; + height: 70px; + padding-top: 40px; + margin-left: -490px; /* Half width of nav */ + border-bottom: 1px solid #333; + z-index: 2; +} +.nav.fixed { + position: fixed; +} +#logo { + float: left; +} +.nav-primary { + float: right; +} +.nav-primary li { + display: inline-block; + margin-left: 10px; + font-weight: 500; +} +#logo h1, +.nav-primary li, +.nav-primary li a { + font-family: "proxima-nova", "helvetica neue", "helvetica", sans-serif; + font-weight: 700; + font-size: 13px; + line-height: 30px; + color: #000; + text-transform: uppercase; +} + +#logo h1 { + height: 30px; + margin-left: 0px; + letter-spacing: 1px; + font-family: 'Questrial', sans-serif; + font-size: 30px; +} + +#logo h1 span{ + color: #F40034 !important; +} + +.nav li:first-child { + margin-left: 0; /* Remove left margin from the first nav li */ +} + +/* Home Page +================================================== */ + +div#home {} + +#home > div.cover { + max-width: 980px; + margin: 0px auto; + /*padding-top: 110px;*/ +} + +div.cover { + +} + +div.cover > img { + width: 100%; + height: 100%; +} + + +/* Article +================================================== */ +.art { + margin-top: -131px; +} +/* Header */ +.art-header { + height: 900px; + /* Background image is defined in the post */ + background-position: top center; + background-attachment: fixed; + overflow: hidden; +} +/* Contains the time, title and subtitle for an article */ +.art-header-inner { + position: fixed; + top: 300px; + left: 50%; + margin-left: -490px; +} +.art-time, +.art-title, +.art-subtitle { + text-align: center; + text-transform: uppercase; +} +.art-time { + font-size: 14px; + line-height: 1.8; + letter-spacing: 4px; +} +.art-title { + font-size: 100px; + line-height: .9; + letter-spacing: -2px; + width: 100%; +} +.art-subtitle { + margin-top: 4px; + font-size: 14px; + line-height: 1.3; + letter-spacing: 4px; +} + +/* If small header, make few adjustments */ +.small .art-title { + font-size: 70px; + line-height: 65px; +} +.small.art-header-inner { + top: 320px; +} + +/* Body */ +.art-body { + position: relative; + width: 100%; + background: #fff; + z-index: 100; + -webkit-box-shadow: 0 -3px 3px rgba(0,0,0,.2); + -moz-box-shadow: 0 -3px 3px rgba(0,0,0,.2); + box-shadow: 0 -3px 3px rgba(0,0,0,.2); +} +.art-body-inner { + font-family: Georgia,Cambria,"Times New Roman",Times,serif; + max-width: 640px; + padding: 80px 0 50px; + letter-spacing: 0.01rem; + font-weight: 400; + font-style: normal; + font-size: 21px; + line-height: 1.5; +} +.art-body-inner a:hover { + border-bottom: 1px solid #F40034; + padding-bottom:2px; +} +.art-body-inner ul, +.art-body-inner ol { /* For lists in the article body */ + margin-bottom: 26px; +} +.art-body-inner ul li { + list-style: disc; +} + +.art-body-inner mark { + background-color: #fdffb6; + padding: 2px; + -webkit-box-shadow: #fdffb6 0 0 5px; + -moz-box-shadow: #fdffb6 0 0 5px; + box-shadow: #fdffb6 0 0 5px; +} + +.art-body-inner blockquote { + font-size: 16px; + background: #f9f9f9; + border-left: 10px solid #ccc; + margin: 1.5em 10px; + padding: 0.5em 10px; + quotes: "\201C""\201D""\2018""\2019"; +} + +.art-body-inner blockquote p:first-child:before { + color: #ccc; + content: "“"; + font-size: 4em; + line-height: 0.1em; + margin-right: 0.25em; + vertical-align: -0.4em; +} + +.art-body-inner blockquote p { + margin-bottom: 1.5em; +} + +.art-body-inner blockquote p:last-child { + margin-bottom: 0; +} + + +.dropcap { /* First character on articles */ + float: left; + margin: 47px 10px 20px 0; + font-size: 100px; + line-height: 0; +} +.art-subhead { /* Subheads are used to break up sections of an article */ + margin: 60px 0 15px; + font-size: 20px; + line-height: 28px; + letter-spacing: 3px; +} +.callout { /* Callouts are like large pullquotes */ + font-weight: bold; +} +.art-body-inner img { + max-width: 100%; + max-height: 600px; + margin-bottom: 26px; +} +.art-body-inner img.center { + display: block; + margin-left: auto; + margin-right: auto; +} +.art-body-inner .art-reference { + font-size: 80%; + color: #999; + margin-top: 50px; +} + +/* For simple, white background posts */ +.simple .art-body { + background: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; +} + + +/* List of Articles +================================================== */ +.art-list { + padding: 120px 0 0; +} +.art-list-body { + position: relative; + overflow: hidden; +} +.art-list-item { + padding: 40px 0; + list-style: none; + overflow: hidden; + border-bottom: 1px solid #ccc; +} +.art-list-item:last-child { + border-bottom: none; +} +.art-list-title { + font-size: 26px; + line-height: 26px; + font-weight: 700; +} +.art-list-item-title-and-time { + float: left; + width: 30%; + margin-bottom: 10px; +} +.art-list-time { + font-size: 12px; + line-height: 20px; + letter-spacing: 2px; + text-transform: uppercase; + color: #999; +} +.art-list-title a { + color: #000; +} +.art-list-title a:hover { + color: #F40034; +} +.art-list-item p { + width: 65%; + float: left; + margin-left: 5%; + margin-bottom: 0; + font-size: 16px; + line-height: 24px; +} + + +/* Footer +================================================== */ +.footer { + padding: 30px 0 40px; + overflow: hidden; + border-top: 1px solid #ccc; +} +.footer, +.footer a { + font-family: "proxima-nova", "helvetica neue", "helvetica", sans-serif; + font-size: 13px; + text-transform: uppercase; + color: #777; +} +.footer a:hover { + color: #000; +} +.back-to-top, +.footer-nav, +.offsite-links { + width: 45%; + float: left; +} +.psi { + width:10%; + float:left; + text-align: center; +} +.footer-nav { + text-align: center; +} +.offsite-links { + text-align: right; +} +.footer .twitter-link:hover { + color: #0084B4; +} +.footer .instagram-link:hover { + color: #3F729B; +} +.footer .github-link:hover { + color: #c5376d; +} +.footer .caffein8-link:hover{ + color: black; +} +.footer .rss-link:hover { + color: #e85d24; +} +/* Remove prev & next links on loop */ +.art-list + .footer .footer-nav, +.abt + .footer .footer-nav { + text-indent: -9999px; + text-align: left; +} + + +/* White Reverse Theme +================================================== */ +/* Nav */ +.nav.white { + border-bottom-color: #fff; + border-bottom-color: rgba(255,255,255,.3); +} +.nav.white li a, +.nav.white li, +.nav.white #logo h1 { + color: #fff; + text-shadow: 0 0 8px rgba(0,0,0,.5); +} +.nav.white #logo h1 { + background-position: top center; +} + +nav.pagination{ + text-align: right; + padding-bottom: 25px; +} +/* Art header */ +.art-header.white { + background-color: #111; +} +.art-header.white .art-time, +.art-header.white .art-title, +.art-header.white .art-subtitle { + color: #fff; + text-shadow: 0 0 8px rgba(0,0,0,.5); +} + + +/* About page +================================================== */ +.abt { + padding: 200px 0 100px; + list-style: none; +} +.abt .abt-header { + font-size: 140px; + line-height: 1; + text-transform: none; +} +.abt .abt-subheader { + font-size: 24px; + font-style: italic; + text-transform: none; + color: #777; +} +.abt-body { + -moz-column-count: 2; + -moz-column-gap: 20px; + -webkit-column-count: 2; + -webkit-column-gap: 20px; + margin-bottom: 28px; +} +.abt-signoff { + line-height: 1.3; + font-style: italic; + color: #777; +} + +/* 404 page +================================================== */ +.fourohfour { + padding: 240px 0 100px; + text-align: center; +} + +/* Code +================================================== */ + +code, tt { +background: #ededee; +color: #3C4043; +font-size: 90%; +padding: 1px 3px; +} + +pre { + width: 92%; + overflow: auto; + margin: 2rem 0; + padding: 1rem 0.8rem 1rem 1.2rem; + color: #3f3b36; + border: 1px solid #ccc; + border-left: 1rem solid #ccc; + font: lighter 1.2rem/2rem monospace; + background: url(/assets/img/pre.png) repeat 0 -0.9rem; + background-size: 1px 4rem; +} + +pre code, tt { +font-size: inherit; +white-space: -moz-pre-wrap; +white-space: pre-wrap; +background: transparent; +border: none; +padding: 0; +} + + +.gist { + font-size: 14px; +} + + +/* Responsive +================================================== */ +@media only screen and (max-width: 1080px) { + /* Set all of the 980 containers to flexible width */ + .nav, + .art-body-inner, + .art-header-inner, + .footer, + .art-list, + .abt, + .fourohfour { + width: 90%; + } + .nav, + .art-header-inner { + margin-left: -45%; + } +} + +@media only screen and (max-width: 1024px) { + /* Everything becomes scrolling and non-fading */ + .nav, + .nav.fixed { + position: relative; + opacity: 1 !important; /* Important to override JS values */ + display: inline-block; + } + .art-header-inner { + position: relative; + top: 0 !important; /* Important to override JS values */ + margin-top: 240px !important; /* Important to override JS values */ + opacity: 1 !important; /* Important to override JS values */ + } + /* Articles no longer have fixed heights */ + .art-header { + height: auto; + padding-bottom: 100px; + background-size: cover !important; + background-attachment: scroll; + } + /* Remove bottom space out if articles doesn't have a background */ + .simple .art-header { + padding-bottom: 0; + } + .art-list { + padding-top: 0; + } + .abt { + padding: 40px 0; + } + .fourohfour { + padding: 80px 0 60px; + } +} + +@media only screen and (max-width: 780px) { + .art-body-inner ul, + .art-body-inner ol { + margin-left: 20px; + } + .art-title { + letter-spacing: 0; + } + .art-subtitle, + .art-time { + font-size: 12px; + } + .nav { + padding-top: 25px; + height: 55px; + } + .art-list-item-title-and-time, + .art-list-item p { + float: none; + width: auto; + margin-left: 0; + } + .abt-body { + -moz-column-count: 1; + -webkit-column-count: 1; + } +} + +@media only screen and (max-width: 500px) { + .nav-primary li { + margin-left: 10px; + } + .nav #logo h1 { + font-size: 16px; + letter-spacing: -1px; + } + .nav li a { + font-size: 12px; + } + .art-header { + padding-bottom: 50px; + } + .art-header-inner { + margin-top: 190px !important; + } + .art-body-inner { + padding-top: 30px; + } + body { + font-size: 15px; + line-height: 24px; + } + p { + margin-bottom: 24px; + } + .footer { + padding: 10px 0 20px; + } + .back-to-top, + .footer-nav { + width: 50%; + } + .back-to-top { + text-align: left; + } + .footer-nav { + text-align: right; + } + .offsite-links { + float: left; + width: 100%; + text-align: left; + } + .offsite-links a { + font-size: 12px; + } + .art-list + .footer .footer-nav { + display: none; + } + .abt .abt-header { + font-size: 80px; + } + .abt .abt-subheader { + font-size: 18px; + } +} + + +/* Misc +================================================== */ +::selection { + background: #000; + color: #fff; +} +::-moz-selection { + background: #000; + color: #fff; +} +img.left { + float: left; + margin-right: 20px; +} +img.right { + float: right; + margin-left: 20px; +} +/* Clearfixing pile */ +.nav:before, +.art-body-inner:before, +.footer:before, +.art-list:before { + content:""; + display:table; +} +.nav:after, +.art-body-inner:after, +.footer:after, +.art-list:after { + clear:both; +} +.nav, +.art-body-inner, +.footer, +.art-list { + zoom:1; /* For IE 6/7 (trigger hasLayout) */ +} + + +@-webkit-keyframes le-fade { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } +} +@-moz-keyframes le-fade { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } +} + +.art-header-inner { + -webkit-animation: le-fade .5s 0 1 ease-out; + -moz-animation: le-fade .5s 0 1 ease-out; +} + +.art-list, +.nav, +.abt, +.art-body { + -webkit-animation: le-fade .5s 0s 1 ease-out; + -moz-animation: le-fade .5s 0s 1 ease-out; +} + +hr.featured-article { + padding: 0; + border: none; + border-top: medium double #bbb; + color: #bbb; + text-align: center; +} +hr.featured-article:after { + content: "✭ Featured Article ✭"; + display: inline-block; + position: relative; + top: -0.8em; + font-size: 1.2em; + padding: 0 0.6em; + background: white; +} + +/* FORM */ + +#contact-area { + width: 600px; + margin-top: 25px; +} + +#contact-area input, #contact-area textarea { + padding: 5px; + width: 471px; + font-family: Helvetica, sans-serif; + margin: 0px 0px 10px 0px; + border: 2px solid #ccc; +} + +#contact-area textarea { + height: 90px; +} + +#contact-area textarea:focus, #contact-area input:focus { + border: 2px solid #900; +} + +#contact-area input.submit-button { + width: 100px; + +} + +label { + float: left; + text-align: right; + margin-right: 15px; + width: 100px; + padding-top: 5px; +} \ No newline at end of file diff --git a/web/assets/img/favicon.ico b/web/assets/img/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..40b40ed345847af1db325abe295a4d7c33cc51d9 GIT binary patch literal 799 zcmZ?wbhEHbRA5kGc$UeqZ{NPZfB)9j)^6Us`Olv}|Ni~^`SWLYcXw)Ps)K`rqod=Z zMT^$0Ti4v&eCN)c-@kvqef!qi+dDKg^!@wyU%q@%RaG@NH($Pd`GN%tl9G}xUc6XR zQu6E9FLibGuV25udiCn{>(}4Ee~*cY`SIh2tE=m-UAqn)I`rbji{9SeckkZKojdp0 zvuEz^?gtJWP*G9YxN+mzvuFMM{GL2{qNu1iW5$g8_wN@K6&V>BZQHi(@#DvNd3lzW zmLEQRxPANf_U+p*UAlDo^y%p6==k{fH*el_bab?~wpLVBeE$47J3IUC-Mhxd#!Hqg z@$m34Gc(J{$+Z^ zfgzJY2V@Q?P8it#H)J+7x3spkcXW1jck-(-hw?JH@v`)EtEXqoo}E5zdY96i*(uFN zj0-Y3q?&aXr)xJUr*kZjNcUQi$uByGv)MHxowvt!Rt9@B(;SH=f#c~~U98q~HZ(=d zNo?X+@6f5SID?ZlQ)UiZror)R3hjJv=A>l?%&`{^ew41l*Dk;$_GoTkf%6J>Eil=TJ#E=(?aY;SM|LZ4G}!4c(8v)yZsj{E+;CCD xp^pWP3S4uv5|&mxacW8Syewc*%yzV+uO-MJ;ZQ + +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog + + + + + +
+ + diff --git a/web/header.xhtml b/web/header.xhtml new file mode 100644 index 00000000..ea2e22e4 --- /dev/null +++ b/web/header.xhtml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog + + + + + \ No newline at end of file diff --git a/web/index.jsp b/web/index.jsp new file mode 100644 index 00000000..027277e1 --- /dev/null +++ b/web/index.jsp @@ -0,0 +1,84 @@ +<%-- + Document : index + Created on : Nov 18, 2014, 11:56:39 PM + Author : TOSHIBA +--%> + +<%@page contentType="text/html" pageEncoding="UTF-8"%> +<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %> +<%@taglib uri="http://java.sun.com/jsf/facelets" prefix="ui" %> + + + +
+
+ +
+
+ + + +
+ + + + + + + + + + + \ No newline at end of file diff --git a/web/index.xhtml b/web/index.xhtml index c70ee58c..d0338b06 100644 --- a/web/index.xhtml +++ b/web/index.xhtml @@ -1,12 +1,87 @@ - - Facelet Title - - - Hello from Facelets - + xmlns:f="http://java.sun.com/jsf/core" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:ui="http://java.sun.com/jsf/facelets"> + + + +
+ + + +
+
+ +
+
+ + + +
+ + + + + + + From 5ce1c06aad12148e32d3b477c3964864ff087ca9 Mon Sep 17 00:00:00 2001 From: runbow Date: Wed, 19 Nov 2014 17:07:36 +0700 Subject: [PATCH 03/58] add header&footer script --- web/footer-script.xhtml | 23 ++++++++++++++++++++ web/footer.xhtml | 30 ++++++++++++++++++++++++++ web/header-script.xhtml | 43 ++++++++++++++++++++++++++++++++++++ web/header.xhtml | 48 ++++++++++------------------------------- web/index.xhtml | 42 +++--------------------------------- 5 files changed, 110 insertions(+), 76 deletions(-) create mode 100644 web/footer-script.xhtml create mode 100644 web/footer.xhtml create mode 100644 web/header-script.xhtml diff --git a/web/footer-script.xhtml b/web/footer-script.xhtml new file mode 100644 index 00000000..bda42ce4 --- /dev/null +++ b/web/footer-script.xhtml @@ -0,0 +1,23 @@ + + + + + + + + + + + + diff --git a/web/footer.xhtml b/web/footer.xhtml new file mode 100644 index 00000000..9842e442 --- /dev/null +++ b/web/footer.xhtml @@ -0,0 +1,30 @@ + + + + + + + + + \ No newline at end of file diff --git a/web/header-script.xhtml b/web/header-script.xhtml new file mode 100644 index 00000000..d2e26f64 --- /dev/null +++ b/web/header-script.xhtml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog + + + + + + + diff --git a/web/header.xhtml b/web/header.xhtml index ea2e22e4..6fd1e24b 100644 --- a/web/header.xhtml +++ b/web/header.xhtml @@ -1,43 +1,17 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Simple Blog - - - - - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/web/index.xhtml b/web/index.xhtml index d0338b06..c313d8fc 100644 --- a/web/index.xhtml +++ b/web/index.xhtml @@ -8,13 +8,7 @@
- - +
@@ -47,40 +41,10 @@
- - +
- - - - + From eaa7707caf6a99f72db27dc4ed8da4efc17f1a4d Mon Sep 17 00:00:00 2001 From: runbow Date: Wed, 19 Nov 2014 17:15:05 +0700 Subject: [PATCH 04/58] add connect db --- web/WEB-INF/web.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index c5e7c738..f0284779 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -4,6 +4,23 @@ javax.faces.PROJECT_STAGE Development + + + JDBC-DRIVER + com.mysql.jdbc.Driver + + + DB-SERVER + jdbc:mysql://localhost:3306/simple_blog + + + DB-USER + root + + DB-PASSWORD + + + Faces Servlet javax.faces.webapp.FacesServlet From c591edf704af206bd6d3279232b74a4fabc108af Mon Sep 17 00:00:00 2001 From: runbow Date: Wed, 19 Nov 2014 17:25:33 +0700 Subject: [PATCH 05/58] fixing db connect --- web/WEB-INF/web.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index f0284779..39b8e8ce 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -15,7 +15,8 @@ DB-USER - root + root + DB-PASSWORD From 0527405ead4b7c2e1cbcc0ebd1a09398ebdfefa1 Mon Sep 17 00:00:00 2001 From: runbow Date: Fri, 21 Nov 2014 15:29:22 +0700 Subject: [PATCH 06/58] db connected --- nbproject/private/private.xml | 3 --- src/java/ConnectDb.java | 47 +++++++++++++++++++++++++++++++++++ web/header-script.xhtml | 2 +- 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 src/java/ConnectDb.java diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index 1d444fa7..47509625 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -1,7 +1,4 @@ - - file:/C:/Users/TOSHIBA/Documents/RAMA/KULIAH/Semester%207/WBD/IF3110-02-Simple-Blog-Java/web/WEB-INF/web.xml - diff --git a/src/java/ConnectDb.java b/src/java/ConnectDb.java new file mode 100644 index 00000000..d3ce6166 --- /dev/null +++ b/src/java/ConnectDb.java @@ -0,0 +1,47 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + + +import java.sql.*; +import javax.inject.Named; +import javax.enterprise.context.Dependent; + +/** + * + * @author TOSHIBA + */ +@Named(value = "connectDb") +@Dependent +public class ConnectDb { + + private Connection conn; + String output2; + + /** + * Creates a new instance of ConnectDb + */ + public ConnectDb() throws SQLException { + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (Exception e) { + System.out.println("Unable to load Driver"); + + } + conn = DriverManager.getConnection(dbURL, uName, pass); + } catch (SQLException ex) { + // Step 1: Create a database "Connection" object + ex.printStackTrace(); + output2 = output2 + ex.toString(); + System.out.println("Unable to connect to database"); + + } + } + +} diff --git a/web/header-script.xhtml b/web/header-script.xhtml index d2e26f64..f1d060d5 100644 --- a/web/header-script.xhtml +++ b/web/header-script.xhtml @@ -4,7 +4,7 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> - + From fc1fba7443be6cb4c63dd34c6263a7bb094f9ba4 Mon Sep 17 00:00:00 2001 From: runbow Date: Fri, 21 Nov 2014 15:37:37 +0700 Subject: [PATCH 07/58] edit footer, fix web.xml bug --- src/java/{ => paket}/ConnectDb.java | 2 ++ web/WEB-INF/web.xml | 4 ++-- web/footer.xhtml | 12 ++++-------- 3 files changed, 8 insertions(+), 10 deletions(-) rename src/java/{ => paket}/ConnectDb.java (98%) diff --git a/src/java/ConnectDb.java b/src/java/paket/ConnectDb.java similarity index 98% rename from src/java/ConnectDb.java rename to src/java/paket/ConnectDb.java index d3ce6166..c84be55e 100644 --- a/src/java/ConnectDb.java +++ b/src/java/paket/ConnectDb.java @@ -1,3 +1,5 @@ +package paket; + /* * To change this template, choose Tools | Templates * and open the template in the editor. diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index 39b8e8ce..a41ee348 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -4,7 +4,7 @@ javax.faces.PROJECT_STAGE Development - + JDBC-DRIVER com.mysql.jdbc.Driver @@ -21,7 +21,7 @@ DB-PASSWORD - + Faces Servlet javax.faces.webapp.FacesServlet diff --git a/web/footer.xhtml b/web/footer.xhtml index 9842e442..a1380219 100644 --- a/web/footer.xhtml +++ b/web/footer.xhtml @@ -12,17 +12,13 @@
Ψ
From 3a94fbd6d535ef6a713e1bc1f03307121eed0062 Mon Sep 17 00:00:00 2001 From: runbow Date: Sat, 22 Nov 2014 11:33:15 +0700 Subject: [PATCH 08/58] add login page --- web/header.xhtml | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/web/header.xhtml b/web/header.xhtml index 6fd1e24b..bd9a62eb 100644 --- a/web/header.xhtml +++ b/web/header.xhtml @@ -1,17 +1,18 @@ - - - - - - - + + + + + + + \ No newline at end of file From 6a73c25dc7ba71a386ba13369bbc27a3bcb53cb6 Mon Sep 17 00:00:00 2001 From: runbow Date: Sat, 22 Nov 2014 11:33:58 +0700 Subject: [PATCH 09/58] add login page --- web/login.xhtml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 web/login.xhtml diff --git a/web/login.xhtml b/web/login.xhtml new file mode 100644 index 00000000..b98de55a --- /dev/null +++ b/web/login.xhtml @@ -0,0 +1,32 @@ + + + + + + Simple Blog | Login + + + + +
+
+

Login

+
+
+ + + + + +
+
+ +
+
+
+
+
+ + + From ced55318b7c7eef83687fc576bb1e3924e819175 Mon Sep 17 00:00:00 2001 From: runbow Date: Sat, 22 Nov 2014 15:43:12 +0700 Subject: [PATCH 10/58] logged in --- nbproject/build-impl.xml | 6 +- nbproject/genfiles.properties | 6 +- nbproject/project.properties | 3 +- nbproject/project.xml | 6 +- src/java/paket/ConnectDb.java | 49 ----------- src/java/paket/login.java | 148 ++++++++++++++++++++++++++++++++++ web/WEB-INF/web.xml | 12 ++- web/login.xhtml | 8 +- 8 files changed, 168 insertions(+), 70 deletions(-) delete mode 100644 src/java/paket/ConnectDb.java create mode 100644 src/java/paket/login.java diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 00f42643..ea522f50 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -985,14 +985,12 @@ exists or setup the property manually. For example like this:
- - + - - + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index d8fb0912..43f8149f 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=46c52805 +build.xml.data.CRC32=12eac0a2 build.xml.script.CRC32=a9410f96 build.xml.stylesheet.CRC32=651128d4@1.43.0.1 # 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=46c52805 -nbproject/build-impl.xml.script.CRC32=10627f01 +nbproject/build-impl.xml.data.CRC32=12eac0a2 +nbproject/build-impl.xml.script.CRC32=96a0ba67 nbproject/build-impl.xml.stylesheet.CRC32=5459df51@1.43.0.1 diff --git a/nbproject/project.properties b/nbproject/project.properties index e6fb8886..e20869e7 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -41,8 +41,7 @@ j2ee.platform.wsit.classpath= j2ee.server.type=gfv3ee6 jar.compress=false javac.classpath=\ - ${libs.jsf20.classpath}:\ - ${libs.jsf12.classpath} + ${libs.MySQLDriver.classpath} # Space-separated list of extra javac options javac.compilerargs= javac.debug=true diff --git a/nbproject/project.xml b/nbproject/project.xml index 5f12cb7e..dc3be17e 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -7,11 +7,7 @@ 1.6.5 - ${libs.jsf20.classpath} - WEB-INF/lib - - - ${libs.jsf12.classpath} + ${libs.MySQLDriver.classpath} WEB-INF/lib diff --git a/src/java/paket/ConnectDb.java b/src/java/paket/ConnectDb.java deleted file mode 100644 index c84be55e..00000000 --- a/src/java/paket/ConnectDb.java +++ /dev/null @@ -1,49 +0,0 @@ -package paket; - -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - - -import java.sql.*; -import javax.inject.Named; -import javax.enterprise.context.Dependent; - -/** - * - * @author TOSHIBA - */ -@Named(value = "connectDb") -@Dependent -public class ConnectDb { - - private Connection conn; - String output2; - - /** - * Creates a new instance of ConnectDb - */ - public ConnectDb() throws SQLException { - String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; - String uName = "root"; - String pass = ""; - - try { - try { - Class.forName("com.mysql.jdbc.Driver"); - } catch (Exception e) { - System.out.println("Unable to load Driver"); - - } - conn = DriverManager.getConnection(dbURL, uName, pass); - } catch (SQLException ex) { - // Step 1: Create a database "Connection" object - ex.printStackTrace(); - output2 = output2 + ex.toString(); - System.out.println("Unable to connect to database"); - - } - } - -} diff --git a/src/java/paket/login.java b/src/java/paket/login.java new file mode 100644 index 00000000..bc353fea --- /dev/null +++ b/src/java/paket/login.java @@ -0,0 +1,148 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package paket; + +import java.io.IOException; +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.*; + +/** + * + * @author TOSHIBA + */ +public class login extends HttpServlet { + + private String databaseURL, username, password; + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + /** + * + * @param config + * @throws ServletException + */ + @Override + public void init(ServletConfig config) throws ServletException{ + + super.init(config); + ServletContext context = config.getServletContext(); + databaseURL = context.getInitParameter("databaseURL"); + username = context.getInitParameter("usrname"); + password = context.getInitParameter("passwrd"); + + } + + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + PrintWriter out = response.getWriter(); + Connection conn = null; + Statement stmnt = null; + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (Exception e) { + e.printStackTrace(); + out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "SELECT * FROM `usr` WHERE usrname =" + "'" + request.getParameter("usrname") + "'"; + + ResultSet rset = stmnt.executeQuery(sqlStr); + + if(!rset.first()){ + out.print("username tidak ada"); + }else{ + String passwrd1 = rset.getString("passwrd"); + String role = rset.getString("role"); + if (passwrd1.equals(request.getParameter("passwrd"))){ + //create session + HttpSession session = request.getSession(); + + session.setAttribute("owner", request.getParameter("usrname")); + session.setAttribute("role", role); + + //set session age + Cookie cookie = new Cookie ("owner", request.getParameter("usrname")); + cookie.setMaxAge(3600); + Cookie cookie2 = new Cookie("role", role); + cookie2.setMaxAge(3600); + response.addCookie(cookie); + response.addCookie(cookie2); + + out.print("success"); + }else{ + out.print("password salah!"); + } + } + } catch (SQLException ex) { + ex.printStackTrace(); + out.println("Unable to connect to database"); + out.print(ex.toString()); + }finally { + out.close(); + try { + // Step 5: Close the Statement and Connection + if (stmnt != null) { + stmnt.close(); + } + if (conn != null) { + conn.close(); + } + } catch (SQLException ex) { + ex.printStackTrace(); + } + } + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + doGet(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index a41ee348..6ffe1309 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -4,7 +4,6 @@ javax.faces.PROJECT_STAGE Development - JDBC-DRIVER com.mysql.jdbc.Driver @@ -19,18 +18,25 @@ DB-PASSWORD - + - Faces Servlet javax.faces.webapp.FacesServlet 1 + + login + paket.login + Faces Servlet /faces/* + + login + /login + 30 diff --git a/web/login.xhtml b/web/login.xhtml index b98de55a..85bdc902 100644 --- a/web/login.xhtml +++ b/web/login.xhtml @@ -13,15 +13,15 @@

Login

-
+ - + - +

- +
From f4dd8b4a775170f5cf06316277cdc1eb3f6c6879 Mon Sep 17 00:00:00 2001 From: runbow Date: Sat, 22 Nov 2014 18:02:02 +0700 Subject: [PATCH 11/58] login cookies --- src/java/paket/login.java | 5 +++-- web/footer-script.xhtml | 1 + web/header-script.xhtml | 1 + web/header.xhtml | 5 +++-- web/index.xhtml | 8 ++++---- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/java/paket/login.java b/src/java/paket/login.java index bc353fea..426858b7 100644 --- a/src/java/paket/login.java +++ b/src/java/paket/login.java @@ -87,9 +87,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) session.setAttribute("owner", request.getParameter("usrname")); session.setAttribute("role", role); - + String name = rset.getString("nama_usr"); //set session age - Cookie cookie = new Cookie ("owner", request.getParameter("usrname")); + Cookie cookie = new Cookie ("user", name); cookie.setMaxAge(3600); Cookie cookie2 = new Cookie("role", role); cookie2.setMaxAge(3600); @@ -97,6 +97,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) response.addCookie(cookie2); out.print("success"); + response.sendRedirect("index.xhtml"); }else{ out.print("password salah!"); } diff --git a/web/footer-script.xhtml b/web/footer-script.xhtml index bda42ce4..0579dc81 100644 --- a/web/footer-script.xhtml +++ b/web/footer-script.xhtml @@ -7,6 +7,7 @@ + -Simple Blog - - diff --git a/web/index.xhtml b/web/index.xhtml index 596d7b2c..2d184a50 100644 --- a/web/index.xhtml +++ b/web/index.xhtml @@ -4,8 +4,11 @@ xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> - + + + Simple Blog +
From b437ecc81ee026bf22d3c8885876f51c67da1d45 Mon Sep 17 00:00:00 2001 From: runbow Date: Mon, 24 Nov 2014 15:47:49 +0700 Subject: [PATCH 20/58] refix manage user --- src/java/paket/AddUser.java | 105 ---------------- src/java/paket/ManUser.java | 215 +++++++++++++++++++++++++++++++++ src/java/paket/ManageUser.java | 173 -------------------------- web/ManageUser.xhtml | 94 ++++++++++++++ web/WEB-INF/faces-config.xml | 6 +- web/header.xhtml | 1 + 6 files changed, 315 insertions(+), 279 deletions(-) delete mode 100644 src/java/paket/AddUser.java create mode 100644 src/java/paket/ManUser.java delete mode 100644 src/java/paket/ManageUser.java create mode 100644 web/ManageUser.xhtml diff --git a/src/java/paket/AddUser.java b/src/java/paket/AddUser.java deleted file mode 100644 index baca0065..00000000 --- a/src/java/paket/AddUser.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package paket; - -import java.io.IOException; -import java.io.PrintWriter; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import javax.servlet.ServletException; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -/** - * - * @author TOSHIBA - */ -public class AddUser extends HttpServlet { - - String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; - String uName = "root"; - String pass = ""; - // - /** - * Handles the HTTP - * GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - PrintWriter out = response.getWriter(); - Connection conn = null; - Statement stmnt = null; - - try { - try { - Class.forName("com.mysql.jdbc.Driver"); - } catch (Exception e) { - e.printStackTrace(); - out.println("Unable to load Driver"); - } - conn = DriverManager.getConnection(dbURL, uName, pass); - stmnt = conn.createStatement(); - - String sqlStr = "INSERT INTO `usr` (`usrname`, `passwrd`, `nama_usr`, `email_usr`, `role`) VALUES ( '" + request.getParameter("username") + "', '" + request.getParameter("password") + "', '" + request.getParameter("nama") + "', '" + request.getParameter("email") + "', '" + request.getParameter("role") + "')"; - - stmnt.executeUpdate(sqlStr); - response.sendRedirect("ManageUser"); - } catch (SQLException ex) { - ex.printStackTrace(); - out.println("Unable to connect to database"); - out.print(ex.toString()); - }finally { - out.close(); - try { - // Step 5: Close the Statement and Connection - if (stmnt != null) { - stmnt.close(); - } - if (conn != null) { - conn.close(); - } - } catch (SQLException ex) { - ex.printStackTrace(); - } - } - } - - /** - * Handles the HTTP - * POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doGet(request, response); - } - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo() { - return "Short description"; - }// -} diff --git a/src/java/paket/ManUser.java b/src/java/paket/ManUser.java new file mode 100644 index 00000000..97732f35 --- /dev/null +++ b/src/java/paket/ManUser.java @@ -0,0 +1,215 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package paket; + +import java.io.Serializable; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Arrays; + +/** + * + * @author TOSHIBA + */ + +public class ManUser implements Serializable{ + + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + + String usrname; + String passwrd; + String nama_usr; + String email_usr; + String role; + + public String getUsrname() { + return usrname; + } + + public void setUsrname(String usrname) { + this.usrname = usrname; + } + + public String getPasswrd() { + return passwrd; + } + + public void setPasswrd(String passwrd) { + this.passwrd = passwrd; + } + + public String getNama_usr() { + return nama_usr; + } + + public void setNama_usr(String nama_usr) { + this.nama_usr = nama_usr; + } + + public String getEmail_usr() { + return email_usr; + } + + public void setEmail_usr(String email_usr) { + this.email_usr = email_usr; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public static class User{ + String usrname; + String passwrd; + String nama_usr; + String email_usr; + + public String getEmail_usr() { + return email_usr; + } + + public void setEmail_usr(String email_usr) { + this.email_usr = email_usr; + } + String role; + + public User(String usrname, String passwrd, String nama_usr, String email_usr, String role) { + this.usrname = usrname; + this.passwrd = passwrd; + this.nama_usr = nama_usr; + this.email_usr = email_usr; + this.role = role; + } + + public String getUsrname() { + return usrname; + } + + public void setUsrname(String usrname) { + this.usrname = usrname; + } + + public String getPasswrd() { + return passwrd; + } + + public void setPasswrd(String passwrd) { + this.passwrd = passwrd; + } + + public String getNama_usr() { + return nama_usr; + } + + public void setNama_usr(String nama_usr) { + this.nama_usr = nama_usr; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + + + } + private ArrayList users; + + public ArrayList getUsers() throws SQLException{ + + Connection conn = null; + Statement stmnt = null; + + ArrayList users = new ArrayList(); + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (Exception e) { + System.out.println("Unable to load Driver"); + + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "SELECT * FROM `usr`"; + ResultSet rSet = stmnt.executeQuery(sqlStr); + while (rSet.next()){ + + String usrname = rSet.getString("usrname"); + String nama_usr = rSet.getString("nama_usr"); + String email_usr = rSet.getString("email_usr"); + String role = rSet.getString("role"); + User user = new User(usrname, passwrd, nama_usr, email_usr, role); + + users.add(user); + System.out.println(users); + } + } catch (SQLException ex) { + // Step 1: Create a database "Connection" object + ex.printStackTrace(); + System.out.println("Unable to connect to database"); + + } + return users; + } + + public String addAction() { + +// User user = new User(this.usrname, this.passwrd, +// this.nama_usr, this.email_usr, this.role); +// +// users.add(user); + Connection conn = null; + Statement stmnt = null; + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "INSERT INTO `usr` (`usrname`, `passwrd`, `nama_usr`, `email_usr`, `role`) VALUES ( '" + usrname + "', '" + passwrd + "', '" + nama_usr + "', '" + email_usr + "', '" + role + "')"; + + stmnt.executeUpdate(sqlStr); + } catch (SQLException ex) { + ex.printStackTrace(); + System.out.println("Unable to connect to database"); + System.out.print(ex.toString()); + }finally { + System.out.close(); + try { + // Step 5: Close the Statement and Connection + if (stmnt != null) { + stmnt.close(); + } + if (conn != null) { + conn.close(); + } + } catch (SQLException ex) { + ex.printStackTrace(); + } + } + return null; + } +} + + diff --git a/src/java/paket/ManageUser.java b/src/java/paket/ManageUser.java deleted file mode 100644 index c1fec87a..00000000 --- a/src/java/paket/ManageUser.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package paket; - -import java.io.IOException; -import java.io.PrintWriter; -import java.sql.*; -import javax.servlet.ServletException; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author TOSHIBA - */ -public class ManageUser extends HttpServlet { - - String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; - String uName = "root"; - String pass = ""; - /** - * Processes requests for both HTTP - * GET and - * POST methods. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - - - // - /** - * Handles the HTTP - * GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - PrintWriter out = response.getWriter(); - Connection conn = null; - Statement stmnt = null; - - - Cookie[] cookies = request.getCookies(); - // Get an array of Cookies associated with this domain - - try { - try { - Class.forName("com.mysql.jdbc.Driver"); - } catch (Exception e) { - e.printStackTrace(); - out.println("Unable to load Driver"); - } - conn = DriverManager.getConnection(dbURL, uName, pass); - stmnt = conn.createStatement(); - - String sqlStr = "SELECT `usrname`, `nama_usr`, `email_usr`, `role` FROM `usr`"; - ResultSet rSet = stmnt.executeQuery(sqlStr); - - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println("Simple Blog | Manajemen User"); - out.println(""); - out.println(""); - out.println("
"); - out.println(""); - if (cookies!=null){ - String role1 = null; - for(Cookie cookie : cookies){ - if("role".equals(cookie.getName())){ - role1 = cookie.getValue(); - } - } - if ("admin".equals(role1)){ - out.print(""); - out.print(""); - out.print(""); - out.print(""); - out.print(""); - out.print(""); - out.print(""); - out.print(""); - out.print(""); - out.print(""); - - while (rSet.next()){ - String usrname = rSet.getString("usrname"); - String nama_usr = rSet.getString("nama_usr"); - String email_usr = rSet.getString("email_usr"); - String role = rSet.getString("role"); - - out.print(""); - out.print(""); - out.print(""); - out.print(""); - out.print(""); - out.print("\n"); - - } - out.print(""); - } - else{ - out.println("

Anda harus masuk sebagai admin!

"); - } - }else{ - out.println("

Anda harus masuk sebagai admin!

"); - } - out.println(""); - out.println(""); - out.println(""); - out.println(""); - }catch(Exception ex){ - ex.printStackTrace(); - out.println("Unable to connect to database"); - out.print(ex.toString()); - }finally { - out.close(); - try { - // Step 5: Close the Statement and Connection - if (stmnt != null) { - stmnt.close(); - } - if (conn != null) { - conn.close(); - } - } catch (SQLException ex) { - ex.printStackTrace(); - } - } - } - /** - * Handles the HTTP - * POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - - } - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo() { - return "Short description"; - }// -} diff --git a/web/ManageUser.xhtml b/web/ManageUser.xhtml new file mode 100644 index 00000000..17c3267f --- /dev/null +++ b/web/ManageUser.xhtml @@ -0,0 +1,94 @@ + + + + + + + + +

JSF 2 dataTable example

+ + + + + + Username + #{o.usrname} + + + + + + Nama + #{o.nama_usr} + + + + + + Email + #{o.email_usr} + + + + + + Role + #{o.role} + + + + + + Action + + + + + + + +

Tambah User

+
NamaEmailRoleTindakan
"+nama_usr+""+email_usr+""+role+"

+ + + + + + + + + + + + + + + + + + + + +
Username :
Password :
Nama :
Email :
Role : + + + + +
+ + + + + + + \ No newline at end of file diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index ceffa95a..774d0ad8 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -3,5 +3,9 @@ xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"> - + + manUser + paket.ManUser + request + diff --git a/web/header.xhtml b/web/header.xhtml index 0e9701b1..b0e6b44e 100644 --- a/web/header.xhtml +++ b/web/header.xhtml @@ -12,6 +12,7 @@
  • Howdy, Guest
  • + Tambah Post
  • Login
  • +
  • Manage User
  • From d17519b10caf5affffaf435b3d7a1ea0a8630937 Mon Sep 17 00:00:00 2001 From: runbow Date: Mon, 24 Nov 2014 16:15:07 +0700 Subject: [PATCH 21/58] add header&footer to manage user --- web/ManageUser.xhtml | 26 +++++++++++++++++++------- web/assets/css/screen.css | 24 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/web/ManageUser.xhtml b/web/ManageUser.xhtml index 17c3267f..2b1b0909 100644 --- a/web/ManageUser.xhtml +++ b/web/ManageUser.xhtml @@ -7,12 +7,18 @@ xmlns:ui="http://java.sun.com/jsf/facelets" > - + + + Simple Blog | Manage User - - -

    JSF 2 dataTable example

    - + +
    + +
    +
    +

    Manage User

    +
    + -

    Tambah User

    +
    Tambah User
    @@ -88,7 +94,13 @@ - + + + + + + + \ No newline at end of file diff --git a/web/assets/css/screen.css b/web/assets/css/screen.css index 2b6d755a..86795bc4 100644 --- a/web/assets/css/screen.css +++ b/web/assets/css/screen.css @@ -859,4 +859,28 @@ label { margin-right: 15px; width: 100px; padding-top: 5px; +} + +/*tambahan*/ +.order-table{ + border-collapse:collapse; +} + +.order-table-header{ + text-align:center; + background:none repeat scroll 0 0 #E5E5E5; + border-bottom:1px solid #BBBBBB; + padding:16px; +} + +.order-table-odd-row{ + text-align:center; + background:none repeat scroll 0 0 #FFFFFFF; + border-top:1px solid #BBBBBB; +} + +.order-table-even-row{ + text-align:center; + background:none repeat scroll 0 0 #F9F9F9; + border-top:1px solid #BBBBBB; } \ No newline at end of file From ca328c02ff45d1ace7a5615942efa5f212de31cf Mon Sep 17 00:00:00 2001 From: runbow Date: Mon, 24 Nov 2014 23:13:26 +0700 Subject: [PATCH 22/58] edit manage user page --- src/java/paket/ManUser.java | 44 +++++++++++++++++++++++++++++++++++++ web/ManageUser.xhtml | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/java/paket/ManUser.java b/src/java/paket/ManUser.java index 97732f35..f66beaed 100644 --- a/src/java/paket/ManUser.java +++ b/src/java/paket/ManUser.java @@ -210,6 +210,50 @@ public String addAction() { } return null; } + + public String delAction(User user) { + +// User user = new User(this.usrname, this.passwrd, +// this.nama_usr, this.email_usr, this.role); +// +// users.add(user); + Connection conn = null; + Statement stmnt = null; + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "DELETE FROM `usr` WHERE `usrname`='"+usrname+"'"; + + stmnt.executeUpdate(sqlStr); + } catch (SQLException ex) { + ex.printStackTrace(); + System.out.println("Unable to connect to database"); + System.out.print(ex.toString()); + }finally { + System.out.close(); + try { + // Step 5: Close the Statement and Connection + if (stmnt != null) { + stmnt.close(); + } + if (conn != null) { + conn.close(); + } + } catch (SQLException ex) { + ex.printStackTrace(); + } + } + users.remove(user); + return null; + } } diff --git a/web/ManageUser.xhtml b/web/ManageUser.xhtml index 2b1b0909..19b3eac5 100644 --- a/web/ManageUser.xhtml +++ b/web/ManageUser.xhtml @@ -57,7 +57,7 @@ Action - + From 9107b1fee0b62cd2d2e0bc0ce12f0b6909397e86 Mon Sep 17 00:00:00 2001 From: runbow Date: Tue, 25 Nov 2014 01:16:34 +0700 Subject: [PATCH 23/58] edit login & resource --- src/java/paket/DeleteUser.java | 102 --------- src/java/paket/ManUser.java | 6 +- web/ManageUser.xhtml | 3 +- web/WEB-INF/web.xml | 12 +- web/header-script.xhtml | 4 +- web/header.jsp | 2 +- web/header.xhtml | 4 +- web/index.xhtml | 4 +- web/login.xhtml | 44 ++-- web/resource/css/login.css | 195 ++++++++++++++++++ web/{assets => resource}/css/screen.css | 7 +- web/{assets => resource}/img/DeleteRed.png | Bin web/{assets => resource}/img/favicon.ico | Bin web/{assets => resource}/img/pre.png | Bin web/{assets => resource}/js/cookie.js | 0 .../js/validate_delete.js | 0 16 files changed, 237 insertions(+), 146 deletions(-) delete mode 100644 src/java/paket/DeleteUser.java create mode 100644 web/resource/css/login.css rename web/{assets => resource}/css/screen.css (99%) rename web/{assets => resource}/img/DeleteRed.png (100%) rename web/{assets => resource}/img/favicon.ico (100%) rename web/{assets => resource}/img/pre.png (100%) rename web/{assets => resource}/js/cookie.js (100%) rename web/{assets => resource}/js/validate_delete.js (100%) diff --git a/src/java/paket/DeleteUser.java b/src/java/paket/DeleteUser.java deleted file mode 100644 index 0fe62ecc..00000000 --- a/src/java/paket/DeleteUser.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package paket; - -import java.io.IOException; -import java.io.PrintWriter; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author TOSHIBA - */ -public class DeleteUser extends HttpServlet { - - String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; - String uName = "root"; - String pass = ""; - - // - /** - * Handles the HTTP - * GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - - PrintWriter out = response.getWriter(); - Connection conn = null; - Statement stmnt = null; - - try { - try { - Class.forName("com.mysql.jdbc.Driver"); - } catch (Exception e) { - e.printStackTrace(); - out.println("Unable to load Driver"); - } - conn = DriverManager.getConnection(dbURL, uName, pass); - stmnt = conn.createStatement(); - - String usrname = request.getParameter("param"); - String sqlStr = "DELETE FROM `usr` WHERE `usrname`='"+usrname+"'"; - stmnt.executeUpdate(sqlStr); - - response.sendRedirect("ManageUser"); - }catch(Exception ex){ - ex.printStackTrace(); - out.println("Unable to connect to database"); - out.print(ex.toString()); - }finally { - out.close(); - try { - // Step 5: Close the Statement and Connection - if (stmnt != null) { - stmnt.close(); - } - if (conn != null) { - conn.close(); - } - } catch (SQLException ex) { - ex.printStackTrace(); - } - } - } - - /** - * Handles the HTTP - * POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo() { - return "Short description"; - }// -} diff --git a/src/java/paket/ManUser.java b/src/java/paket/ManUser.java index f66beaed..0c1c7dfe 100644 --- a/src/java/paket/ManUser.java +++ b/src/java/paket/ManUser.java @@ -211,7 +211,7 @@ public String addAction() { return null; } - public String delAction(User user) { + public String delAction(User user) { // User user = new User(this.usrname, this.passwrd, // this.nama_usr, this.email_usr, this.role); @@ -230,7 +230,7 @@ public String delAction(User user) { conn = DriverManager.getConnection(dbURL, uName, pass); stmnt = conn.createStatement(); - String sqlStr = "DELETE FROM `usr` WHERE `usrname`='"+usrname+"'"; + String sqlStr = "DELETE FROM `usr` WHERE `usrname`='"+user.usrname+"'"; stmnt.executeUpdate(sqlStr); } catch (SQLException ex) { @@ -251,7 +251,7 @@ public String delAction(User user) { ex.printStackTrace(); } } - users.remove(user); +// users.remove(user); return null; } } diff --git a/web/ManageUser.xhtml b/web/ManageUser.xhtml index 19b3eac5..b912599e 100644 --- a/web/ManageUser.xhtml +++ b/web/ManageUser.xhtml @@ -8,7 +8,6 @@ > - Simple Blog | Manage User @@ -57,7 +56,7 @@ Action - + diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index 72de8f47..62859788 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -37,17 +37,13 @@ ManageUser paket.ManageUser - - DeleteUser - paket.DeleteUser - AddUser paket.AddUser Faces Servlet - *.xhtml + /faces/* login @@ -61,10 +57,6 @@ ManageUser /ManageUser - - DeleteUser - /DeleteUser - AddUser /AddUser @@ -75,6 +67,6 @@ - index.xhtml + faces/index.xhtml diff --git a/web/header-script.xhtml b/web/header-script.xhtml index d80b87ac..43495b24 100644 --- a/web/header-script.xhtml +++ b/web/header-script.xhtml @@ -25,9 +25,9 @@ - + - + + + + + + Simple Blog | View Post + + +
    + + +
    + +
    +
    + +

    #{post.judul}

    +

    +
    +
    +
    +
    +
    + #{post.konten} +
    +

    Komentar

    +
    + + + + + + + +
    + + + + + + + + + + +
    +
    + + +
    + + + From e6530b3788f63029b9182c54faf5a6a6c443e3e4 Mon Sep 17 00:00:00 2001 From: runbow Date: Wed, 26 Nov 2014 16:24:55 +0700 Subject: [PATCH 28/58] repair logout link --- src/java/paket/CookieCheck.java | 53 +++++++++++++++++++++++++++++++++ web/WEB-INF/faces-config.xml | 5 ++++ web/header.xhtml | 9 +++--- 3 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 src/java/paket/CookieCheck.java diff --git a/src/java/paket/CookieCheck.java b/src/java/paket/CookieCheck.java new file mode 100644 index 00000000..7b38baca --- /dev/null +++ b/src/java/paket/CookieCheck.java @@ -0,0 +1,53 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package paket; + +import java.util.Map; +import javax.faces.context.FacesContext; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; + +/** + * + * @author TOSHIBA + */ +public class CookieCheck { + + FacesContext facesContext = FacesContext.getCurrentInstance(); + HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest(); + + /** + * Creates a new instance of CookieCheck + */ + public String CookieCheck() { + String cValue=null; + Cookie[] cookies = request.getCookies(); + for (Cookie cookie : cookies){ + if("role".equals(cookie.getName())){ + cValue = cookie.getValue(); + } + } + return cValue; + } + + public boolean isLoggedIn(){ + return CookieCheck()!=null; + } + + public boolean isAdmin(){ + return "admin".equals(CookieCheck()); + } + + public String getUName(){ + String UName="Guest"; + Cookie[] cookies = request.getCookies(); + for (Cookie cookie : cookies){ + if("user".equals(cookie.getName())){ + UName = cookie.getValue(); + } + } + return UName; + } +} diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index a7ada76d..748cd61a 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -18,4 +18,9 @@ paket.Logout request + + cookieCheck + paket.CookieCheck + request + diff --git a/web/header.xhtml b/web/header.xhtml index 3d2b4368..5db92acb 100644 --- a/web/header.xhtml +++ b/web/header.xhtml @@ -9,10 +9,11 @@ From b97970bb69c21b7eb53e8759aa09a8caf266c588 Mon Sep 17 00:00:00 2001 From: runbow Date: Wed, 26 Nov 2014 16:39:35 +0700 Subject: [PATCH 29/58] edit&clean some --- web/ManageUser.xhtml | 2 +- web/add-user.xhtml | 58 ------------------------------ web/header.jsp | 53 ---------------------------- web/header.xhtml | 3 +- web/index.jsp | 84 -------------------------------------------- web/index.xhtml | 2 +- 6 files changed, 4 insertions(+), 198 deletions(-) delete mode 100644 web/add-user.xhtml delete mode 100644 web/header.jsp delete mode 100644 web/index.jsp diff --git a/web/ManageUser.xhtml b/web/ManageUser.xhtml index b912599e..1e724868 100644 --- a/web/ManageUser.xhtml +++ b/web/ManageUser.xhtml @@ -10,7 +10,7 @@ Simple Blog | Manage User - +
    diff --git a/web/add-user.xhtml b/web/add-user.xhtml deleted file mode 100644 index 928e1adb..00000000 --- a/web/add-user.xhtml +++ /dev/null @@ -1,58 +0,0 @@ - - - - Simple Blog | Tambah User - - -
    - - -
    - - -

    -

    - -
    -
    -

    Tambah User

    - -
    -
    - - - - - - - - - - - - - - - - - -
    -
    -
    - -
    - - - -
    - - - -
    - \ No newline at end of file diff --git a/web/header.jsp b/web/header.jsp deleted file mode 100644 index 2d09213d..00000000 --- a/web/header.jsp +++ /dev/null @@ -1,53 +0,0 @@ -<%-- - Document : header - Created on : Nov 19, 2014, 12:01:29 AM - Author : TOSHIBA ---%> - -<%@page contentType="text/html" pageEncoding="UTF-8"%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Simple Blog - - - - - -
    - - diff --git a/web/header.xhtml b/web/header.xhtml index 5db92acb..5c9ae5ee 100644 --- a/web/header.xhtml +++ b/web/header.xhtml @@ -7,7 +7,8 @@ xmlns:ui="http://java.sun.com/jsf/facelets">
    - - - - - - - - - - - \ No newline at end of file diff --git a/web/index.xhtml b/web/index.xhtml index b88e180b..ecb51b5a 100644 --- a/web/index.xhtml +++ b/web/index.xhtml @@ -9,7 +9,7 @@ Simple Blog - +
    From ccdfadab7c0a3b926fec1efe7d21aa67dd853054 Mon Sep 17 00:00:00 2001 From: runbow Date: Wed, 26 Nov 2014 16:43:04 +0700 Subject: [PATCH 30/58] edit logout class --- src/java/paket/Logout.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/java/paket/Logout.java b/src/java/paket/Logout.java index 1079c583..8df2e5b5 100644 --- a/src/java/paket/Logout.java +++ b/src/java/paket/Logout.java @@ -4,6 +4,7 @@ */ package paket; +import java.io.IOException; import java.io.Serializable; import javax.faces.context.FacesContext; import javax.servlet.http.Cookie; @@ -20,7 +21,7 @@ public class Logout implements Serializable{ /** * Creates a new instance of Logout */ - public void Logout() { + public void Logout() throws IOException { FacesContext facesContext = FacesContext.getCurrentInstance(); HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest(); @@ -36,5 +37,7 @@ public void Logout() { //ivalidate session HttpSession session = request.getSession(); session.invalidate(); + + FacesContext.getCurrentInstance().getExternalContext().redirect("index.xhtml"); } } From 4183c2d5748f6f74ad93af95f57d6b8a8c7727a3 Mon Sep 17 00:00:00 2001 From: runbow Date: Wed, 26 Nov 2014 23:58:49 +0700 Subject: [PATCH 31/58] add login style --- nbproject/faces-config.NavData | 2 - web/header.xhtml | 2 +- web/login.xhtml | 5 +- web/resource/css/style.css | 105 +++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 web/resource/css/style.css diff --git a/nbproject/faces-config.NavData b/nbproject/faces-config.NavData index 3dd2bc74..72325963 100644 --- a/nbproject/faces-config.NavData +++ b/nbproject/faces-config.NavData @@ -3,9 +3,7 @@ - - diff --git a/web/header.xhtml b/web/header.xhtml index 5c9ae5ee..5d5f506e 100644 --- a/web/header.xhtml +++ b/web/header.xhtml @@ -10,7 +10,7 @@

    - + diff --git a/web/edit_post.xhtml b/web/edit_post.xhtml index 4606e8aa..7a6ff861 100644 --- a/web/edit_post.xhtml +++ b/web/edit_post.xhtml @@ -34,7 +34,10 @@ Tanggal : - + + + + Konten : diff --git a/web/new_post.xhtml b/web/new_post.xhtml index 7f887a01..8a9d1a20 100644 --- a/web/new_post.xhtml +++ b/web/new_post.xhtml @@ -34,7 +34,10 @@ Tanggal : - + + + + Konten : From 8ca025ddca92bb859e44ebb9aca229fa1e945c56 Mon Sep 17 00:00:00 2001 From: Mario Tressa Juzar Date: Tue, 2 Dec 2014 01:19:11 +0700 Subject: [PATCH 53/58] tambah list post --- nbproject/private/private.xml | 6 +- src/java/paket/Post.java | 170 ---------------------------------- src/java/paket/ViewPost.java | 120 ++++++++++++++++++++++-- web/WEB-INF/faces-config.xml | 2 +- web/index.xhtml | 37 +++----- web/post.xhtml | 10 +- 6 files changed, 135 insertions(+), 210 deletions(-) delete mode 100644 src/java/paket/Post.java diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index 86a6eaa1..03633b8b 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -3,12 +3,8 @@ - file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/web/header.xhtml + file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/src/java/paket/ViewPost.java file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/web/index.xhtml - file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/src/java/paket/editPost.java - file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/src/java/paket/Comment.java - file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/src/java/paket/CookieCheck.java - file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/web/edit_post.xhtml diff --git a/src/java/paket/Post.java b/src/java/paket/Post.java deleted file mode 100644 index 0db8d248..00000000 --- a/src/java/paket/Post.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package entity; - -import java.io.Serializable; -import java.sql.Connection; -import java.sql.Date; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import javax.faces.bean.ManagedBean; -import javax.faces.bean.ManagedProperty; -import javax.faces.bean.RequestScoped; - - -/** - * - * @author User - */ -@ManagedBean (name="post", eager=true) -@RequestScoped -public class Post { - private int id_post; - private String judul; - private String konten; - private Date tanggal_post; - private String status; - private int del_stat; - - String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; - String uName = "root"; - String pass = ""; - - private Post(int id_post, String judul, String konten, Date tanggal_post, String status, int del_stat) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - /** - * @return the id_post - */ - public int getId_post() { - return id_post; - } - - /** - * @param id_post the id_post to set - */ - public void setId_post(int id_post) { - this.id_post = id_post; - } - - /** - * @return the judul - */ - public String getJudul() { - return judul; - } - - /** - * @param judul the judul to set - */ - public void setJudul(String judul) { - this.judul = judul; - } - - /** - * @return the konten - */ - public String getKonten() { - return konten; - } - - /** - * @param konten the konten to set - */ - public void setKonten(String konten) { - this.konten = konten; - } - - /** - * @return the tanggal_post - */ - public Date getTanggal_post() { - return tanggal_post; - } - - /** - * @param tanggal_post the tanggal_post to set - */ - public void setTanggal_post(Date tanggal_post) { - this.tanggal_post = tanggal_post; - } - - /** - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * @param status the status to set - */ - public void setStatus(String status) { - this.status = status; - } - - /** - * @return the del_stat - */ - public int getDel_stat() { - return del_stat; - } - - /** - * @param del_stat the del_stat to set - */ - public void setDel_stat(int del_stat) { - this.del_stat = del_stat; - } - @ManagedProperty (value="#{posts}") - private ArrayList posts; - - public ArrayList getPost() throws SQLException { - - Connection connect = null; - Statement stmnt = null; - - ArrayList posts = new ArrayList(); - try { - try { - Class.forName("com.mysql.jdbc.Driver"); - } catch (Exception e) { - System.out.println("Unable to load Driver"); - - } - connect = DriverManager.getConnection(dbURL,uName,pass ); - stmnt = connect.createStatement(); - - String sqlStr = "SELECT * FROM `post`"; - ResultSet rSet = stmnt.executeQuery(sqlStr); - while (rSet.next()){ - int id_post = rSet.getInt("id_post"); - String judul = rSet.getString("judul"); - String konten = rSet.getString("konten"); - Date tanggal_post = rSet.getDate("tanggal_user"); - String status = rSet.getString("status"); - int del_stat = rSet.getInt("del_stat"); - Post post = new Post(id_post,judul,konten,tanggal_post,status,del_stat); - - posts.add(post); - System.out.println(posts); - } - } catch (SQLException ex) { - // Step 1: Create a database "Connection" object - ex.printStackTrace(); - System.out.println("Unable to connect to database"); - - } - return posts; - } - public boolean IsPublished(){ - return getStatus()=="published"; - } - -} diff --git a/src/java/paket/ViewPost.java b/src/java/paket/ViewPost.java index 490b3c12..52015923 100644 --- a/src/java/paket/ViewPost.java +++ b/src/java/paket/ViewPost.java @@ -6,11 +6,13 @@ package paket; +import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.util.ArrayList; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -22,7 +24,42 @@ */ public class ViewPost { - private String idpost, judul, konten, tanggal; + private String idpost, judul, konten, tanggal, status; + private String komen, nama, email; + private ResultSet rs; + private ArrayList listpost = new ArrayList(); + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getKomen() { + return komen; + } + + public void setKomen(String komen) { + this.komen = komen; + } + + public String getNama() { + return nama; + } + + public void setNama(String nama) { + this.nama = nama; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } public String getIdpost() { return idpost; @@ -61,7 +98,7 @@ public void setTanggal(String tanggal) { public ViewPost() { } - public void getPost(){ + public void ambilPostdanComment(){ String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; String uName = "root"; String pass = ""; @@ -77,9 +114,7 @@ public void getPost(){ Matcher matcher = pattern.matcher( peta ); if ( matcher.find() ) idpost = matcher.group( 1 ); - - System.out.print(idpost); - + try { try { Class.forName("com.mysql.jdbc.Driver"); @@ -91,7 +126,7 @@ public void getPost(){ stmnt = conn.createStatement(); String sqlStr = "SELECT * FROM `post` WHERE id_post='" +idpost +"'"; - ResultSet rs = stmnt.executeQuery(sqlStr); + rs = stmnt.executeQuery(sqlStr); if (rs.next()){ tanggal = rs.getString("tanggal_post"); @@ -99,9 +134,82 @@ public void getPost(){ konten = rs.getString("konten"); } + sqlStr = "SELECT * FROM `komen` WHERE id_post='" +idpost +"'"; + rs = stmnt.executeQuery(sqlStr); + + } catch (SQLException e){ + + } + } + + public ArrayList ambilPostList(){ + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + Integer i = 0; + Connection conn = null; + Statement stmnt = null; + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "SELECT * FROM post"; + ResultSet rs = stmnt.executeQuery(sqlStr); + + while (rs.next()){ + ViewPost view = new ViewPost(); + view.setJudul(rs.getString("judul")); + view.setKonten(rs.getString("konten")); + view.setTanggal(rs.getString("tanggal_post")); + view.setStatus(rs.getString("status")); + listpost.add(view); + } + } catch (SQLException e){ } + return listpost; + } + + public void executeComment() throws IOException{ + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + + Connection conn = null; + Statement stmnt = null; + + System.out.print("commentid"+idpost); + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "INSERT INTO `komen`(`nama`, `email`, `isi`, `id_post`) VALUE('" +nama +"', '" +email +"', '" +komen +"', '" +idpost +"')"; + stmnt.executeUpdate(sqlStr); + + FacesContext.getCurrentInstance().getExternalContext().redirect("post.xhtml?id="+idpost); + + } catch (SQLException e){ + + } + } + + public void clear(){ + listpost.clear(); } } diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index dff5d398..f6de7582 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -31,7 +31,7 @@ viewPost paket.ViewPost - request + session editUser diff --git a/web/index.xhtml b/web/index.xhtml index 8bd9b223..5e0508ff 100644 --- a/web/index.xhtml +++ b/web/index.xhtml @@ -9,7 +9,7 @@ Simple Blog - +
    @@ -17,28 +17,19 @@
    diff --git a/web/post.xhtml b/web/post.xhtml index e10cd846..b7375e9b 100644 --- a/web/post.xhtml +++ b/web/post.xhtml @@ -11,7 +11,7 @@ Simple Blog | <h:outputText value="#{viewPost.judul}"></h:outputText> - +
    @@ -34,15 +34,15 @@
    Nama: - + Email: - + Komentar:
    - + - +
    From c99666ed4b356ee674d5f6fb6dd51f3d23cb3989 Mon Sep 17 00:00:00 2001 From: Riska Date: Tue, 2 Dec 2014 01:37:01 +0700 Subject: [PATCH 54/58] tambah unpublished tambah unpublished --- src/java/paket/Unpublished.java | 113 ++++++++++++++++++++++++++++++++ src/java/paket/ViewPost.java | 2 +- web/WEB-INF/faces-config.xml | 5 ++ web/unpublished.xhtml | 36 +++++----- 4 files changed, 140 insertions(+), 16 deletions(-) create mode 100644 src/java/paket/Unpublished.java diff --git a/src/java/paket/Unpublished.java b/src/java/paket/Unpublished.java new file mode 100644 index 00000000..27255f32 --- /dev/null +++ b/src/java/paket/Unpublished.java @@ -0,0 +1,113 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package paket; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; + +/** + * + * @author Mario + */ +public class Unpublished { + + private String idpost, judul, konten, tanggal, status; + private ArrayList unpub = new ArrayList(); + + public String getIdpost() { + return idpost; + } + + public void setIdpost(String idpost) { + this.idpost = idpost; + } + + public String getJudul() { + return judul; + } + + public void setJudul(String judul) { + this.judul = judul; + } + + public String getKonten() { + return konten; + } + + public void setKonten(String konten) { + this.konten = konten; + } + + public String getTanggal() { + return tanggal; + } + + public void setTanggal(String tanggal) { + this.tanggal = tanggal; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + /** + * Creates a new instance of Unpublished + */ + public Unpublished() { + } + + public ArrayList ambilPostList(){ + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + + Connection conn = null; + Statement stmnt = null; + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "SELECT * FROM post"; + ResultSet rs = stmnt.executeQuery(sqlStr); + + while (rs.next()){ + Unpublished view = new Unpublished(); + view.setIdpost(rs.getString("id_post")); + view.setJudul(rs.getString("judul")); + view.setKonten(rs.getString("konten")); + view.setTanggal(rs.getString("tanggal_post")); + view.setStatus(rs.getString("status")); + if ("unpublished".equals(view.getStatus().toString())){ + unpub.add(view); + } + } + + } catch (SQLException e){ + + } + return unpub; + } + + public void clear(){ + unpub.clear(); + } +} diff --git a/src/java/paket/ViewPost.java b/src/java/paket/ViewPost.java index 52015923..6a5fd635 100644 --- a/src/java/paket/ViewPost.java +++ b/src/java/paket/ViewPost.java @@ -146,7 +146,7 @@ public ArrayList ambilPostList(){ String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; String uName = "root"; String pass = ""; - Integer i = 0; + Connection conn = null; Statement stmnt = null; diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index f6de7582..0ac887f4 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -38,4 +38,9 @@ paket.editUser request + + unpublished + paket.Unpublished + request + diff --git a/web/unpublished.xhtml b/web/unpublished.xhtml index f048cb47..a338ca06 100644 --- a/web/unpublished.xhtml +++ b/web/unpublished.xhtml @@ -11,25 +11,31 @@ Simple Blog | Unpublished Post - +
    -
    -
    - -
    +
    +
    +
    +
    From 1460bf01dc42efcb82c5d937f6c282b3aff6bdf6 Mon Sep 17 00:00:00 2001 From: Riska Date: Tue, 2 Dec 2014 01:52:03 +0700 Subject: [PATCH 55/58] tambah soft delete tambah soft delete --- src/java/paket/SoftDelete.java | 121 ++++++++++++++++++++++++++++++++ src/java/paket/Unpublished.java | 11 ++- web/WEB-INF/faces-config.xml | 5 ++ web/softdelete.xhtml | 36 ++++++---- 4 files changed, 157 insertions(+), 16 deletions(-) create mode 100644 src/java/paket/SoftDelete.java diff --git a/src/java/paket/SoftDelete.java b/src/java/paket/SoftDelete.java new file mode 100644 index 00000000..2219c9fc --- /dev/null +++ b/src/java/paket/SoftDelete.java @@ -0,0 +1,121 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package paket; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; + +/** + * + * @author Mario + */ +public class SoftDelete { + + private String idpost, judul, konten, tanggal, status, del_stat; + private ArrayList sdel = new ArrayList(); + + public String getIdpost() { + return idpost; + } + + public void setIdpost(String idpost) { + this.idpost = idpost; + } + + public String getJudul() { + return judul; + } + + public void setJudul(String judul) { + this.judul = judul; + } + + public String getKonten() { + return konten; + } + + public void setKonten(String konten) { + this.konten = konten; + } + + public String getTanggal() { + return tanggal; + } + + public void setTanggal(String tanggal) { + this.tanggal = tanggal; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getDel_stat() { + return del_stat; + } + + public void setDel_stat(String del_stat) { + this.del_stat = del_stat; + } + /** + * Creates a new instance of SoftDelete + */ + public SoftDelete() { + } + + public ArrayList ambilPostList(){ + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + + Connection conn = null; + Statement stmnt = null; + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "SELECT * FROM post"; + ResultSet rs = stmnt.executeQuery(sqlStr); + + while (rs.next()){ + SoftDelete view = new SoftDelete(); + view.setIdpost(rs.getString("id_post")); + view.setJudul(rs.getString("judul")); + view.setKonten(rs.getString("konten")); + view.setTanggal(rs.getString("tanggal_post")); + view.setStatus(rs.getString("status")); + view.setDel_stat(rs.getString("del_stat")); + if (!"0".equals(view.getDel_stat().toString())){ + sdel.add(view); + } + } + + } catch (SQLException e){ + + } + return sdel; + } + + public void clear(){ + sdel.clear(); + } +} diff --git a/src/java/paket/Unpublished.java b/src/java/paket/Unpublished.java index 27255f32..8238af30 100644 --- a/src/java/paket/Unpublished.java +++ b/src/java/paket/Unpublished.java @@ -19,8 +19,16 @@ */ public class Unpublished { - private String idpost, judul, konten, tanggal, status; + private String idpost, judul, konten, tanggal, status, del_stat; private ArrayList unpub = new ArrayList(); + + public String getDel_stat() { + return del_stat; + } + + public void setDel_stat(String del_stat) { + this.del_stat = del_stat; + } public String getIdpost() { return idpost; @@ -96,6 +104,7 @@ public ArrayList ambilPostList(){ view.setKonten(rs.getString("konten")); view.setTanggal(rs.getString("tanggal_post")); view.setStatus(rs.getString("status")); + view.setDel_stat(rs.getString("del_stat")); if ("unpublished".equals(view.getStatus().toString())){ unpub.add(view); } diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index 0ac887f4..e8ece3b2 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -43,4 +43,9 @@ paket.Unpublished request + + softDelete + paket.SoftDelete + request + diff --git a/web/softdelete.xhtml b/web/softdelete.xhtml index 735c564a..46155e56 100644 --- a/web/softdelete.xhtml +++ b/web/softdelete.xhtml @@ -11,25 +11,31 @@ Simple Blog | Soft Delete - +
    -
    -
    - -
    +
    +
    +
    +
    From 174959716561bd6bf28726664016982fc0518027 Mon Sep 17 00:00:00 2001 From: Mario Tressa Juzar Date: Tue, 2 Dec 2014 03:19:32 +0700 Subject: [PATCH 56/58] perbaikan beberapa fungsi --- src/java/paket/Unpublished.java | 28 ++++++++++++++++++ src/java/paket/ViewPost.java | 51 +++++++++++++++++++++++++++++++-- web/edit_post.xhtml | 4 +-- web/index.xhtml | 8 ++++-- web/new_post.xhtml | 2 +- web/post.xhtml | 27 +++++++---------- web/softdelete.xhtml | 4 +++ web/unpublished.xhtml | 5 ++++ 8 files changed, 105 insertions(+), 24 deletions(-) diff --git a/src/java/paket/Unpublished.java b/src/java/paket/Unpublished.java index 8238af30..f042f184 100644 --- a/src/java/paket/Unpublished.java +++ b/src/java/paket/Unpublished.java @@ -6,12 +6,14 @@ package paket; +import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; +import javax.faces.context.FacesContext; /** * @@ -119,4 +121,30 @@ public ArrayList ambilPostList(){ public void clear(){ unpub.clear(); } + + public void jadikanPublish(String id) throws IOException{ + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + + Connection conn = null; + Statement stmnt = null; + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + System.out.print("id disini"+id); + String sqlStr = "UPDATE post SET status='published' WHERE id_post="+id; + stmnt.executeUpdate(sqlStr); + + } catch (SQLException e){ + + } + } } diff --git a/src/java/paket/ViewPost.java b/src/java/paket/ViewPost.java index 6a5fd635..ab26bcc3 100644 --- a/src/java/paket/ViewPost.java +++ b/src/java/paket/ViewPost.java @@ -24,11 +24,44 @@ */ public class ViewPost { - private String idpost, judul, konten, tanggal, status; + private String idpost, judul, konten, tanggal, status, del_stat, tgl_komen; private String komen, nama, email; private ResultSet rs; private ArrayList listpost = new ArrayList(); + private ArrayList listkomen = new ArrayList(); + public String getTgl_komen() { + return tgl_komen; + } + + public void setTgl_komen(String tgl_komen) { + this.tgl_komen = tgl_komen; + } + + public ArrayList getListpost() { + return listpost; + } + + public void setListpost(ArrayList listpost) { + this.listpost = listpost; + } + + public ArrayList getListkomen() { + return listkomen; + } + + public void setListkomen(ArrayList listkomen) { + this.listkomen = listkomen; + } + + public String getDel_stat() { + return del_stat; + } + + public void setDel_stat(String del_stat) { + this.del_stat = del_stat; + } + public String getStatus() { return status; } @@ -99,6 +132,7 @@ public ViewPost() { } public void ambilPostdanComment(){ + clear(); String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; String uName = "root"; String pass = ""; @@ -137,6 +171,14 @@ public void ambilPostdanComment(){ sqlStr = "SELECT * FROM `komen` WHERE id_post='" +idpost +"'"; rs = stmnt.executeQuery(sqlStr); + while (rs.next()){ + ViewPost view = new ViewPost(); + view.setKomen(rs.getString("isi")); + view.setNama(rs.getString("nama")); + view.setTgl_komen(rs.getString("tangggal_kom")); + listkomen.add(view); + } + } catch (SQLException e){ } @@ -165,11 +207,15 @@ public ArrayList ambilPostList(){ while (rs.next()){ ViewPost view = new ViewPost(); + view.setIdpost(rs.getString("id_post")); view.setJudul(rs.getString("judul")); view.setKonten(rs.getString("konten")); view.setTanggal(rs.getString("tanggal_post")); view.setStatus(rs.getString("status")); - listpost.add(view); + view.setDel_stat(rs.getString("del_stat")); + if ("published".equals(view.getStatus().toString())&&("0".equals(view.getDel_stat().toString()))){ + listpost.add(view); + } } } catch (SQLException e){ @@ -210,6 +256,7 @@ public void executeComment() throws IOException{ public void clear(){ listpost.clear(); + listkomen.clear(); } } diff --git a/web/edit_post.xhtml b/web/edit_post.xhtml index 7a6ff861..67025cad 100644 --- a/web/edit_post.xhtml +++ b/web/edit_post.xhtml @@ -34,8 +34,8 @@ Tanggal : - - + + diff --git a/web/index.xhtml b/web/index.xhtml index 5e0508ff..fac697a2 100644 --- a/web/index.xhtml +++ b/web/index.xhtml @@ -21,12 +21,16 @@
  • - #{list.judul} + #{list.judul}

    #{list.tanggal}

    - #{list.konten} + #{list.konten} +

    +

    + | +

  • diff --git a/web/new_post.xhtml b/web/new_post.xhtml index 8a9d1a20..de234226 100644 --- a/web/new_post.xhtml +++ b/web/new_post.xhtml @@ -35,7 +35,7 @@ Tanggal : - + diff --git a/web/post.xhtml b/web/post.xhtml index b7375e9b..a388269c 100644 --- a/web/post.xhtml +++ b/web/post.xhtml @@ -44,25 +44,18 @@ -
    - -
      -
    • -
      -

      Jems

      -
      2 menit lalu
      -
      -

      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis repudiandae quae natus quos alias eos repellendus a obcaecati cupiditate similique quibusdam, atque omnis illum, minus ex dolorem facilis tempora deserunt! …

      -
    • - -
    • +
    + +
      -

      Kave

      -
      1 jam lalu
      +

      #{list.nama}

      +
      #{list.tgl_komen}
      -

      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis repudiandae quae natus quos alias eos repellendus a obcaecati cupiditate similique quibusdam, atque omnis illum, minus ex dolorem facilis tempora deserunt! …

      - -
    +

    + #{list.komen} +

    + +
    diff --git a/web/softdelete.xhtml b/web/softdelete.xhtml index 46155e56..1b388ffd 100644 --- a/web/softdelete.xhtml +++ b/web/softdelete.xhtml @@ -30,6 +30,10 @@

    #{list.konten}

    +

    + | + +

    diff --git a/web/unpublished.xhtml b/web/unpublished.xhtml index a338ca06..b8b588ce 100644 --- a/web/unpublished.xhtml +++ b/web/unpublished.xhtml @@ -30,6 +30,11 @@

    #{list.konten}

    +

    + | + | + +

    From 259e63c6f7b25b9454a7c6272406604a7a700ad3 Mon Sep 17 00:00:00 2001 From: Mario Tressa Juzar Date: Tue, 2 Dec 2014 03:53:02 +0700 Subject: [PATCH 57/58] edit beberapa file --- nbproject/faces-config.NavData | 2 +- src/java/paket/SoftDelete.java | 26 ++++++++++++++++++++++++++ src/java/paket/ViewPost.java | 32 +++++++++++++++++++++++++++++++- web/post.xhtml | 6 +++--- web/softdelete.xhtml | 2 +- web/unpublished.xhtml | 2 +- 6 files changed, 63 insertions(+), 7 deletions(-) diff --git a/nbproject/faces-config.NavData b/nbproject/faces-config.NavData index a689e72f..d04fee8a 100644 --- a/nbproject/faces-config.NavData +++ b/nbproject/faces-config.NavData @@ -4,8 +4,8 @@ - + diff --git a/src/java/paket/SoftDelete.java b/src/java/paket/SoftDelete.java index 2219c9fc..49577eb8 100644 --- a/src/java/paket/SoftDelete.java +++ b/src/java/paket/SoftDelete.java @@ -118,4 +118,30 @@ public ArrayList ambilPostList(){ public void clear(){ sdel.clear(); } + + public void restorePost(){ + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + + Connection conn = null; + Statement stmnt = null; + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "UPDATE post SET del_stat=0 WHERE id_post=" +idpost; + ResultSet rs = stmnt.executeQuery(sqlStr); + + } catch (SQLException e){ + + } + } } diff --git a/src/java/paket/ViewPost.java b/src/java/paket/ViewPost.java index ab26bcc3..95573299 100644 --- a/src/java/paket/ViewPost.java +++ b/src/java/paket/ViewPost.java @@ -168,7 +168,7 @@ public void ambilPostdanComment(){ konten = rs.getString("konten"); } - sqlStr = "SELECT * FROM `komen` WHERE id_post='" +idpost +"'"; + sqlStr = "SELECT * FROM `komen` WHERE id_post=" +idpost; rs = stmnt.executeQuery(sqlStr); while (rs.next()){ @@ -259,4 +259,34 @@ public void clear(){ listkomen.clear(); } + public void executeSoftDelete() throws IOException{ + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + + Connection conn = null; + Statement stmnt = null; + + System.out.print("commentid"+idpost); + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "UPDATE post SET del_stat=1 WHERE id_post="+idpost; + stmnt.executeUpdate(sqlStr); + + FacesContext.getCurrentInstance().getExternalContext().redirect("index.xhtml"); + + } catch (SQLException e){ + + } + } + } diff --git a/web/post.xhtml b/web/post.xhtml index a388269c..637c7c1e 100644 --- a/web/post.xhtml +++ b/web/post.xhtml @@ -34,13 +34,13 @@
    Nama: - + Email: - + Komentar:
    - +
    diff --git a/web/softdelete.xhtml b/web/softdelete.xhtml index 1b388ffd..b45dfd97 100644 --- a/web/softdelete.xhtml +++ b/web/softdelete.xhtml @@ -23,7 +23,7 @@
  • - #{list.judul} + #{list.judul}

    #{list.tanggal}
    diff --git a/web/unpublished.xhtml b/web/unpublished.xhtml index b8b588ce..fd1c4440 100644 --- a/web/unpublished.xhtml +++ b/web/unpublished.xhtml @@ -23,7 +23,7 @@
  • - #{list.judul} + #{list.judul}

    #{list.tanggal}
    From 4e7216f41d807fe51e259d38af81d98eef8ddb4c Mon Sep 17 00:00:00 2001 From: runbow Date: Tue, 2 Dec 2014 05:07:12 +0700 Subject: [PATCH 58/58] add delete link add delete link --- src/java/paket/deletePost.java | 68 ++++++++++++++++++++++++++++++++++ web/WEB-INF/faces-config.xml | 5 +++ web/index.xhtml | 4 +- web/unpublished.xhtml | 6 +-- 4 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 src/java/paket/deletePost.java diff --git a/src/java/paket/deletePost.java b/src/java/paket/deletePost.java new file mode 100644 index 00000000..3834bedd --- /dev/null +++ b/src/java/paket/deletePost.java @@ -0,0 +1,68 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package paket; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import javax.faces.context.FacesContext; + +/** + * + * @author TOSHIBA + */ +public class deletePost { + + private String idpost, judul, konten, tanggal, status, del_stat; + + public String getIdpost() { + return idpost; + } + + public void setIdpost(String idpost) { + this.idpost = idpost; + } + + public String getDel_stat() { + return del_stat; + } + + public void setDel_stat(String del_stat) { + this.del_stat = del_stat; + } + + /** + * Creates a new instance of deletePost + */ + public void deletePost() throws IOException { + FacesContext.getCurrentInstance().getExternalContext().redirect("index.xhtml"); +// String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; +// String uName = "root"; +// String pass = ""; +// +// Connection conn = null; +// Statement stmnt = null; +// +// try { +// try { +// Class.forName("com.mysql.jdbc.Driver"); +// } catch (ClassNotFoundException e) { +// e.printStackTrace(); +// System.out.println("Unable to load Driver"); +// } +// conn = DriverManager.getConnection(dbURL, uName, pass); +// stmnt = conn.createStatement(); +// +// String sqlStr = "UPDATE post SET del_stat=1 WHERE id_post=" +idpost; +// ResultSet rs = stmnt.executeQuery(sqlStr); +// +// } catch (SQLException e){ +// +// } + } +} diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index e8ece3b2..8a406920 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -48,4 +48,9 @@ paket.SoftDelete request + + deletePost + paket.deletePost + request + diff --git a/web/index.xhtml b/web/index.xhtml index fac697a2..45121cbc 100644 --- a/web/index.xhtml +++ b/web/index.xhtml @@ -29,8 +29,8 @@ #{list.konten}

    - | - + | +

  • diff --git a/web/unpublished.xhtml b/web/unpublished.xhtml index fd1c4440..b0d30ab0 100644 --- a/web/unpublished.xhtml +++ b/web/unpublished.xhtml @@ -30,10 +30,10 @@

    #{list.konten}

    -

    +

    | - | - + | +

    Username :
    Role : - From 23ad2ffa9f006f9886bebd542a45456d3db85709 Mon Sep 17 00:00:00 2001 From: runbow Date: Mon, 1 Dec 2014 16:35:10 +0700 Subject: [PATCH 40/58] edit header --- src/java/paket/CookieCheck.java | 16 ++++++++++++++++ web/ManageUser.xhtml | 1 + web/header.xhtml | 4 +++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/java/paket/CookieCheck.java b/src/java/paket/CookieCheck.java index 0cafec9f..59ceec62 100644 --- a/src/java/paket/CookieCheck.java +++ b/src/java/paket/CookieCheck.java @@ -42,6 +42,14 @@ public boolean isAdmin(){ return "admin".equals(CookieCheck()); } + public boolean isOwner(){ + return "owner".equals(CookieCheck()); + } + + public boolean isEditor(){ + return "editor".equals(CookieCheck()); + } + public String getUName(){ String UName="Guest"; Cookie[] cookies = request.getCookies(); @@ -67,4 +75,12 @@ public String getUsrName(){ } return UsrName; } + + public boolean adminORowner(){ + return (isLoggedIn() && (isAdmin() || isOwner())); + } + + public boolean adminOReditor(){ + return (isLoggedIn() && (isAdmin() || isEditor())); + } } diff --git a/web/ManageUser.xhtml b/web/ManageUser.xhtml index 6d0680e9..7470c344 100644 --- a/web/ManageUser.xhtml +++ b/web/ManageUser.xhtml @@ -57,6 +57,7 @@ Action + diff --git a/web/header.xhtml b/web/header.xhtml index 5d5f506e..54b0d6be 100644 --- a/web/header.xhtml +++ b/web/header.xhtml @@ -11,9 +11,11 @@

    From 21f3c999fa254058e6e876a608394d3ee9ead4bc Mon Sep 17 00:00:00 2001 From: Mario Tressa Juzar Date: Mon, 1 Dec 2014 16:44:36 +0700 Subject: [PATCH 41/58] tambah add post tambah add post --- nbproject/build-impl.xml | 53 ++++++++--- nbproject/faces-config.NavData | 6 +- nbproject/genfiles.properties | 4 +- nbproject/private/private.xml | 8 ++ nbproject/project.properties | 2 +- src/java/paket/addPost.java | 160 ++++++++++++--------------------- src/java/paket/editPost.java | 21 +++++ web/WEB-INF/faces-config.xml | 5 ++ web/edit_post.xhtml | 57 ++++++++++++ web/header-script.xhtml | 1 + web/new_post.xhtml | 40 +++++---- 11 files changed, 220 insertions(+), 137 deletions(-) create mode 100644 src/java/paket/editPost.java create mode 100644 web/edit_post.xhtml diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index ea522f50..b3b847c9 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -105,12 +105,24 @@ + + + + + + + + + + + + @@ -458,7 +470,7 @@ or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties f - + @@ -959,28 +971,28 @@ exists or setup the property manually. For example like this: - + - + - + - + @@ -999,7 +1011,7 @@ exists or setup the property manually. For example like this: - + @@ -1048,18 +1060,32 @@ exists or setup the property manually. For example like this: - + + + + + + + + + - + + + + - + + + + @@ -1127,6 +1153,7 @@ exists or setup the property manually. For example like this: + @@ -1143,9 +1170,12 @@ exists or setup the property manually. For example like this: - + + + + @@ -1240,6 +1270,7 @@ exists or setup the property manually. For example like this: + @@ -1330,7 +1361,7 @@ exists or setup the property manually. For example like this: - + Some tests failed; see details above. diff --git a/nbproject/faces-config.NavData b/nbproject/faces-config.NavData index 72325963..a689e72f 100644 --- a/nbproject/faces-config.NavData +++ b/nbproject/faces-config.NavData @@ -2,12 +2,12 @@ - + - - + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 43f8149f..fbc88875 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=651128d4@1.43.0.1 # 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=12eac0a2 -nbproject/build-impl.xml.script.CRC32=96a0ba67 -nbproject/build-impl.xml.stylesheet.CRC32=5459df51@1.43.0.1 +nbproject/build-impl.xml.script.CRC32=9106d273 +nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.67.1.1 diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index 47509625..d0bf1e8f 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -1,4 +1,12 @@ + + + file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/src/java/paket/CookieCheck.java + file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/web/new_post.xhtml + file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/src/java/paket/addPost.java + file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/src/java/paket/ManUser.java + + diff --git a/nbproject/project.properties b/nbproject/project.properties index e20869e7..9d4afbe7 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -32,7 +32,7 @@ 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.middleware}/mq/lib/jaxm-api.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar +j2ee.platform.classpath=${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar diff --git a/src/java/paket/addPost.java b/src/java/paket/addPost.java index 1fdf2fa8..cd5a9849 100644 --- a/src/java/paket/addPost.java +++ b/src/java/paket/addPost.java @@ -7,136 +7,94 @@ package paket; import java.io.IOException; -import java.io.PrintWriter; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; -import java.util.logging.Level; -import java.util.logging.Logger; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; +import javax.faces.context.FacesContext; /** * * @author Mario */ -@ManagedBean(name = "addPost", eager=true) +@ManagedBean @RequestScoped -public class addPost extends HttpServlet { +public class addPost { + + private String tanggal, konten, judul; + private String username; + + public String getTanggal() { + return tanggal; + } - String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; - String uName = "root"; - String pass = ""; - String username, judul, tanggal, konten, tgl, bln, thn; + public void setTanggal(String tanggal) { + this.tanggal = tanggal; + } - /** - * Processes requests for both HTTP GET and POST - * methods. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - public void processRequest(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException, SQLException { + public void ambilTanggal(){ + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date date = new Date(); + this.tanggal = dateFormat.format(date); + } + + public String getKonten() { + return konten; + } + + public void setKonten(String konten) { + this.konten = konten; + } + + public String getJudul() { + return judul; + } + + public void setJudul(String judul) { + this.judul = judul; + } + + public String addPost() throws IOException{ + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; - PrintWriter out = response.getWriter(); Connection conn = null; Statement stmnt = null; - HttpSession session = request.getSession(); - username = session.getValue("user").toString(); + CookieCheck cookie = new CookieCheck(); + username = cookie.getUsrName(); + + System.out.print(username); + System.out.print("username sebelah sini <<"); + System.out.print(tanggal); + System.out.print(judul); + System.out.print(konten); try { try { Class.forName("com.mysql.jdbc.Driver"); - } catch (Exception e) { - out.println("Unable to load Driver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); } conn = DriverManager.getConnection(dbURL, uName, pass); stmnt = conn.createStatement(); - judul = request.getParameter("judul"); - konten = request.getParameter("konten"); - tanggal = request.getParameter("tangal"); + String sqlStr = "INSERT INTO `post`(`judul`,`konten`,`tanggal_post`,`usrname`) VALUE('" +judul +"', '" +konten +"', '" +tanggal +"', '" +username +"')"; + stmnt.executeUpdate(sqlStr); - String sqlstr = "INSERT INTO `post`(`judul`, `konten`, `usrname`) VALUES('" + judul + "', '" + konten + "', '" + username + "') "; - stmnt.executeQuery(sqlstr); - response.sendRedirect("index.html"); + FacesContext.getCurrentInstance().getExternalContext().redirect("index.xhtml"); - } catch (SQLException ex) { - out.println("Unable to connect to database"); - out.print(ex.toString()); + } catch (SQLException e){ - - }finally { - out.close(); - try { - // Step 5: Close the Statement and Connection - if (stmnt != null) { - stmnt.close(); - } - if (conn != null) { - conn.close(); - } - } catch (SQLException ex) { - } - } - - } - - // - /** - * Handles the HTTP GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - try { - processRequest(request, response); - } catch (SQLException ex) { - Logger.getLogger(addPost.class.getName()).log(Level.SEVERE, null, ex); } + return null; } - - /** - * Handles the HTTP POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - try { - processRequest(request, response); - } catch (SQLException ex) { - Logger.getLogger(addPost.class.getName()).log(Level.SEVERE, null, ex); - } - } - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo() { - return "Short description"; - }// - + } diff --git a/src/java/paket/editPost.java b/src/java/paket/editPost.java new file mode 100644 index 00000000..c8869435 --- /dev/null +++ b/src/java/paket/editPost.java @@ -0,0 +1,21 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package paket; + +/** + * + * @author Mario + */ +public class editPost { + + /** + * Creates a new instance of editPost + */ + public editPost() { + } + +} diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index 748cd61a..a06f581e 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -23,4 +23,9 @@ paket.CookieCheck request + + editPost + paket.editPost + request + diff --git a/web/edit_post.xhtml b/web/edit_post.xhtml new file mode 100644 index 00000000..7f887a01 --- /dev/null +++ b/web/edit_post.xhtml @@ -0,0 +1,57 @@ + + + + + + Simple Blog | Tambah Post + + +
    + + +
    + + +

    -

    + +
    +
    +

    Tambah Post

    + +
    + + + Judul : + + + + + Tanggal : + + + + + Konten : + + + + + +
    +
    +
    + +
    + + +
    + +
    + + \ No newline at end of file diff --git a/web/header-script.xhtml b/web/header-script.xhtml index 5ec4d513..b97d707c 100644 --- a/web/header-script.xhtml +++ b/web/header-script.xhtml @@ -29,6 +29,7 @@ + + + + + + + + + + \ No newline at end of file From 01d98b94f5ef3cd435ccdf41b14be7b1c2fc0bd9 Mon Sep 17 00:00:00 2001 From: Mario Tressa Juzar Date: Mon, 1 Dec 2014 20:00:14 +0700 Subject: [PATCH 44/58] fix edit post fix edit post --- src/java/paket/editPost.java | 39 ++++++++++++++++++++++++++++++++++++ web/edit_post.xhtml | 7 ++++--- web/index.xhtml | 2 +- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/java/paket/editPost.java b/src/java/paket/editPost.java index 45f74340..c7e0a6b5 100644 --- a/src/java/paket/editPost.java +++ b/src/java/paket/editPost.java @@ -6,6 +6,7 @@ package paket; +import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; @@ -29,6 +30,14 @@ public class editPost { private String tanggal, konten, judul; private String username, idpost; + public String getIdpost() { + return idpost; + } + + public void setIdpost(String idpost) { + this.idpost = idpost; + } + public String getTanggal() { return tanggal; } @@ -107,4 +116,34 @@ public void getPost(){ } } + public void saveEditPost() throws IOException { + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + + Connection conn = null; + Statement stmnt = null; + + System.out.print(idpost); + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "UPDATE post SET judul='" +judul +"', konten='" +konten +"', tanggal_post='" +tanggal +"' WHERE id_post=" +idpost; + stmnt.executeUpdate(sqlStr); + + FacesContext.getCurrentInstance().getExternalContext().redirect("index.xhtml"); + + } catch (SQLException e){ + + } + } + } diff --git a/web/edit_post.xhtml b/web/edit_post.xhtml index 413b32e8..4606e8aa 100644 --- a/web/edit_post.xhtml +++ b/web/edit_post.xhtml @@ -9,7 +9,7 @@ > - Simple Blog | Tambah Post + Simple Blog | Edit Post
    @@ -22,7 +22,7 @@
    -

    Tambah Post

    +

    Edit Post

    @@ -40,8 +40,9 @@ Konten : + - +
    diff --git a/web/index.xhtml b/web/index.xhtml index 4b515bf2..67e6258e 100644 --- a/web/index.xhtml +++ b/web/index.xhtml @@ -25,7 +25,7 @@

    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis repudiandae quae natus quos alias eos repellendus a obcaecati cupiditate similique quibusdam, atque omnis illum, minus ex dolorem facilis tempora deserunt! …

    - Edit | Hapus + Edit | Hapus

    From 144b7f0ff8ee5e87c772efc40a635ea995baef2e Mon Sep 17 00:00:00 2001 From: Mario Tressa Juzar Date: Mon, 1 Dec 2014 20:14:15 +0700 Subject: [PATCH 45/58] edit gitignore edit gitignore --- .gitignore | 5 ++++- nbproject/private/private.xml | 10 ++++++++++ nbproject/project.properties | 2 +- src/java/paket/addPost.java | 6 ++++++ src/java/paket/editPost.java | 9 +++++++++ web/edit_post.xhtml | 6 +++--- web/index.xhtml | 4 ++++ 7 files changed, 37 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 95832e8e..fac654b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ /build/ -/dist/ \ No newline at end of file +/dist/ +/nbproject/project.properties +/nbproject/private +/build.xml \ No newline at end of file diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index 47509625..86a6eaa1 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -1,4 +1,14 @@ + + + file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/web/header.xhtml + file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/web/index.xhtml + file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/src/java/paket/editPost.java + file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/src/java/paket/Comment.java + file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/src/java/paket/CookieCheck.java + file:/D:/Project/GitHub/IF3110-02-Simple-Blog-Java/web/edit_post.xhtml + + diff --git a/nbproject/project.properties b/nbproject/project.properties index e20869e7..9d4afbe7 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -32,7 +32,7 @@ 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.middleware}/mq/lib/jaxm-api.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar +j2ee.platform.classpath=${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar diff --git a/src/java/paket/addPost.java b/src/java/paket/addPost.java index 330b8cfa..cd5a9849 100644 --- a/src/java/paket/addPost.java +++ b/src/java/paket/addPost.java @@ -70,6 +70,12 @@ public String addPost() throws IOException{ CookieCheck cookie = new CookieCheck(); username = cookie.getUsrName(); + System.out.print(username); + System.out.print("username sebelah sini <<"); + System.out.print(tanggal); + System.out.print(judul); + System.out.print(konten); + try { try { Class.forName("com.mysql.jdbc.Driver"); diff --git a/src/java/paket/editPost.java b/src/java/paket/editPost.java index c7e0a6b5..5c16a3f8 100644 --- a/src/java/paket/editPost.java +++ b/src/java/paket/editPost.java @@ -6,6 +6,7 @@ package paket; +<<<<<<< HEAD import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; @@ -21,12 +22,15 @@ import javax.faces.context.FacesContext; import javax.servlet.http.HttpServletRequest; +======= +>>>>>>> parent of 4c157a1... tambah edit post /** * * @author Mario */ public class editPost { +<<<<<<< HEAD private String tanggal, konten, judul; private String username, idpost; @@ -62,12 +66,15 @@ public void setJudul(String judul) { this.judul = judul; } +======= +>>>>>>> parent of 4c157a1... tambah edit post /** * Creates a new instance of editPost */ public editPost() { } +<<<<<<< HEAD public void ambilTanggal(){ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); @@ -146,4 +153,6 @@ public void saveEditPost() throws IOException { } } +======= +>>>>>>> parent of 4c157a1... tambah edit post } diff --git a/web/edit_post.xhtml b/web/edit_post.xhtml index 4606e8aa..1fd39569 100644 --- a/web/edit_post.xhtml +++ b/web/edit_post.xhtml @@ -11,7 +11,7 @@ Simple Blog | Edit Post - +
    @@ -29,12 +29,12 @@ Judul : - + Tanggal : - + Konten : diff --git a/web/index.xhtml b/web/index.xhtml index 67e6258e..7d515940 100644 --- a/web/index.xhtml +++ b/web/index.xhtml @@ -25,7 +25,11 @@

    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis repudiandae quae natus quos alias eos repellendus a obcaecati cupiditate similique quibusdam, atque omnis illum, minus ex dolorem facilis tempora deserunt! …

    +<<<<<<< HEAD Edit | Hapus +======= + Edit | Hapus +>>>>>>> parent of 4c157a1... tambah edit post

    From 7a4658f15ecdb346ea14cfa5564bdc865fc43ebf Mon Sep 17 00:00:00 2001 From: Mario Tressa Juzar Date: Mon, 1 Dec 2014 20:18:00 +0700 Subject: [PATCH 46/58] ini ini --- nbproject/private/private.properties | 12 ++++++------ src/java/paket/editPost.java | 9 --------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties index 36e9206a..cfd3be5a 100644 --- a/nbproject/private/private.properties +++ b/nbproject/private/private.properties @@ -1,7 +1,7 @@ -deploy.ant.properties.file=C:\\Users\\TOSHIBA\\AppData\\Roaming\\NetBeans\\7.3\\config\\GlassFishEE6\\Properties\\gfv31712819959.properties +deploy.ant.properties.file=C:\\Users\\Mario\\AppData\\Roaming\\NetBeans\\8.0\\config\\GlassFishEE6\\Properties\\gfv3614672000.properties j2ee.platform.is.jsr109=true -j2ee.server.domain=C:/Users/TOSHIBA/GlassFish_Server/glassfish/domains/domain1 -j2ee.server.home=C:/Users/TOSHIBA/GlassFish_Server/glassfish -j2ee.server.instance=[C:\\Users\\TOSHIBA\\GlassFish_Server\\glassfish;C:\\Users\\TOSHIBA\\GlassFish_Server\\glassfish\\domains\\domain1]deployer:gfv3ee6wc:localhost:4848 -j2ee.server.middleware=C:/Users/TOSHIBA/GlassFish_Server -user.properties.file=C:\\Users\\TOSHIBA\\AppData\\Roaming\\NetBeans\\7.3\\build.properties +j2ee.server.domain=C:/Program Files/glassfish-4.0/glassfish/domains/domain1 +j2ee.server.home=C:/Program Files/glassfish-4.0/glassfish +j2ee.server.instance=[C:\\Program Files\\glassfish-4.0\\glassfish;C:\\Program Files\\glassfish-4.0\\glassfish\\domains\\domain1]deployer:gfv3ee6:localhost:4848 +j2ee.server.middleware=C:/Program Files/glassfish-4.0 +user.properties.file=C:\\Users\\Mario\\AppData\\Roaming\\NetBeans\\8.0\\build.properties diff --git a/src/java/paket/editPost.java b/src/java/paket/editPost.java index 5c16a3f8..c7e0a6b5 100644 --- a/src/java/paket/editPost.java +++ b/src/java/paket/editPost.java @@ -6,7 +6,6 @@ package paket; -<<<<<<< HEAD import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; @@ -22,15 +21,12 @@ import javax.faces.context.FacesContext; import javax.servlet.http.HttpServletRequest; -======= ->>>>>>> parent of 4c157a1... tambah edit post /** * * @author Mario */ public class editPost { -<<<<<<< HEAD private String tanggal, konten, judul; private String username, idpost; @@ -66,15 +62,12 @@ public void setJudul(String judul) { this.judul = judul; } -======= ->>>>>>> parent of 4c157a1... tambah edit post /** * Creates a new instance of editPost */ public editPost() { } -<<<<<<< HEAD public void ambilTanggal(){ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); @@ -153,6 +146,4 @@ public void saveEditPost() throws IOException { } } -======= ->>>>>>> parent of 4c157a1... tambah edit post } From 136bb4f392b0fff6c8ca945d6459c3db415b17eb Mon Sep 17 00:00:00 2001 From: Mario Tressa Juzar Date: Mon, 1 Dec 2014 20:31:11 +0700 Subject: [PATCH 47/58] conflix conflix --- nbproject/private/private.properties | 12 ++++++------ web/edit_post.xhtml | 1 + web/index.xhtml | 4 ---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties index cfd3be5a..36e9206a 100644 --- a/nbproject/private/private.properties +++ b/nbproject/private/private.properties @@ -1,7 +1,7 @@ -deploy.ant.properties.file=C:\\Users\\Mario\\AppData\\Roaming\\NetBeans\\8.0\\config\\GlassFishEE6\\Properties\\gfv3614672000.properties +deploy.ant.properties.file=C:\\Users\\TOSHIBA\\AppData\\Roaming\\NetBeans\\7.3\\config\\GlassFishEE6\\Properties\\gfv31712819959.properties j2ee.platform.is.jsr109=true -j2ee.server.domain=C:/Program Files/glassfish-4.0/glassfish/domains/domain1 -j2ee.server.home=C:/Program Files/glassfish-4.0/glassfish -j2ee.server.instance=[C:\\Program Files\\glassfish-4.0\\glassfish;C:\\Program Files\\glassfish-4.0\\glassfish\\domains\\domain1]deployer:gfv3ee6:localhost:4848 -j2ee.server.middleware=C:/Program Files/glassfish-4.0 -user.properties.file=C:\\Users\\Mario\\AppData\\Roaming\\NetBeans\\8.0\\build.properties +j2ee.server.domain=C:/Users/TOSHIBA/GlassFish_Server/glassfish/domains/domain1 +j2ee.server.home=C:/Users/TOSHIBA/GlassFish_Server/glassfish +j2ee.server.instance=[C:\\Users\\TOSHIBA\\GlassFish_Server\\glassfish;C:\\Users\\TOSHIBA\\GlassFish_Server\\glassfish\\domains\\domain1]deployer:gfv3ee6wc:localhost:4848 +j2ee.server.middleware=C:/Users/TOSHIBA/GlassFish_Server +user.properties.file=C:\\Users\\TOSHIBA\\AppData\\Roaming\\NetBeans\\7.3\\build.properties diff --git a/web/edit_post.xhtml b/web/edit_post.xhtml index 1fd39569..4ba52c0c 100644 --- a/web/edit_post.xhtml +++ b/web/edit_post.xhtml @@ -41,6 +41,7 @@ + diff --git a/web/index.xhtml b/web/index.xhtml index 7d515940..67e6258e 100644 --- a/web/index.xhtml +++ b/web/index.xhtml @@ -25,11 +25,7 @@

    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis repudiandae quae natus quos alias eos repellendus a obcaecati cupiditate similique quibusdam, atque omnis illum, minus ex dolorem facilis tempora deserunt! …

    -<<<<<<< HEAD Edit | Hapus -======= - Edit | Hapus ->>>>>>> parent of 4c157a1... tambah edit post

    From ed4b993b44bc717ff5129d66ce6cd27cb4696fa5 Mon Sep 17 00:00:00 2001 From: Mario Tressa Juzar Date: Mon, 1 Dec 2014 20:53:04 +0700 Subject: [PATCH 48/58] fix conflict fix conflict --- .gitignore | 3 ++- src/java/paket/editPost.java | 2 ++ web/edit_post.xhtml | 7 +++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index fac654b0..dcdf4906 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /dist/ /nbproject/project.properties /nbproject/private -/build.xml \ No newline at end of file +/build.xml +/nbproject/private/private.properties \ No newline at end of file diff --git a/src/java/paket/editPost.java b/src/java/paket/editPost.java index c7e0a6b5..42a6fe9d 100644 --- a/src/java/paket/editPost.java +++ b/src/java/paket/editPost.java @@ -91,6 +91,8 @@ public void getPost(){ if ( matcher.find() ) idpost = matcher.group( 1 ); + System.out.print(idpost); + try { try { Class.forName("com.mysql.jdbc.Driver"); diff --git a/web/edit_post.xhtml b/web/edit_post.xhtml index 4ba52c0c..4606e8aa 100644 --- a/web/edit_post.xhtml +++ b/web/edit_post.xhtml @@ -11,7 +11,7 @@ Simple Blog | Edit Post - +
    @@ -29,19 +29,18 @@ Judul : - + Tanggal : - + Konten : - From 1577ddd36255a146b96ff43834ddbd6b1e00355f Mon Sep 17 00:00:00 2001 From: runbow Date: Mon, 1 Dec 2014 21:52:42 +0700 Subject: [PATCH 49/58] add editUser method --- src/java/paket/ManUser.java | 12 ++- src/java/paket/editUser.java | 146 +++++++++++++++++++++++++++++++++++ web/ManageUser.xhtml | 2 +- web/WEB-INF/faces-config.xml | 5 ++ web/editUser.xhtml | 43 ++++++++--- 5 files changed, 194 insertions(+), 14 deletions(-) create mode 100644 src/java/paket/editUser.java diff --git a/src/java/paket/ManUser.java b/src/java/paket/ManUser.java index a5e81579..09492386 100644 --- a/src/java/paket/ManUser.java +++ b/src/java/paket/ManUser.java @@ -4,6 +4,7 @@ */ package paket; +import java.io.IOException; import java.io.Serializable; import java.sql.Connection; import java.sql.DriverManager; @@ -12,6 +13,10 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.Arrays; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.faces.context.FacesContext; /** * @@ -261,7 +266,12 @@ public String delAction(User user) { return null; } - + public String editAction(User user) throws IOException { + + FacesContext.getCurrentInstance().getExternalContext().redirect("editUser.xhtml?param="+user.usrname); + + return null; + } } diff --git a/src/java/paket/editUser.java b/src/java/paket/editUser.java new file mode 100644 index 00000000..bfdc0182 --- /dev/null +++ b/src/java/paket/editUser.java @@ -0,0 +1,146 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package paket; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.faces.context.FacesContext; + +/** + * + * @author TOSHIBA + */ +public class editUser { + + private String usrname, passwrd, nama_usr, email_usr, role; + + public String getUsrname() { + return usrname; + } + + public void setUsrname(String usrname) { + this.usrname = usrname; + } + + public String getPasswrd() { + return passwrd; + } + + public void setPasswrd(String passwrd) { + this.passwrd = passwrd; + } + + public String getNama_usr() { + return nama_usr; + } + + public void setNama_usr(String nama_usr) { + this.nama_usr = nama_usr; + } + + public String getEmail_usr() { + return email_usr; + } + + public void setEmail_usr(String email_usr) { + this.email_usr = email_usr; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + /** + * Creates a new instance of editUser + */ + public editUser() { + } + + public void ambilUser(){ + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + + Connection conn = null; + Statement stmnt = null; + + FacesContext context = FacesContext.getCurrentInstance(); + Map requestMap = context.getExternalContext().getRequestParameterMap(); + String peta = requestMap.toString(); + + Pattern pattern = Pattern.compile( "param=(\\w+)" ); + Matcher matcher = pattern.matcher( peta ); + if ( matcher.find() ) + usrname = matcher.group( 1 ); + + System.out.print(usrname); + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "SELECT * FROM `usr` WHERE usrname='" +usrname +"'"; + ResultSet rSet = stmnt.executeQuery(sqlStr); + + if (rSet.next()){ + usrname = rSet.getString("usrname"); + passwrd = rSet.getString("passwrd"); + nama_usr = rSet.getString("nama_usr"); + email_usr = rSet.getString("email_usr"); + role = rSet.getString("role"); + } + + } catch (SQLException e){ + + } + } + + public void updateUser() throws IOException { + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + + Connection conn = null; + Statement stmnt = null; + +// System.out.print(idpost); + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "UPDATE usr SET passwrd='" +passwrd +"', nama_usr='" +nama_usr +"','"+email_usr+"','"+role+"' WHERE usrname=" +usrname; + stmnt.executeUpdate(sqlStr); + + FacesContext.getCurrentInstance().getExternalContext().redirect("ManageUser.xhtml"); + + } catch (SQLException e){ + + } + } +} diff --git a/web/ManageUser.xhtml b/web/ManageUser.xhtml index 7470c344..4d067e19 100644 --- a/web/ManageUser.xhtml +++ b/web/ManageUser.xhtml @@ -57,7 +57,7 @@ Action - + diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index a06f581e..4f5c07bc 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -28,4 +28,9 @@ paket.editPost request + + editUser + paket.editUser + request + diff --git a/web/editUser.xhtml b/web/editUser.xhtml index 643a7f84..85ab019c 100644 --- a/web/editUser.xhtml +++ b/web/editUser.xhtml @@ -10,44 +10,63 @@ Simple Blog | Manage User - +

    Manage User

    - - + + +
    - + - + - + - + -
    Username :
    Password :
    Nama :
    Email :
    Role : +
    - - - -
    + + +
    From 2db21ce400edc698067b8d5a1f262663207263be Mon Sep 17 00:00:00 2001 From: Mario Tressa Juzar Date: Mon, 1 Dec 2014 22:05:48 +0700 Subject: [PATCH 50/58] tambah view post, unpublished, soft delete tambah view post, unpublished, soft delete --- src/java/paket/Comment.java | 110 ----------------------------------- src/java/paket/ViewPost.java | 107 ++++++++++++++++++++++++++++++++++ web/ListPost.xhtml | 46 --------------- web/ViewPost.xhtml | 72 ----------------------- web/WEB-INF/faces-config.xml | 5 ++ web/header.xhtml | 4 +- web/index.xhtml | 2 +- web/post.xhtml | 75 ++++++++++++++++++++++++ web/softdelete.xhtml | 39 +++++++++++++ web/unpublished.xhtml | 39 +++++++++++++ 10 files changed, 268 insertions(+), 231 deletions(-) delete mode 100644 src/java/paket/Comment.java create mode 100644 src/java/paket/ViewPost.java delete mode 100644 web/ListPost.xhtml delete mode 100644 web/ViewPost.xhtml create mode 100644 web/post.xhtml create mode 100644 web/softdelete.xhtml create mode 100644 web/unpublished.xhtml diff --git a/src/java/paket/Comment.java b/src/java/paket/Comment.java deleted file mode 100644 index 56dc8888..00000000 --- a/src/java/paket/Comment.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package entity; - -import java.sql.Date; -import javax.faces.bean.ManagedBean; -import javax.faces.bean.RequestScoped; - -/** - * - * @author User - */ -@ManagedBean (name="comment", eager=true) -@RequestScoped -public class Comment { - private int id_kom; - private String nama; - private Date tanggal_kom; - private String email; - private String isi; - private int id_post; - - /** - * @return the id_kom - */ - public int getId_kom() { - return id_kom; - } - - /** - * @param id_kom the id_kom to set - */ - public void setId_kom(int id_kom) { - this.id_kom = id_kom; - } - - /** - * @return the nama - */ - public String getNama() { - return nama; - } - - /** - * @param nama the nama to set - */ - public void setNama(String nama) { - this.nama = nama; - } - - /** - * @return the tanggal_kom - */ - public Date getTanggal_kom() { - return tanggal_kom; - } - - /** - * @param tanggal_kom the tanggal_kom to set - */ - public void setTanggal_kom(Date tanggal_kom) { - this.tanggal_kom = tanggal_kom; - } - - /** - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * @param email the email to set - */ - public void setEmail(String email) { - this.email = email; - } - - /** - * @return the isi - */ - public String getIsi() { - return isi; - } - - /** - * @param isi the isi to set - */ - public void setIsi(String isi) { - this.isi = isi; - } - - /** - * @return the id_post - */ - public int getId_post() { - return id_post; - } - - /** - * @param id_post the id_post to set - */ - public void setId_post(int id_post) { - this.id_post = id_post; - } - -} diff --git a/src/java/paket/ViewPost.java b/src/java/paket/ViewPost.java new file mode 100644 index 00000000..490b3c12 --- /dev/null +++ b/src/java/paket/ViewPost.java @@ -0,0 +1,107 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package paket; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.faces.context.FacesContext; + +/** + * + * @author Mario + */ +public class ViewPost { + + private String idpost, judul, konten, tanggal; + + public String getIdpost() { + return idpost; + } + + public void setIdpost(String idpost) { + this.idpost = idpost; + } + + public String getJudul() { + return judul; + } + + public void setJudul(String judul) { + this.judul = judul; + } + + public String getKonten() { + return konten; + } + + public void setKonten(String konten) { + this.konten = konten; + } + + public String getTanggal() { + return tanggal; + } + + public void setTanggal(String tanggal) { + this.tanggal = tanggal; + } + /** + * Creates a new instance of ViewPost + */ + public ViewPost() { + } + + public void getPost(){ + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + + Connection conn = null; + Statement stmnt = null; + + FacesContext context = FacesContext.getCurrentInstance(); + Map requestMap = context.getExternalContext().getRequestParameterMap(); + String peta = requestMap.toString(); + + Pattern pattern = Pattern.compile( "id=(\\d+)" ); + Matcher matcher = pattern.matcher( peta ); + if ( matcher.find() ) + idpost = matcher.group( 1 ); + + System.out.print(idpost); + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "SELECT * FROM `post` WHERE id_post='" +idpost +"'"; + ResultSet rs = stmnt.executeQuery(sqlStr); + + if (rs.next()){ + tanggal = rs.getString("tanggal_post"); + judul = rs.getString("judul"); + konten = rs.getString("konten"); + } + + } catch (SQLException e){ + + } + } + +} diff --git a/web/ListPost.xhtml b/web/ListPost.xhtml deleted file mode 100644 index 7f21658f..00000000 --- a/web/ListPost.xhtml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - Simple Blog - - -
    - - -
    -
    - -
    -
    - - -
    - - - -
    - - diff --git a/web/ViewPost.xhtml b/web/ViewPost.xhtml deleted file mode 100644 index 4b7efbe3..00000000 --- a/web/ViewPost.xhtml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - Simple Blog | View Post - - -
    - - -
    - -
    -
    - -

    #{post.judul}

    -

    -
    -
    -
    -
    -
    - #{post.konten} -
    -

    Komentar

    -
    - - - - - - - -
    - - - - - - - - - - -
    -
    - - -
    - - - diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index a06f581e..b1dde8c8 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -28,4 +28,9 @@ paket.editPost request + + viewPost + paket.ViewPost + request + diff --git a/web/header.xhtml b/web/header.xhtml index 54b0d6be..9da60856 100644 --- a/web/header.xhtml +++ b/web/header.xhtml @@ -12,10 +12,10 @@ diff --git a/web/index.xhtml b/web/index.xhtml index 67e6258e..8bd9b223 100644 --- a/web/index.xhtml +++ b/web/index.xhtml @@ -19,7 +19,7 @@
    • -

      Apa itu Simple Blog?

      +

      Apa itu Simple Blog?

      15 Juli 2014
      Featured
      diff --git a/web/post.xhtml b/web/post.xhtml new file mode 100644 index 00000000..e10cd846 --- /dev/null +++ b/web/post.xhtml @@ -0,0 +1,75 @@ + + + + + + Simple Blog | <h:outputText value="#{viewPost.judul}"></h:outputText> + + +
      + + +
      +
      +
      + +

      #{viewPost.judul}

      +

      +
      +
      +
      +
      +
      + #{viewPost.konten} +
      + +

      Komentar

      + +
      + + Nama: + + + Email: + + + Komentar:
      + + + +
      +
      + +
        +
      • +
        +

        Jems

        +
        2 menit lalu
        +
        +

        Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis repudiandae quae natus quos alias eos repellendus a obcaecati cupiditate similique quibusdam, atque omnis illum, minus ex dolorem facilis tempora deserunt! …

        +
      • + +
      • +
        +

        Kave

        +
        1 jam lalu
        +
        +

        Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis repudiandae quae natus quos alias eos repellendus a obcaecati cupiditate similique quibusdam, atque omnis illum, minus ex dolorem facilis tempora deserunt! …

        +
      • +
      +
      +
      +
      + + +
      + +
      + + \ No newline at end of file diff --git a/web/softdelete.xhtml b/web/softdelete.xhtml new file mode 100644 index 00000000..735c564a --- /dev/null +++ b/web/softdelete.xhtml @@ -0,0 +1,39 @@ + + + + + + Simple Blog | Soft Delete + + +
      + + +
      +
      + +
      +
      + + +
      + +
      + + \ No newline at end of file diff --git a/web/unpublished.xhtml b/web/unpublished.xhtml new file mode 100644 index 00000000..f048cb47 --- /dev/null +++ b/web/unpublished.xhtml @@ -0,0 +1,39 @@ + + + + + + Simple Blog | Unpublished Post + + +
      + + +
      +
      + +
      +
      + + +
      + +
      + + \ No newline at end of file From 660e6fe6c06e381740207b777b29049eaaf0cf3a Mon Sep 17 00:00:00 2001 From: Mario Tressa Juzar Date: Mon, 1 Dec 2014 22:13:06 +0700 Subject: [PATCH 51/58] tambah page --- nbproject/private/private.properties | 12 +-- src/java/paket/ManUser.java | 12 ++- src/java/paket/editUser.java | 146 +++++++++++++++++++++++++++ web/ManageUser.xhtml | 2 +- web/WEB-INF/faces-config.xml | 5 + web/editUser.xhtml | 43 +++++--- 6 files changed, 200 insertions(+), 20 deletions(-) create mode 100644 src/java/paket/editUser.java diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties index 36e9206a..cfd3be5a 100644 --- a/nbproject/private/private.properties +++ b/nbproject/private/private.properties @@ -1,7 +1,7 @@ -deploy.ant.properties.file=C:\\Users\\TOSHIBA\\AppData\\Roaming\\NetBeans\\7.3\\config\\GlassFishEE6\\Properties\\gfv31712819959.properties +deploy.ant.properties.file=C:\\Users\\Mario\\AppData\\Roaming\\NetBeans\\8.0\\config\\GlassFishEE6\\Properties\\gfv3614672000.properties j2ee.platform.is.jsr109=true -j2ee.server.domain=C:/Users/TOSHIBA/GlassFish_Server/glassfish/domains/domain1 -j2ee.server.home=C:/Users/TOSHIBA/GlassFish_Server/glassfish -j2ee.server.instance=[C:\\Users\\TOSHIBA\\GlassFish_Server\\glassfish;C:\\Users\\TOSHIBA\\GlassFish_Server\\glassfish\\domains\\domain1]deployer:gfv3ee6wc:localhost:4848 -j2ee.server.middleware=C:/Users/TOSHIBA/GlassFish_Server -user.properties.file=C:\\Users\\TOSHIBA\\AppData\\Roaming\\NetBeans\\7.3\\build.properties +j2ee.server.domain=C:/Program Files/glassfish-4.0/glassfish/domains/domain1 +j2ee.server.home=C:/Program Files/glassfish-4.0/glassfish +j2ee.server.instance=[C:\\Program Files\\glassfish-4.0\\glassfish;C:\\Program Files\\glassfish-4.0\\glassfish\\domains\\domain1]deployer:gfv3ee6:localhost:4848 +j2ee.server.middleware=C:/Program Files/glassfish-4.0 +user.properties.file=C:\\Users\\Mario\\AppData\\Roaming\\NetBeans\\8.0\\build.properties diff --git a/src/java/paket/ManUser.java b/src/java/paket/ManUser.java index a5e81579..09492386 100644 --- a/src/java/paket/ManUser.java +++ b/src/java/paket/ManUser.java @@ -4,6 +4,7 @@ */ package paket; +import java.io.IOException; import java.io.Serializable; import java.sql.Connection; import java.sql.DriverManager; @@ -12,6 +13,10 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.Arrays; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.faces.context.FacesContext; /** * @@ -261,7 +266,12 @@ public String delAction(User user) { return null; } - + public String editAction(User user) throws IOException { + + FacesContext.getCurrentInstance().getExternalContext().redirect("editUser.xhtml?param="+user.usrname); + + return null; + } } diff --git a/src/java/paket/editUser.java b/src/java/paket/editUser.java new file mode 100644 index 00000000..bfdc0182 --- /dev/null +++ b/src/java/paket/editUser.java @@ -0,0 +1,146 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package paket; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.faces.context.FacesContext; + +/** + * + * @author TOSHIBA + */ +public class editUser { + + private String usrname, passwrd, nama_usr, email_usr, role; + + public String getUsrname() { + return usrname; + } + + public void setUsrname(String usrname) { + this.usrname = usrname; + } + + public String getPasswrd() { + return passwrd; + } + + public void setPasswrd(String passwrd) { + this.passwrd = passwrd; + } + + public String getNama_usr() { + return nama_usr; + } + + public void setNama_usr(String nama_usr) { + this.nama_usr = nama_usr; + } + + public String getEmail_usr() { + return email_usr; + } + + public void setEmail_usr(String email_usr) { + this.email_usr = email_usr; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + /** + * Creates a new instance of editUser + */ + public editUser() { + } + + public void ambilUser(){ + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + + Connection conn = null; + Statement stmnt = null; + + FacesContext context = FacesContext.getCurrentInstance(); + Map requestMap = context.getExternalContext().getRequestParameterMap(); + String peta = requestMap.toString(); + + Pattern pattern = Pattern.compile( "param=(\\w+)" ); + Matcher matcher = pattern.matcher( peta ); + if ( matcher.find() ) + usrname = matcher.group( 1 ); + + System.out.print(usrname); + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "SELECT * FROM `usr` WHERE usrname='" +usrname +"'"; + ResultSet rSet = stmnt.executeQuery(sqlStr); + + if (rSet.next()){ + usrname = rSet.getString("usrname"); + passwrd = rSet.getString("passwrd"); + nama_usr = rSet.getString("nama_usr"); + email_usr = rSet.getString("email_usr"); + role = rSet.getString("role"); + } + + } catch (SQLException e){ + + } + } + + public void updateUser() throws IOException { + String dbURL = "jdbc:mysql://localhost:3306/simple_blog"; + String uName = "root"; + String pass = ""; + + Connection conn = null; + Statement stmnt = null; + +// System.out.print(idpost); + + try { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + System.out.println("Unable to load Driver"); + } + conn = DriverManager.getConnection(dbURL, uName, pass); + stmnt = conn.createStatement(); + + String sqlStr = "UPDATE usr SET passwrd='" +passwrd +"', nama_usr='" +nama_usr +"','"+email_usr+"','"+role+"' WHERE usrname=" +usrname; + stmnt.executeUpdate(sqlStr); + + FacesContext.getCurrentInstance().getExternalContext().redirect("ManageUser.xhtml"); + + } catch (SQLException e){ + + } + } +} diff --git a/web/ManageUser.xhtml b/web/ManageUser.xhtml index 7470c344..4d067e19 100644 --- a/web/ManageUser.xhtml +++ b/web/ManageUser.xhtml @@ -57,7 +57,7 @@ Action - + diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index b1dde8c8..dff5d398 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -33,4 +33,9 @@ paket.ViewPost request + + editUser + paket.editUser + request + diff --git a/web/editUser.xhtml b/web/editUser.xhtml index 643a7f84..85ab019c 100644 --- a/web/editUser.xhtml +++ b/web/editUser.xhtml @@ -10,44 +10,63 @@ Simple Blog | Manage User - +

      Manage User

      - - + + +
      - + - + - + - + -
      Username :
      Password :
      Nama :
      Email :
      Role : +
      - - - -
      + + +
      From 88552937442b9350bcef70a864802725128bfe91 Mon Sep 17 00:00:00 2001 From: runbow Date: Mon, 1 Dec 2014 22:56:58 +0700 Subject: [PATCH 52/58] add validation add validation --- web/ManageUser.xhtml | 5 ++++- web/edit_post.xhtml | 5 ++++- web/new_post.xhtml | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/web/ManageUser.xhtml b/web/ManageUser.xhtml index 4d067e19..e28d12bd 100644 --- a/web/ManageUser.xhtml +++ b/web/ManageUser.xhtml @@ -79,7 +79,10 @@
    Email : + + +
    Role :