我是ATG的新手,我只能用JBoss成功安装ATG v10.2.
但是,由于在ATG中创建组件和模块可以以不同的方式完成,因此我想知道模块和组件是否有任何"Hello World"示例.
我已经在谷歌搜索过了,但互联网上出现的不同文章并未按顺序的方式详细提及.
因此,如果人们可以详细说明新手的步骤,那将会很棒,因为我至少需要开始使用一个示例,我稍后可以将其作为其他复杂示例的基础.
非常感谢每一个人!
注意: -
我在某种程度上也了解J2EE和MVC,我可以提交表单并将用户输入数据保存到DB,没有任何重大问题.
我现在也正在阅读ATG Page Developer Guide.
ATG中有很多概念,这使得Hello World程序难以实现.您的意思是创建一个JSP页面并像商业参考商店一样部署它吗?你想在Dyn/Admin中创建一个组件吗?你想创建一个hello world存储库吗?根据您的想法,采取的方法将有所不同.
要使用ATG,您不必了解在数据库中保存值.如果你使用J2EE和MVC经验进行ATG编程,除非你从一个新思维开始,否则你可能会发现很难应对它,因为ATG中的情况非常不同.
由于@radimpe介绍了如何创建一个hello world Droplet,我将展示如何创建一个简单的组件,以便可以在Dyn/Admin中查看它.
创建一个HelloWorld组件:它只出现在DynAdmin中 创建一个具有以下结构的Eclipse项目.

以下是上述屏幕截图中显示的每个文件的内容
package com.buddha.components;
import atg.nucleus.GenericService;
import atg.nucleus.ServiceException;
public class HelloWorldComponent extends GenericService {
public String firstStr = "Dummy Value"; /* This value will be overwritten */
public String getFirstStr() {
return firstStr;
}
public void setFirstStr(String firstStr) {
this.firstStr = firstStr;
}
@Override
public void doStartService() throws ServiceException {
super.doStartService();
System.out.println("Hello ATG Component!");
}
@Override
public void doStopService() throws ServiceException {
super.doStopService();
System.out.println("Hello ATG Component! Stops now!");
}
}
Run Code Online (Sandbox Code Playgroud)
Manifest-Version: 1.0
ATG-Required: DafEar.Admin
ATG-Config-Path: config/
ATG-Class-Path: ./bin/
Run Code Online (Sandbox Code Playgroud)
$class=com.buddha.components.HelloWorldComponent
firstStr=HelloWorld
Run Code Online (Sandbox Code Playgroud)
构建项目并将项目文件夹复制到$ {DYNAMO_ROOT}并运行以下命令以生成项目的ear文件并将其部署到jboss服务器中.
runAssembler.bat -jboss HelloWorld.ear -m EXP_HelloATGComponentWorld
Run Code Online (Sandbox Code Playgroud)
导航到Dyn/Admin并搜索该组件HelloWorldComponent,然后单击搜索结果中列出的组件.

单击它以转到组件页面以查看我们创建的属性及其在属性文件中给出的值.

你可以像这样观察日志.
21:53:00,485 INFO [stdout] (http-/0.0.0.0:8080-1:ipaddr=127.0.0.1;path=/dyn/admin/nucleus//com/buddha/components/HelloWorldComponent;sessionid=gT4bmHj5WKs1Rf85GN0Z+9Qu) Hello ATG Component!这行由于doStartService()中的sysout而生成; 您还可以提供其他可以通过dyn/admin调用或与其他组件交互的方法.最好的运气.
来源:在Oracle Commerce Platform中创建组件
这是一个相当广泛的主题,一般来说,该Hello World示例只会让您开始在屏幕上呈现一些文本.大多数的前端交互将与发生FormHandlers和Droplets它的Droplet将让你在Hello World屏幕上的文字.那么让我们开始吧.
<%-- JSTL --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%-- DSP --%>
<%-- This tag library represents the ATG tags --%>
<%@ taglib prefix="dsp" uri="http://www.atg.com/taglibs/daf/dspjspTaglib1_0" %>
<%-- All, non-static includes will have a wrapping page tag --%>
<dsp:page>
<%-- A droplet is almost like a servlet, and here you include the name of the droplet you want to call --%>
<dsp:droplet name="/com/acme/droplet/HelloWorldDroplet">
<%-- An 'output parameter' matches the name of the 'service parameter' in your droplet. You can have multiple of these --%>
<dsp:oparam name="output">
<%-- The 'param' matches the name of the 'setParameter' in your droplet and can also be assigned to a jstl variable below --%>
Hello <dsp:valueof param="toWhom" />
</dsp:oparam>
</dsp:droplet>
</dsp:page>
Run Code Online (Sandbox Code Playgroud)
现在创建一个"组件".这是将在JSP页面和CLASS文件之间映射的属性文件(即,您在Droplet名称中引用它)
文件:/com/acme/droplet/HelloWorldDroplet.properties
$class=com.acme.droplet.HelloWorldDroplet
$scope=global
Run Code Online (Sandbox Code Playgroud)
现在创建您的Java文件:(/ com/acme/droplet/HelloWorldDroplet.java)
public class HelloWorldDroplet extends DynamoServlet {
public void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws ServletException, IOException {
//This will allow you to pass a parameter to the droplet eg: hello.jsp?who=Peter
String who = pRequest.getParameter("who");
//Do a check on whether to display the default value or the one passed in
if (StringUtils.isEmpty(who)) {
//'toWhom' is the name of the param on the JSP page
pRequest.setParameter("toWhom", "World");
} else {
pRequest.setParameter("toWhom", who);
}
//'output' is the name of the 'oparam' on the JSP page.
pRequest.serviceParameter("output", pRequest, pResponse);
}
}
Run Code Online (Sandbox Code Playgroud)
希望这足以让你开始.
| 归档时间: |
|
| 查看次数: |
14136 次 |
| 最近记录: |