AnsweredAssumed Answered

Dashlet: how to use  java-backed code to instead of the .js controller?

Question asked by sunquanbin on Sep 16, 2013
Latest reply on Sep 23, 2013 by sunquanbin

I have created a very simple dashlet for share. I have the following three files in the path: alfresco/web-extension/site-webscripts/org/alfresco/components/dashlets

<li>A controller: hello.js</li>
  It defines a porpterty:
model.msg = "A hello message."

<li>A free marker template: hello.get.html.ftl.</li>
  It shows the message:

<li>A descriptor: hello.get.desc.xml</li>

I tested share and I could add this dashlet successfully.

My question is: can I write a java code as a controller to return the "model.msg" object instead of using the "hello.js". Something is similar in Java Backed WebScript, which registers the java class to an http get request in a *-context.xml file:

  <bean id="" class="org.alfresco.demo.HelloJava" parent="webscript" />

Is there a similar way to do this for dashlet? And how should I name this ???-context.xml file and where should I put it?

PS. my java code is

public class HelloJava extends DeclarativeWebScript
   protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
      Map<String, Object> model = new HashMap<String, Object>();
      model.put("msg", "A message from Java Code.");
      return model;

Many thanks