AnsweredAssumed Answered

Erratic behaviour in webscript results output

Question asked by jlmarques on Mar 5, 2008
Hi, have this webscript that searches for keywords inside files. The problem is that when I reload the webscript the second time it does not return results and this error shows up in the tomcat console:

[Fatal Error] :1:1: Content is not allowed in prolog.

This is my webscript code:


<webscript>
<shortname>Search</shortname>
<description>Retrieves content that matches the search criteria</description>
<url>/cms/search?param={parameter}</url>
<url>/cms/search.json?param={parameter}</url>
<format default="html">extension</format>
<authentication>user</authentication>
<transaction>requiresnew</transaction>
</webscript>


var store = avm.lookupStore("intranet");
var query = "TEXT:"+args.param;

var param = store.luceneSearch(query);

if (param == undefined)
{
   status.code = 404;
   status.message = "Keyword " + args.param + " not found.";
   status.redirect = true;
}
else
{
   var nodes = store.luceneSearch(query);
   model.resultset = nodes;
}


<#if resultset?size==0 >
<p>Não foram encontrados resultados.</p>
<#else>
   <#list resultset as node>
       <#if node.isDocument>
         <#if node.xmlNodeModel?exists>
            <#assign dom=node.xmlNodeModel>
            <#if dom.page?size == 1>
                  <h2>${dom.page.title}</h2>
                  <p>${dom.page.smallDescription}<p>
                  
            </#if>
            <#if dom.article?size == 1>
                  <h2>${dom.article.title}</h2>
                  <p>${dom.article.body}<p>
                  <p><a href="index.php?article=${dom.article.slug}" >continuar a ler</a><p>
            </#if>
            
         <#else>
            <h2>Ficheiro: <a href="http://localhost:8080${url.serviceContext}/api/node/content/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/${node.name?url}">${node.name}</a></h2>
            <p>${node.properties.description!""}</p>
         </#if>
       </#if>
   </#list>
</#if>


Is it something to do with the transaction? I don't know why this happens. Some help would be appreciated :).

Outcomes