04-28-2008 09:30 AM
05-29-2008 04:56 AM
11-17-2008 06:57 AM
WEB-INF\lib6). copied helloworld-scripts-context.xml in
shared\classes\alfresco\extension7). removed alfresco.war
<webscript>
<shortname> Hello World </shortname>
<description> Hello World Web Script </description>
<url> /helloworld?name={nameArgument} </url>
</webscript>package com.helloworld.scripts;
import java.util.Map;
import java.util.HashMap;
import org.alfresco.web.scripts.DeclarativeWebScript;
import org.alfresco.web.scripts.WebScriptRequest;
import org.alfresco.web.scripts.WebScriptStatus;
public class HelloWorld extends org.alfresco.web.scripts.DeclarativeWebScript
{
String nm="";
protected Map<String, Object> executeImpl(WebScriptRequest wr, WebScriptStatus ws){
System.out.println("from executeImpl()****************");
System.out.println("hello****************");
Map<String, Object> model = new HashMap<String, Object>();
model.put("foo", nm);
return model;
}
public void setSomeName(String name){
nm=name;
}
}<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans-2.0.dtd'>
<beans>
<bean id="webscript.com.scripts.helloworld.get" class="com.helloworld.scripts.HelloWorld" parent="webscript">
<property name="someName">
<value> This is a Foo Name </value>
</property>
</bean>
</beans><html>
<body>
<p> Hello, ${args.name} </p>
Foo : ${foo}
</body>
</html>06-08-2010 05:18 AM
It is really quite powerfull and easy to do once you have it setup.
There are a few items you must be aware of. Here's how I did it.
* Create the javabean according to java standards.
* Add the javabean to the freemarker model. I did this by creating my own servlet the extended GuestTemplateContentServlet and extending the buildModel method. This method is what is used by alfresco add the alfresco java beans to the root model.
* I then added my own javabeans that did whatever I needed them to.
So for example you had a Javabean with a getTotal() method and you added it to the HashMap with an id of "calc". In the template you would simply say: ${calc.total} once the javabean is added to the root Hashmap. Take a look at the org.alfresco.web.app.servlet.GuestTemplateContentServlet. Turn on it's debugging in you wish and you will see how it works.
The total method can return most any java.lang data type as well as List or Map interfaces.
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.