You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Hugo Ferreira <hf...@gmail.com> on 2020/10/01 22:27:05 UTC

External JS code

Hi,

I'm currently building a new "wrapper" for Apache Royale to render and
design reports thru StimulsoftReports JS library

I learned the concept from Carlos and Maria examples and also the
documentation.
I learned how to import external JS libraries and CSS and how to just call
a JS function with parameters.

But I need to run and build JS on the Royale side.
Use StimulsolftReports it's not done by call just a function.
I need to build JS code.

A short example:
var report = new Stimulsoft.Report.StiReport();
report.loadFile("SimpleList.mrt");
var viewer = new Stimulsoft.Viewer.StiViewer();
viewer.report = report;

Is there a way to do this like a way to inject this code as the way we
already have to inject JS and CSS files on the header ?
Or the only way is to build the JS code on a separate JS file and include
it on the project ?

Re: External JS code

Posted by Carlos Rovira <ca...@apache.org>.
Hi ,

I think this is the problem already asked in the other thread right? See if
the response I just put there works for you (create a extern per js script
class) and then use it from AS3 in the right order. Let's see if this works
for you.

Also here's another project I started using externs to use Mark down for
our site:

https://github.com/apache/royale-asjs/tree/develop/examples/jewel/royale-website

Maybe it give you more working code that helps you to learn about externs.




El vie., 2 oct. 2020 a las 13:42, Hugo Ferreira (<hf...@gmail.com>)
escribió:

> Of course.
>
>
> ////////////////////////////////////////////////////////////////////////////////
> //
> // Licensed to the Apache Software Foundation (ASF) under one or more
> // contributor license agreements. See the NOTICE file distributed with
> // this work for additional information regarding copyright ownership.
> // The ASF licenses this file to You under the Apache License, Version 2.0
> // (the "License"); you may not use this file except in compliance with
> // the License. You may obtain a copy of the License at
> //
> // http://www.apache.org/licenses/LICENSE-2.0
> //
> // Unless required by applicable law or agreed to in writing, software
> // distributed under the License is distributed on an "AS IS" BASIS,
> // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> // See the License for the specific language governing permissions and
> // limitations under the License.
> //
>
> ////////////////////////////////////////////////////////////////////////////////
> package
> {
> /**
> * @externs
> */
> COMPILE::JS
> public class StimulsoftReports
> {
> /**
> * <inject_script>
> * var script = document.createElement("script");
> * script.setAttribute("src",
> "resources/stimulsoftreports/stimulsoft.reports.js");
> * document.head.appendChild(script);
> * window.onload = function()
> * {
> * var script = document.createElement("script");
> * script.setAttribute("src",
> "resources/stimulsoftreports/stimulsoft.viewer.js");
> * document.head.appendChild(script);
> * }
> * function loadReport(renderArea, reportDefinition)
> * {
> * var viewer = new Stimulsoft.Viewer.StiViewer();
> * var report = new Stimulsoft.Report.StiReport();
> * report.load(reportDefinition);
> * viewer.report = report;
> * }
> * var link = document.createElement("link");
> * link.setAttribute("rel", "stylesheet");
> * link.setAttribute("href",
> "resources/stimulsoftreports/stimulsoft.viewer.office2013.whiteblue.css");
> * document.head.appendChild(link);
> * </inject_script>
> */
> public function StimulsoftReports(){}
>
> public static function loadReport(renderArea:Element,
> reportDefinition:String):void {}
> }
> }
>
> The above example, inject this code:
> function loadReport(renderArea, reportDefinition)
> {
> var viewer = new Stimulsoft.Viewer.StiViewer();
> var report = new Stimulsoft.Report.StiReport();
> report.load(reportDefinition);
> viewer.report = report;
> }
>
> Then I run on my Royale/AS side, StimulsoftReports.loadReport ... but I get
> console error: Uncaught ReferenceError: StimulsoftReports is not defined
>
> Perhaps I should create a JS file with this JS script and append to
> document head.
>
> Carlos Rovira <ca...@apache.org> escreveu no dia sexta, 2/10/2020
> à(s) 12:32:
>
> > Sorry Hugo, don't understand what you mean in your question
> > can you reformulate?
> >
> >
> > El vie., 2 oct. 2020 a las 0:27, Hugo Ferreira (<hferreira.80@gmail.com
> >)
> > escribió:
> >
> > > Hi,
> > >
> > > I'm currently building a new "wrapper" for Apache Royale to render and
> > > design reports thru StimulsoftReports JS library
> > >
> > > I learned the concept from Carlos and Maria examples and also the
> > > documentation.
> > > I learned how to import external JS libraries and CSS and how to just
> > call
> > > a JS function with parameters.
> > >
> > > But I need to run and build JS on the Royale side.
> > > Use StimulsolftReports it's not done by call just a function.
> > > I need to build JS code.
> > >
> > > A short example:
> > > var report = new Stimulsoft.Report.StiReport();
> > > report.loadFile("SimpleList.mrt");
> > > var viewer = new Stimulsoft.Viewer.StiViewer();
> > > viewer.report = report;
> > >
> > > Is there a way to do this like a way to inject this code as the way we
> > > already have to inject JS and CSS files on the header ?
> > > Or the only way is to build the JS code on a separate JS file and
> include
> > > it on the project ?
> > >
> >
> >
> > --
> > Carlos Rovira
> > http://about.me/carlosrovira
> >
>


