XmlObjectAspect is Not found

Poster Content
nk4um User
Posts: 16
May 8, 2007 08:39Thanks....
Hi Gertone & PJR,
I got it. Now its work fine. Really thanks for ur support.

K.B
Like · Post Reply
nk4um User
Posts: 102
May 8, 2007 08:09what puzzles me...
... is that you got away with your unwellformed XML
if I paste in your earliest copy of the XML document,
I get a "Failed to compile script" exception
So I don''t really understand that you did not get an error on that

cheers

Geert
Like · Post Reply
nk4um Moderator
Posts: 901
May 8, 2007 08:08Browser?
Hi Kawsi/Gert,

Thanks for helping Gert!  I wonder.  Kawsi, you''re not trying to run this javascript in the browser are you?   NetKernel has *server-side* javascript which is executed by calling the active:javascript engine.  (That''s what the script play pen is doing).  Calls to Java objects like XmlObject aspect will only work if you''re running the script inside NK on the server.

Pete
Like · Post Reply
nk4um User
Posts: 102
May 8, 2007 08:00sorry, I am lost...
Hi,

I tested your example and it works fine with me
Here is the full JavaScript, that works for me.
I assume that when you call the script in a module
that you have set everything right so it will call this JavaScript file


// -------------------------------------------------------------------------------------------------
// imported Packages
// -------------------------------------------------------------------------------------------------
importPackage(Packages.org.ten60.netkernel.xml.representation);
importPackage(Packages.com.ten60.netkernel.urii.aspect);
importPackage(Packages.org.ten60.netkernel.layer1.representation);
importPackage(Packages.java.lang);
// -------------------------------------------------------------------------------------------------

   var quote = new Array();
   quote[0] =  5;
   var auther = new Array();
   auther[0] = "me";
   randNum = 0;
   
   doc = <TodayQuote>
           <Title>Quote of the day:</Title>
           <Text>{quote[randNum]}</Text>
           <Prompt>{auther[randNum]}</Prompt>
         </TodayQuote>;

    //Create XmlObjectAspect and return as response
    xoa=new XmlObjectAspect(doc.getXmlObject() );
    resp=context.createResponseFrom(xoa);
    resp.setMimeType("text/xml");
    context.setResponse(resp);


I hope Pete or Tony have a clue

cheers

Geert
Like · Post Reply
nk4um User
Posts: 16
May 8, 2007 04:34configuration issue?
Hi
I dont think it could be a problem. Bcoz when i tried the XML code with root element also faced same problem. But in Scripting Playpen it executed successfully and gave the result what i expect to have as output. Again my code:

doc=<TodayQuote>                          
   <Title>Quote of the day:</Title>         
   <Text>{quote[randNum]}</Text>                             
   <Prompt>{auther[randNum]}</Prompt>                           
   </TodayQuote>;
   
//Create XmlObjectAspect and return as response
    xoa=new XmlObjectAspect(doc.getXmlObject() );
    resp=context.createResponseFrom(xoa);
    resp.setMimeType("text/xml");   
    context.setResponse(resp);


Is it a configuration issue within my module? But the Javascript example file Time.js works fine within my module. Cant i use Arrays? or any suggestion?

Thanks 4 ur response
K.B
Like · Post Reply
nk4um User
Posts: 102
May 7, 2007 08:28XML not valid?
The XML as you posted it is not wellformed (3 root elements)
maybe that is the cause of the object not found error

cheers

Geert
Like · Post Reply
nk4um User
Posts: 16
May 7, 2007 08:01ReferenceError
Hi,
Now I got the error like this:

org.mozilla.javascript.EcmaError
ReferenceError: "XmlObjectAspect" is not defined.

Any suggestion?

Thanks for ur response
K.B
Like · Post Reply
nk4um User
Posts: 102
May 4, 2007 17:54import some packages
Hi,

I have this in most of my JavaScripts

// -------------------------------------------------------------------------------------------------
// imported Packages
// -------------------------------------------------------------------------------------------------
importPackage(Packages.org.ten60.netkernel.xml.representation);
importPackage(Packages.com.ten60.netkernel.urii.aspect);
//importPackage(Packages.org.ten60.netkernel.layer1.representation);
importPackage(Packages.java.lang);
// -------------------------------------------------------------------------------------------------


Then it should work,
cheers

Geert
Like · Post Reply
nk4um User
Posts: 16
May 4, 2007 11:06XmlObjectAspect is Not found
Hi
Im using NK 3.0. I would like to use Javascript as scripting language.For that do i ve to install any additional packages? If that so, plz give some detail abt that.
Becouse my javascript works fine in PenScripting application & got d output what  i expect. But got ReferenceError: XmlObjectAspect is Not found(org.mozilla.javascript.EcmaError) when i tried to view .js file via browser.
This is the code i wrote:

//Create XML literal
doc=                 
   <Title>Quote of the day:</Title>         
   <Text>{quote[randNum]}</Text>                             
   <Prompt>{auther[randNum]}</Prompt>;
   
//Create XmlObjectAspect and return as response
    xoa=new XmlObjectAspect(doc.getXmlObject() );
    resp=context.createResponseFrom(xoa);
    resp.setMimeType("text/xml");   
    context.setResponse(resp);


Thanks in advance.
K.B
Like · Post Reply