0

im trying to run a java based-webscript in alfresco. In my first step I just want to print "hello world" using the response output stream.The main problem I face is that the code is not being executed.I have tried to set breakpoints in the code but they dont trigger,I only get the plain ftl as a result.

Shouldnt the abstratWebscript response priorize over the ftl? Could someone tell me what im doing wrong or if this is the natural behavior of the abstractwebscript?

This is the java class:

package com.beam.gbsprocs.tag.webscript;
import java.io.IOException;
import java.io.PrintWriter;    

import org.springframework.extensions.webscripts.AbstractWebScript;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;

public class GbsprocsTagWebscript extends AbstractWebScript {



  @Override
  public void execute(WebScriptRequest req, WebScriptResponse res)
        throws IOException {

    PrintWriter out = new PrintWriter(res.getOutputStream());

    out.println("hello world");
    out.close();

  }

}

This is the description file

<webscript>
<shortname>Perform GBSprocs  Tag completion</shortname>
<description>Export gives a json list of posible tag values </description>
<url>/gbsprocs/tag</url>
<authentication>user</authentication>
</webscript>

Bean declaration(added in edition):

  <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:util="http://www.springframework.org/schema/util"

   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
   http://www.springframework.org/schema/util
  http://www.springframework.org/schema/util/spring-util-2.5.xsd">

 <bean id="com.beam.gbsprocs.tag.webscript.GbsprocsTagWebscript.get"
    class="com.beam.gbsprocs.tag.webscript.GbsprocsTagWebscript"
      parent="webscript">


 </bean>

</beans>

And the ftl looks like:

Hello from ftl.

Executing result: rest client response

1 Answers1

1

Use org.springframework.extensions.webscripts.DeclarativeWebScript instead AbstractWebScript

and @override method protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) that returns your model to ftl

And also you need add bean deffenition on your class

M.Diachenko
  • 198
  • 7
  • I know it can work that way,but i wonder if it is posible to do it with an AbstractWebscript. (I added my spring bean definition to have all the data) – Adrián Álvarez Jun 01 '16 at 10:29