Package org.itsnat.core.script

Examples of org.itsnat.core.script.ScriptUtil


        counterText.setData(String.valueOf(counter));       
       
        Document doc = itsNatDoc.getDocument();       

        Element elemParent = doc.getElementById("insertHereId");
        ScriptUtil scriptGen = itsNatDoc.getScriptUtil();
        String elemRef = scriptGen.getNodeReference(elemParent);
        ClientDocument clientDoc = itsNatEvt.getClientDocument();
        clientDoc.addCodeToSend(elemRef + ".innerHTML = '';");       
        clientDoc.addCodeToSend("alert('Currently inserted fragment removed before');");       
               
        ItsNatServlet servlet = itsNatDoc.getItsNatDocumentTemplate().getItsNatServlet()
View Full Code Here


            itsNatDoc.addCodeToSend(msg);
        }

        HTMLTextAreaElement textAreaElem = (HTMLTextAreaElement)doc.getElementById("textAreaId");

        ScriptUtil scriptGen = itsNatDoc.getScriptUtil();

        String code;
        String msg = "A Java String 'transported' \n\t as a \"JavaScript\" string";

        String textAreaElemJS = scriptGen.getNodeReference(textAreaElem);
        String jsStrLiteral = scriptGen.getTransportableStringLiteral(msg);
        code = textAreaElemJS + ".value = " + jsStrLiteral + ";";
        itsNatDoc.addCodeToSend(code);
        log(code);

        code = scriptGen.getSetPropertyCode(textAreaElem,"value",msg,true);
        itsNatDoc.addCodeToSend(code);
        log(code);

        code = scriptGen.getCallMethodCode(textAreaElem,"select",null,true);
        itsNatDoc.addCodeToSend(code);
        log(code);
    }
View Full Code Here

        counterText.setData(String.valueOf(counter));       
       
        Document doc = itsNatDoc.getDocument();       
       
        Element elemParent = doc.getElementById("insertHereId");
        ScriptUtil scriptGen = itsNatDoc.getScriptUtil();
        String elemRef = scriptGen.getNodeReference(elemParent);
        ClientDocument clientDoc = itsNatEvt.getClientDocument();
        clientDoc.addCodeToSend(elemRef + ".innerHTML = '';");       
        clientDoc.addCodeToSend("alert('Currently inserted fragment removed before');");       
               
        ItsNatServlet servlet = itsNatDoc.getItsNatDocumentTemplate().getItsNatServlet()
View Full Code Here

        itsNatDoc.addCodeToSend(code.toString());
    }

    public void testChildren(Element elem,StringBuilder code)
    {
        ScriptUtil util = itsNatDoc.getScriptUtil();
        NodeList children = elem.getChildNodes();
        int len = children.getLength();
        for(int i = 0; i < len; i++)
        {
            Node child = children.item(i);
            int nodeType = child.getNodeType();
            if (nodeType == Node.TEXT_NODE) continue;
            String ref = util.getNodeReference(child);

            code.append("var node = " + ref + ";");
            code.append("if (node.nodeType != " + nodeType + ") { alert('ERROR TestComments'); throw 'ERROR'; }");
        }
    }
View Full Code Here

        ItsNatDocument itsNatDoc = null;
        Document doc = itsNatDoc.getDocument();

        HTMLInputElement inputElem = (HTMLInputElement)doc.getElementById("inputElemId");

        ScriptUtil scriptGen = itsNatDoc.getScriptUtil();

        String code;

        String msg = "A Java String transported as a JavaScript string";
        String inputElemJS = scriptGen.getNodeReference(inputElem);
        String newValue = scriptGen.getTransportableStringLiteral(msg);
        code = inputElemJS + ".value = " + newValue + ";";

        itsNatDoc.addCodeToSend(code);

        code = scriptGen.getSetPropertyCode(inputElem,"value",msg,true);
        itsNatDoc.addCodeToSend(code);

        code = scriptGen.getCallMethodCode(inputElem,"select",null,true);
        itsNatDoc.addCodeToSend(code);

/* JavaScript, quitar los comentarios para imprimir

    itsNatDoc.getNode("cn_33").value = "A Java String transported as a JavaScript string";
View Full Code Here

    public void fillTextInput(Element elem,String value)
    {
        ItsNatDocument itsNatDoc = getItsNatDocument();
        synchronized(itsNatDoc)
        {
            ScriptUtil script = itsNatDoc.getScriptUtil();
            itsNatDoc.addCodeToSend( script.getSetPropertyCode(elem,"value",value,true) );
        }

        util.sendHTMLEvent(elem,"change",true);
    }
View Full Code Here

        // Evento "click"
        ItsNatDOMStdEvent itsNatEvent = (ItsNatDOMStdEvent)evt;
        ItsNatHTMLDocument itsNatDoc = (ItsNatHTMLDocument)itsNatEvent.getItsNatDocument();

        String code;
        ScriptUtil codeGen = itsNatDoc.getScriptUtil();

        code = codeGen.getCallMethodCode(codeGen.createScriptExpr("window"),"alert",new Object[]{"First Alert"},true);
        itsNatDoc.addCodeToSend(code);

        Document doc = itsNatDoc.getDocument();
        AbstractView window = ((DocumentView)doc).getDefaultView();
        code = codeGen.getCallMethodCode(window,"alert",new Object[]{"Second Alert"},true);
        itsNatDoc.addCodeToSend(code);


        // ESTE es un caso de testeo de m�todos todav�a no p�blicos
View Full Code Here

    /**
     * Creates a new instance of TextScriptGenerator
     */
    public TextScriptGenerator(ItsNatDocument itsNatDoc)
    {
        ScriptUtil gen = itsNatDoc.getScriptUtil();
        String text = gen.encodeURIComponent(" % + < \" & � # \n ");

        itsNatDoc.addCodeToSend("if (!encodeURIComponent(decodeURIComponent(\"" + text + "\")) == \"" + text + "\") { alert('ERROR TextScriptGenerator'); throw 'ERROR'; } \n");
    }
