cancel
Showing results for 
Search instead for 
Did you mean: 

Use type d:any in a Webscript

dranakan
Champ on-the-rise
Champ on-the-rise
Hello Smiley Happy

Can someone give me an example or link to use the type "d:any" in a Webscript ? The type "d:any" can store Java Object. I would like to store an array of int.

In Java, it's easy to add value.

int [] listIntTest={2,3,4,6};

Map<QName, Serializable> aspectProps = new HashMap<QName, Serializable>();

// Add the properties (the array)
aspectProps.put(QName.createQName(CustomModelItf.NAMESPACE_CUSTOM_GENERAL_MODEL_URI,CustomModelItf.PROP_sc_LISTANY),listIntTest);

// Add the aspect with its properties
nodeService.addAspect(node,QName.createQName(CustomModelItf.NAMESPACE_CUSTOM_GENERAL_MODEL_URI,CustomModelItf.ASPECT_sc_LIST),aspectProps);

How can I get these properties in a Webscript ? (Do you have the syntaxe to get the result in a ftl file ?)  :?:
I take value like this :


<#if child.properties['sc:documentNb']?exists & (child.properties['sc:documentNb']?length !=0)>
   <#assign val = "${child.properties['sc:documentNb']?c}"/>
   <documentNb>${val}</documentNb>
</#if>
But how take with an array ?
How can I show this value with the web-client-config ?  :?:

Thanks
5 REPLIES 5

dranakan
Champ on-the-rise
Champ on-the-rise
It is possible to do that :

   <#if child.properties['sc:listAny']?exists>
      <#assign val = [3,4,566] />
      <#list val as number>${number}<#if number_has_next>,</#if></#list>
   </#if>

but when I want to get my values…. it doesn't work…

   <#if child.properties['sc:listAny']?exists>
      <#assign val = child.properties['sc:listAny'] />
      <#list val as number>${number}<#if number_has_next>,</#if></#list>
   </#if>

Error :


500 Description:    Le serveur a recontrer une erreur interne qui l''a empêché de satisfaire la requête.

Message:   Wrapped Exception (with status template): Error during processing of the template 'Expected collection or sequence. val evaluated instead to freemarker.template.SimpleScalar on line 45, column 64 in org/alfresco/module/custom/searchresult/searchResults.get.html.ftl.'. Veuillez contacter votre administrateur système.
   
Exception:   freemarker.template.TemplateException - Expected collection or sequence. val evaluated instead to freemarker.template.SimpleScalar on line 45, column 64 in org/alfresco/module/custom/searchresult/searchResults.get.html.ftl.
   
   freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135)
   freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:190)
   freemarker.core.Environment.visit(Environment.java:415)
   freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
   freemarker.core.Environment.visit(Environment.java:208)
   freemarker.core.MixedContent.accept(MixedContent.java:92)
   freemarker.core.Environment.visit(Environment.java:208)
   freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
   freemarker.core.Environment.visit(Environment.java:208)
   freemarker.core.MixedContent.accept(MixedContent.java:92)
   freemarker.core.Environment.visit(Environment.java:208)
   freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
   freemarker.core.Environment.visit(Environment.java:208)
   freemarker.core.MixedContent.accept(MixedContent.java:92)
   freemarker.core.Environment.visit(Environment.java:208)
   freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:179)
   freemarker.core.Environment.visit(Environment.java:415)
   freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
   freemarker.core.Environment.visit(Environment.java:208)
   freemarker.core.MixedContent.accept(MixedContent.java:92)
   freemarker.core.Environment.visit(Environment.java:208)
   freemarker.core.IfBlock.accept(IfBlock.java:82)
   freemarker.core.Environment.visit(Environment.java:208)
   freemarker.core.MixedContent.accept(MixedContent.java:92)
   freemarker.core.Environment.visit(Environment.java:208)
   freemarker.core.Environment.process(Environment.java:188)
   freemarker.template.Template.process(Template.java:237)
   org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:201)
   org.alfresco.web.scripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:505)
   org.alfresco.web.scripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:241)
   org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147)
   org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:319)
   org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:320)
   org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:227)
   org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:368)
   org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:390)
   org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:273)
   org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:261)
   org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139)
   org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:116)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
   org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
   org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   java.lang.Thread.run(Thread.java:619)
   
Exception:   org.alfresco.service.cmr.repository.TemplateException - Error during processing of the template 'Expected collection or sequence. val evaluated instead to freemarker.template.SimpleScalar on line 45, column 64 in org/alfresco/module/custom/searchresult/searchResults.get.html.ftl.'. Veuillez contacter votre administrateur système.
   
   org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:205)
   
Exception:   org.alfresco.web.scripts.WebScriptException - Wrapped Exception (with status template): Error during processing of the template 'Expected collection or sequence. val evaluated instead to freemarker.template.SimpleScalar on line 45, column 64 in org/alfresco/module/custom/searchresult/searchResults.get.html.ftl.'. Veuillez contacter votre administrateur système.
   
   org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:595)

What is wrong ?

Thanks

dranakan
Champ on-the-rise
Champ on-the-rise
Hello,

Nobody uses the type d:any in Webscript ?

rsulliv1
Champ in-the-making
Champ in-the-making
Have you made any progress with this issue?

dranakan
Champ on-the-rise
Champ on-the-rise
Hello,

Have you made any progress with this issue?

No…

rsulliv1
Champ in-the-making
Champ in-the-making
I fixed my issue by creating a javascript array

var jArray = new Array();

and then pushing individual arrays onto that stack

var arrayItem = {};

arrayItem.element1 = "whatever";
arrayItem.element2 = "also whatever";

jArray.push(arrayItem);

then returning jArray to the model:

model.stuffToIterate = jArray;

Before I was simply pushing the arrayItem to the model:

arrayItem.element1 = "whatever";
arrayItem.element2 = "also whatever";

model.stuffToIterate = arrayItem;



Not sure if that helps at all, but it got me past my issue.