07-10-2009 07:37 PM
07-21-2009 07:55 AM
<bean id="webframework.searchpath" class="org.alfresco.web.scripts.SearchPath">
<property name="searchPath">
<list>
<ref bean="webframework.remotestore.webscripts" />
<ref bean="webframework.store.webscripts.custom" />
<ref bean="webframework.store.webscripts" />
<ref bean="webscripts.store" />
</list>
</property>
</bean>
<bean id="webframework.store.webscripts.custom" class="org.alfresco.web.scripts.ClassPathStore">
<property name="mustExist"><value>false</value></property>
<property name="classPath"><value>alfresco/web-extension/site-webscripts</value></property>
</bean>
<webscript>
<shortname>The World's Simplest Webscript</shortname>
<description>Hands back a little bit of JSON</description>
<family>user-dashlet</family>
<url>/demo/simple</url>
<authentication>none</authentication>
</webscript>
<!– Abstract Web Script Implementations –>
<bean id="webscript" abstract="true"/>
<bean id="webscript.org.alfresco.demo.simple.get" class="org.alfresco.module.demoscripts.SimpleWebScript" parent="webscript"/>
package org.alfresco.module.demoscripts;
import java.io.IOException;
import java.io.Writer;
import org.alfresco.web.scripts.AbstractWebScript;
import org.alfresco.web.scripts.WebScriptException;
import org.alfresco.web.scripts.WebScriptRequest;
import org.alfresco.web.scripts.WebScriptResponse;
import org.json.JSONException;
import org.json.JSONObject;
public class SimpleWebScript extends AbstractWebScript {
public void execute(WebScriptRequest req, WebScriptResponse res)
throws IOException {
try {
// build a json object
JSONObject obj = new JSONObject();
// put some data on it
obj.put("field1", "data1");
// build a JSON string and send it back
String jsonString = obj.toString();
Writer writer = res.getWriter();
//writer.write(jsonString);
writer.write("<div class=\"dashlet\">");
writer.write("<div class=\"title\">SIMPLE WEB SCRIPT</div>");
writer.write("<div id=\"SIMPLEWEBSCRIPT\" class=\"body scrollableList\">");
writer.write("<h1>SIMPLE SIMPLE</h1>");
writer.write("</div>");
writer.write("</div>");
} catch (JSONException e) {
throw new WebScriptException("Unable to serialize JSON");
}
}
}
07-21-2009 11:14 PM
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.