View Full Code Here

        <P:Child id="test4childId"  P:PruebA="Valor" />
   </P:Parent>
*/

        StringBuilder code = new StringBuilder();
        ScriptUtil util = itsNatDoc.getScriptUtil();

        code.append( "try{" );

        code.append( "var elem = null;" );
        code.append( "var attr = null;" );

        Element testElem1 = doc.getElementById("test1Id");
        code.append( "elem = " + util.getNodeReference(testElem1) + ";" );
        code.append( "attr = elem.getAttributeNodeNS('http://www.w3.org/2000/svg','PruebA');");
        code.append( "if (attr == null) alert('WRONG test 1'); ");
        code.append( "else if (attr.name != 'P:PruebA') alert('WRONG test 1 (2)'); ");

        Element testChildElem1 = doc.getElementById("test1childId");
        code.append( "elem = " + util.getNodeReference(testChildElem1) + ";" );
        code.append( "if (elem.namespaceURI != 'http://www.w3.org/2000/svg') alert('WRONG test child 1'); ");
        code.append( "if (elem.tagName != 'P:Prueba') alert('WRONG test child 1 (2)'); ");

        Element testElem2 = doc.getElementById("test2Id");
        code.append( "elem = " + util.getNodeReference(testElem2) + ";" );
        code.append( "attr = elem.getAttributeNodeNS('http://prueba.org/prueba','PruebA');");
        code.append( "if (attr == null) alert('WRONG test 2'); ");
        code.append( "else if (attr.name != 'P:PruebA') alert('WRONG test 2 (2)'); ");

        Element testElem3 = doc.getElementById("test3Id");
        code.append( "elem = " + util.getNodeReference(testElem3) + ";" );
        code.append( "attr = elem.getAttributeNodeNS('http://prueba.org/prueba','PruebA');");
        code.append( "if (attr == null) alert('WRONG test 2'); ");
        code.append( "else if (attr.name != 'P:PruebA') alert('WRONG test 2 (2)'); ");

        ItsNatDocumentTemplate template = itsNatDoc.getItsNatDocumentTemplate();
        String mime = template.getMIME();
        if (mime.equals("text/html")) // testeamos el itsnat:ignorens que s�lo tiene sentido en text/html
        {
            Element testElem4 = doc.getElementById("test4Id");
            code.append( "elem = " + util.getNodeReference(testElem4) + ";" );
            code.append( "if (elem.namespaceURI == 'http://prueba.org/prueba') alert('WRONG test 4'); ");
            code.append( "if (elem.tagName.toLowerCase() != 'p:parent') alert('WRONG test 4 (2)'); ");

            Element testChildElem4 = doc.getElementById("test4childId");
            code.append( "elem = " + util.getNodeReference(testChildElem4) + ";" );
            code.append( "if (elem.namespaceURI == 'http://prueba.org/prueba') alert('WRONG test 4 child'); ");
            code.append( "if (elem.tagName.toLowerCase() != 'p:child') alert('WRONG test 4 child (2)'); ");

            code.append( "attr = elem.getAttributeNode('p:prueba');");
            code.append( "if (attr == null) alert('WRONG test 4 child (3)'); ");
View Full Code Here

        ItsNatEventDOMStateless itsNatEvt = (ItsNatEventDOMStateless)evt;
       
        ItsNatDocument itsNatDoc = itsNatEvt.getItsNatDocument();
        Document doc = itsNatDoc.getDocument();
        Element elemParent = doc.getElementById("testElemId");
        ScriptUtil scriptGen = itsNatDoc.getScriptUtil();
        String elemRef = scriptGen.getNodeReference(elemParent);
        ClientDocument clientDoc = itsNatEvt.getClientDocument();
        clientDoc.addCodeToSend(elemRef + ".innerHTML = '';");       
        clientDoc.addCodeToSend("alert('Removed current children');");       
               
        ItsNatServlet servlet = itsNatDoc.getItsNatDocumentTemplate().getItsNatServlet()
View Full Code Here

TOP

Related Classes of org.itsnat.core.script.ScriptUtil

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.