{"id":2527,"date":"2012-10-25T21:26:07","date_gmt":"2012-10-26T02:26:07","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=2527"},"modified":"2012-10-25T21:26:07","modified_gmt":"2012-10-26T02:26:07","slug":"simple-atg-jsp-and-droplet","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2012\/10\/25\/simple-atg-jsp-and-droplet\/","title":{"rendered":"Simple ATG JSP and droplet"},"content":{"rendered":"<p>This post assumes you have installed the Commerce Reference Store.  It was also written for ATG 10.0.3, although it may work on other versions, as well.<\/p>\n<p>Create the following file, named printAllOrders.java, under $ATG_INSTALL_DIR\/home\/locallib<\/p>\n<pre lang=\"java\" line=\"1\">\r\nimport java.io.*;\r\nimport javax.servlet.*;\r\nimport javax.servlet.http.*;\r\nimport atg.servlet.*;\r\nimport atg.repository.*;\r\n\r\npublic class printAllOrders extends DynamoServlet {\r\n  public printAllOrders() {}\r\n  public void service (DynamoHttpServletRequest request,\r\n                       DynamoHttpServletResponse response) \r\n  throws ServletException, IOException {\r\n    try {\r\n      MutableRepository pRepository = (MutableRepository)ServletUtil.getCurrentRequest().resolveName(\"\/atg\/commerce\/order\/OrderRepository\");\r\n\r\n      RepositoryItemDescriptor orderDesc = pRepository.getItemDescriptor(\"order\");\r\n      RepositoryView orderView = orderDesc.getRepositoryView();\r\n      QueryBuilder orderBuilder = orderView.getQueryBuilder();\r\n      RepositoryItem[] answer = orderView.executeQuery(orderBuilder.createUnconstrainedQuery());\r\n      if (answer == null) {\r\n        request.setParameter (\"order_id\", \"No items were found\");\r\n        request.serviceParameter (\"output\", request, response);\r\n      }\r\n      else {\r\n        for (int i=0; i<answer.length; i++) {\r\n          request.setParameter (\"order_id\", answer[i].getRepositoryId());\r\n          request.serviceParameter (\"output\", request, response);\r\n        }\r\n      }\r\n    }\r\n    catch (Exception ce) {\r\n      ce.printStackTrace();\r\n    }\r\n  }\r\n}\r\n<\/pre>\n<p>Compile it with the following command line invocations:<\/p>\n<pre lang=\"text\">\r\n[atg@expressdb1 company]# cd $ATG_INSTALL_DIR \r\n[atg@expressdb1 ]# export CLASSPATH=.:$(pwd)\/lib\/classes.jar:$(pwd)\/DAS\/lib\/servlet.jar:$(pwd)\/DCS\/lib\/classes.jar:$(pwd)\/DPS\/lib\/classes.jar\r\n[atg@expressdb1 ]# javac \u2013d .\/home\/locallib .\/home\/locallib\/printAllOrders.java\r\n<\/pre>\n<p>Create a properties file for your component by creating a file named printAllOrders.properties under $ATG_INSTALL_DIR\/home\/localconfig\/test.  The file should have the following contents:<\/p>\n<pre lang=\"text\">\r\n$class=printAllOrders\r\n$scope=global\r\n<\/pre>\n<p>Copy the generated printAllOrders.class file from $ATG_INSTALL_DIR\/home\/locallib to $JBOSS_DIR\/server\/your_app_name\/deploy\/your_ear_file.ear\/atglib\/_atghome_slocallib\/<\/p>\n<p>Create a JSP file named $JBOSS_DIR\/your_app_name\/deploy\/your_ear_file.ear\/store.war\/company\/printallorders.jsp with the following contents:<\/p>\n<pre lang=\"java\" line=\"1\">\r\n<dsp:importbean bean=\"\/atg\/dynamo\/droplet\/ForEach\"\/>\r\n<dsp:page>\r\n\r\n<html>\r\n<head><title>Order ID\u2019s<\/title><\/head>\r\n<body>\r\n\r\n<ul>\r\n  <dsp:droplet name=\"\/test\/printAllOrders\">\r\n    <dsp:oparam name=\"output\">\r\n      <dsp:valueof param=\"order_id\"\/><br>\r\n    <\/dsp:oparam>\r\n  <\/dsp:droplet>\r\n<\/ul>\r\n\r\n<\/body><\/html>\r\n\r\n<\/dsp:page>\r\n<\/pre>\n<p>Restart your jboss application server with a command line similar to what is shown below:<\/p>\n<pre lang=\"text\">\r\ncd $JBOSS_DIR\/bin\r\nnohup .\/run.sh -c your_app_name -b 0.0.0.0 &\r\n<\/pre>\n<p>Navigate your browser to the base URL of your installation at the following URL (changing the jsp file name to whatever you named it above, such as printallorders.jsp).<\/p>\n<p>http:\/\/your_host_name:8080\/crs\/company\/printallorders.jsp<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post assumes you have installed the Commerce Reference Store. It was also written for ATG 10.0.3, although it may work on other versions, as well. Create the following file, named printAllOrders.java, under $ATG_INSTALL_DIR\/home\/locallib import java.io.*; import javax.servlet.*; import javax.servlet.http.*;&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2012\/10\/25\/simple-atg-jsp-and-droplet\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[37,38],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/2527"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=2527"}],"version-history":[{"count":10,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/2527\/revisions"}],"predecessor-version":[{"id":2537,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/2527\/revisions\/2537"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2527"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}