-- 
Carlos Rovira
http://about.me/carlosrovira

Re: External JS code

Posted by Hugo Ferreira <hf...@gmail.com>.
Of course.

////////////////////////////////////////////////////////////////////////////////
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
package
{
/**
* @externs
*/
COMPILE::JS
public class StimulsoftReports
{
/**
* <inject_script>
* var script = document.createElement("script");
* script.setAttribute("src",
"resources/stimulsoftreports/stimulsoft.reports.js");
* document.head.appendChild(script);
* window.onload = function()
* {
* var script = document.createElement("script");
* script.setAttribute("src",
"resources/stimulsoftreports/stimulsoft.viewer.js");
* document.head.appendChild(script);
* }
* function loadReport(renderArea, reportDefinition)
* {
* var viewer = new Stimulsoft.Viewer.StiViewer();
* var report = new Stimulsoft.Report.StiReport();
* report.load(reportDefinition);
* viewer.report = report;
* }
* var link = document.createElement("link");
* link.setAttribute("rel", "stylesheet");
* link.setAttribute("href",
"resources/stimulsoftreports/stimulsoft.viewer.office2013.whiteblue.css");
* document.head.appendChild(link);
* </inject_script>
*/
public function StimulsoftReports(){}

public static function loadReport(renderArea:Element,
reportDefinition:String):void {}
}
}

The above example, inject this code:
function loadReport(renderArea, reportDefinition)
{
var viewer = new Stimulsoft.Viewer.StiViewer();
var report = new Stimulsoft.Report.StiReport();
report.load(reportDefinition);
viewer.report = report;
}

Then I run on my Royale/AS side, StimulsoftReports.loadReport ... but I get
console error: Uncaught ReferenceError: StimulsoftReports is not defined

Perhaps I should create a JS file with this JS script and append to
document head.

Carlos Rovira <ca...@apache.org> escreveu no dia sexta, 2/10/2020
à(s) 12:32:

> Sorry Hugo, don't understand what you mean in your question
> can you reformulate?
>
>
> El vie., 2 oct. 2020 a las 0:27, Hugo Ferreira (<hf...@gmail.com>)
> escribió:
>
> > Hi,
> >
> > I'm currently building a new "wrapper" for Apache Royale to render and
> > design reports thru StimulsoftReports JS library
> >
> > I learned the concept from Carlos and Maria examples and also the
> > documentation.
> > I learned how to import external JS libraries and CSS and how to just
> call
> > a JS function with parameters.
> >
> > But I need to run and build JS on the Royale side.
> > Use StimulsolftReports it's not done by call just a function.
> > I need to build JS code.
> >
> > A short example:
> > var report = new Stimulsoft.Report.StiReport();
> > report.loadFile("SimpleList.mrt");
> > var viewer = new Stimulsoft.Viewer.StiViewer();
> > viewer.report = report;
> >
> > Is there a way to do this like a way to inject this code as the way we
> > already have to inject JS and CSS files on the header ?
> > Or the only way is to build the JS code on a separate JS file and include
> > it on the project ?
> >
>
>
> --
> Carlos Rovira
> http://about.me/carlosrovira
>

Re: External JS code

Posted by Carlos Rovira <ca...@apache.org>.
Sorry Hugo, don't understand what you mean in your question
can you reformulate?


El vie., 2 oct. 2020 a las 0:27, Hugo Ferreira (<hf...@gmail.com>)
escribió:

> Hi,
>
> I'm currently building a new "wrapper" for Apache Royale to render and
> design reports thru StimulsoftReports JS library
>
> I learned the concept from Carlos and Maria examples and also the
> documentation.
> I learned how to import external JS libraries and CSS and how to just call
> a JS function with parameters.
>
> But I need to run and build JS on the Royale side.
> Use StimulsolftReports it's not done by call just a function.
> I need to build JS code.
>
> A short example:
> var report = new Stimulsoft.Report.StiReport();
> report.loadFile("SimpleList.mrt");
> var viewer = new Stimulsoft.Viewer.StiViewer();
> viewer.report = report;
>
> Is there a way to do this like a way to inject this code as the way we
> already have to inject JS and CSS files on the header ?
> Or the only way is to build the JS code on a separate JS file and include
> it on the project ?
>


-- 
Carlos Rovira
http://about.me/carlosrovira