cancel
Showing results for 
Search instead for 
Did you mean: 

Error displaying script config value in webscript

cperez
Champ in-the-making
Champ in-the-making
Hi all.

I add to my webscript a new script config file "nodeAct.get.config.xml" to use that values in "nodeAct.get.js" and "nodeAct.get.html.ftl".

but when I try to get show the value in the ftl i get the next error:

500 Description:   An error inside the HTTP server which prevented it from fulfilling the request. Message:   Wrapped Exception (with status template): 'Error on line 26, column 31 in nodeAct.get.html.ftl Expecting a string, date or number here, Expression uname is instead a freemarker.template.SimpleHash'.    Exception:   freemarker.core.NonStringException - Error on line 26, column 31 in nodeAct.get.html.ftl Expecting a string, date or number here, Expression uname is instead a freemarker.template.SimpleHash‍‍‍‍‍‍‍


This is my "nodeAct.get.html.ftl"
<html>   <head>      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>      <script type="text/javascript">         jQuery.support.cors = true;         var urlTicket = "${url.serviceContext}/api/login?u=${user}&pw=${pass}";         var ticket = "";         var request = $.get(urlTicket, function(data,status){            ticket = data.toString().substring(48,95);            //window.location.href = "${url.serviceContext}/doAct?nId=${nId}${arguments}&alf_ticket="+ticket;            },'html'         );         request.error(function(jqXHR, textStatus) {            if (textStatus == 'error'){               status.code = 403;               status.message = "User not found.";               status.redirect = true;            }         });      </script>      <title>Doing actions</title>   </head>   <body>      <div id="error-box" >         <br />          <br /><td>nombre= ${uname}</td>      </div>   </body></html>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


this is the error line
          <br /><td>nombre= ${uname}</td>‍‍‍




And this is the "nodeAct.get.js" where i define the uname variable:
    var s = new XML(config.script);     model.uname =s.nodeAct.nombre;‍‍‍‍


I also try with :
   - model.uname =s.nombre;
   - model.uname =s.nodeAct.clave;
   - model.uname =s.clave;

But i get the same error, and i finally try callin a non xml variable defined ( model.uname=s.notExistSmiley Wink and I get the same error.

I try all defined in https://wiki.alfresco.com/wiki/Web_Scripts#Configuration.

What am i doing wrong??
I'm using alfresco 3.0 if it's relevant.

Thanks a lot in advance


5 REPLIES 5

sanket
Champ on-the-rise
Champ on-the-rise
Have you tried :
model.uname =s.nodeAct.nombre.toString();
OR
model.uname =s.nombre.toString();
whichever applicable.

cperez
Champ in-the-making
Champ in-the-making
The error was solved, but the result in both cases is "empty" instead of "admin".

This is the "nodeAct.get.config.xml" file content:
<nodeAct>   <nombre>admin</nombre>   <clave>123123</clave></nodeAct>‍‍‍‍‍‍

sanket
Champ on-the-rise
Champ on-the-rise
In this case, you should try with "value" :
s.nodeAct.nombre.value.toString();
Try printing the value on console :
What result you get with these :
s.nodeAct.nombre.value;
s.nodeAct.nombre.value.toString();
s.nodeAct.nombre.toString();

cperez
Champ in-the-making
Champ in-the-making
On the web page, the result is empty with all posibilities.

I don't know how to show it in the console. I've never used the console with alfresco.

Can you explain how to do it?

Thanks

sanket
Champ on-the-rise
Champ on-the-rise
You can turn on the logger in alfresco (tomcat\webapps\alfresco\WEB-INF\classes\log4j.properties) and set these properties to debug or info if you want to print values by writing logger.log(value) in your js files.

log4j.logger.org.alfresco.repo.jscript=debug
log4j.logger.org.alfresco.repo.jscript.ScriptLogger=debug

The same thing applies to alfresco share (tomcat\webapps\share\WEB-INF\classes\log4j.properties).