AnsweredAssumed Answered

Error while calling createcomment webscript in dialog

Question asked by sharad_panchal on Sep 27, 2011
I am new to the alfresco development. One of the requirement I am working on is to give a add comments funtionality for the documents on seach result page. On search result page, there will be button "Comments" at bottom of every row. On click of it, the comment dialog box will opened for providing a comments.

I have written following code, similar to onActionDetails functions in documentlibrary/actions.js. But it gives an error

freemarker.core.InvalidReferenceException - Expression page is undefined on line 4, column 18 in org/alfresco/components/blog/createcomment.get.html.ftl.

Please let me know what is issue in my code.

I trying to reuse the createcomment webservice for the functionality by calling it through Alfresco.util.SimpleDialog.
The code I have written in search-min.js is as follows.

addition in Search_renderCellDescription funtion


desc +='<span id="'+me.id+'-commentDoc-button" class="yui-button yui-push-button search-icon"><span class="first-child"><button

type="button">Comment</button></span></span>';



elCell.innerHTML = desc;

      var commentDocButton = elCell.getElementsByTagName("span");
      for (i = 0, ii = commentDocButton.length; i < ii; i++)
      {
         if(commentDocButton.id == me.id+'-commentDoc-button')
         {
            Event.addListener(commentDocButton, "click",
            function show_comment_dialog()
            {
               //Alfresco.module.getILKMDialogInstance().show();

               var templateUrl = YAHOO.lang.substitute(Alfresco.constants.URL_SERVICECONTEXT +
               components/blog/createcomment",
               {
                  htmlid: me.id
               });

               // Using Forms Service, so always create new instance
               var myDialog = new Alfresco.module.SimpleDialog(me.id+'-myDialog');

               myDialog.setOptions(
               {
                  width: "40em",
                  templateUrl: templateUrl,
                  actionUrl: null,
                  destroyOnHide: true,
                  onSuccess:
                  {
                     fn: function myDialog_success(response)
                     {
                        Alfresco.util.PopupManager.displayMessage(
                        {
                           text: "Success!"
                        });
                     },
                     scope: this
                  },
                  onFailure:
                  {
                     fn: function myDialog_failure(response)
                     {
                        if (response)
                        {
                           Alfresco.util.PopupManager.displayMessage(
                           {
                              text: "Failed to complete task."
                           });
                        }
                        else
                        {
                           Alfresco.util.PopupManager.displayMessage(
                           {
                              text: "Failed to communicate with server…or something"
                           });
                        }
                     },
                     scope: this
                  }
               }).show();


            }
            , me, true);
         }
      }

This funtion code the render the button also on click give the call to createcomment webscript. But CreateComment webscript throw following exception.

20:59:18,001 http-8080-6 ERROR [freemarker.runtime] Expression page is undefined on line 4, column 18 in

org/alfresco/components/blog/createcomment.get.html.ftl.

Expression page is undefined on line 4, column 18 in org/alfresco/components/blog/createcomment.get.html.ftl.
The problematic instruction:
———-
==> ${page.url.templateArgs.site!""} [on line 4, column 16 in org/alfresco/components/blog/createcomment.get.html.ftl]
———-

Java backtrace for programmers:
———-
freemarker.core.InvalidReferenceException: Expression page is undefined on line 4, column 18 in org/alfresco/components/blog/createcomment.get.html.ftl.
   at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
   at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:134)
   at freemarker.core.Dot._getAsTemplateModel(Dot.java:78)
   at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   at freemarker.core.Dot._getAsTemplateModel(Dot.java:74)
   at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   at freemarker.core.Dot._getAsTemplateModel(Dot.java:74)
   at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   at freemarker.core.DefaultToExpression._getAsTemplateModel(DefaultToExpression.java:100)
   at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   at freemarker.core.Expression.getStringValue(Expression.java:93)
   at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
   at freemarker.core.Environment.visit(Environment.java:210)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:210)
   at freemarker.core.Environment.process(Environment.java:190)
   at org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:171)
   at org.springframework.extensions.webscripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:589)
   at org.springframework.extensions.webscripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:267)
   at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147)
   at org.springframework.extensions.webscripts.PresentationContainer.executeScript(PresentationContainer.java:69)
   at org.springframework.extensions.webscripts.LocalWebScriptRuntimeContainer.executeScript(LocalWebScriptRuntimeContainer.java:231)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:333)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:189)
   at org.springframework.extensions.webscripts.servlet.mvc.WebScriptView.renderMergedOutputModel(WebScriptView.java:99)
   at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
   at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
   at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
   at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
   at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
   at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
   at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:195)
   at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:159)
   at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
   at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
   at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:417)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
   at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
   at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
   at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
   at java.lang.Thread.run(Thread.java:619)
20:59:18,001 http-8080-6 ERROR [extensions.webscripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: 08270002 Failed

to process template org/alfresco/components/blog/createcomment.get.html.ftl
org.springframework.extensions.webscripts.WebScriptException: 08270002 Failed to process template org/alfresco/components/blog/createcomment.get.html.ftl
   at org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:175)
   at org.springframework.extensions.webscripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:589)
   at org.springframework.extensions.webscripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:267)
   at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147)
   at org.springframework.extensions.webscripts.PresentationContainer.executeScript(PresentationContainer.java:69)
   at org.springframework.extensions.webscripts.LocalWebScriptRuntimeContainer.executeScript(LocalWebScriptRuntimeContainer.java:231)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:333)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:189)
   at org.springframework.extensions.webscripts.servlet.mvc.WebScriptView.renderMergedOutputModel(WebScriptView.java:99)
   at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
   at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
   at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
   at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
   at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
   at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
   at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:195)
   at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:159)
   at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
   at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
   at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:417)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
   at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
   at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
   at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
   at java.lang.Thread.run(Thread.java:619)
Caused by: freemarker.core.InvalidReferenceException: Expression page is undefined on line 4, column 18 in

org/alfresco/components/blog/createcomment.get.html.ftl.
   at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
   at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:134)
   at freemarker.core.Dot._getAsTemplateModel(Dot.java:78)
   at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   at freemarker.core.Dot._getAsTemplateModel(Dot.java:74)
   at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   at freemarker.core.Dot._getAsTemplateModel(Dot.java:74)
   at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   at freemarker.core.DefaultToExpression._getAsTemplateModel(DefaultToExpression.java:100)
   at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   at freemarker.core.Expression.getStringValue(Expression.java:93)
   at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
   at freemarker.core.Environment.visit(Environment.java:210)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:210)
   at freemarker.core.Environment.process(Environment.java:190)
   at org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:171)
   … 39 more
Please let me know I am doing it in correct way. Or there is other way of calling it.

Regards and thanks in advance
Sharad

Outcomes