[HttpRequestHandler] Add a new action for javascript script's 

[HttpRequestHandler] Add a new action for javascript script's 

Hello all

In HttpRequestHandler there is a nice little action that adds a <script> tag to the <head> section.

The problem is that it only adds a <script> tag using the src parameter and not a entire script.

It does something like: 
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>

but it would also be useful to have something like:
<script type="text/javascript">

As such I propose a possible solution to an action AddJavaScript to be added to the HttpRequestHandler extension:
In HttpRequestHandler.cs add
        public void MssAddJavaScript(string ssJavaScriptSource, bool ssDefer, string ssCharset) {
            HeadFilter hf = GetHeadFilter();
            hf.AddJavaScript(ssJavaScriptSource, ssDefer);

In HeadFilter.cs add
       public void AddJavaScript(string JavaScriptSource, bool defer) {
              AddScript("text/javascript", JavaScriptSource, defer);

       public void AddScript(string Type, string SRC, bool defer) {
              if (defer) {
                     scriptTags.AppendFormat("<script type=\"{0}\" defer=\"defer\">{1}</script>", Type, SRC);
              } else {
                     scriptTags.AppendFormat("<script type=\"{0}\">{1}</script>", Type, SRC);
If you like this idea give it a "Like" in http://www.outsystems.com/wisdomofthecrowds/IdeaComment_List.aspx?IdeaId=939 :)
Hi Pedro

That already exists.
Is called "RunJavaScript" in the HTTPRequestHandler. Not sure if it's implemented like that, but has the same effect.
(If you are using a old version of the platform think it was included on the RichWidgetsExtension extension before)

João Rosado

I'm not 100% sure on this, but I think the RunJavaScript puts the script at the current "location" of the HTML not at the <head> section. I was checking the extension for the implementation and it only has the following code: 
        public void MssRunJavaScript(string ssScript) {

Since we don't have the code for the Outsystems.HubEdition.RuntimePlatform.AppInfo class I cannot validate the implementation details.

This request for the <head> section has some importance in Google Api's for instance where you need to do something like  google.load("jquery", "1.6.4") before anything else in the page. 

Best regards,
Hi Pedro,

Ok, missread a bit..

Either write that on a Javascript property, or in an unescaped expression.
Don't need to be on the head part.

Alternativelly ..if you really really want to put add that on the Head, you can use the AddPostProcessingFilter.
But I think it's a overkill.

João Rosado