Package test.svg

Source Code of test.svg.TestSVGIncludeFragment

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package test.svg;

import java.io.Serializable;
import org.itsnat.core.tmpl.ItsNatDocFragmentTemplate;
import org.itsnat.core.ItsNatDocument;
import org.itsnat.core.ItsNatServlet;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.Element;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.EventTarget;

/**
*
* @author jmarranz
*/
public class TestSVGIncludeFragment implements EventListener,Serializable
{
    protected ItsNatDocument itsNatDoc;
    protected Element includeFragElem;

    public TestSVGIncludeFragment(ItsNatDocument itsNatDoc)
    {
        this.itsNatDoc = itsNatDoc;

        Document doc = itsNatDoc.getDocument();
        this.includeFragElem = doc.getElementById("includeFragId");
        ((EventTarget)includeFragElem).addEventListener("click",this,false);
    }

    public void handleEvent(Event evt)
    {
        ItsNatServlet servlet = itsNatDoc.getItsNatDocumentTemplate().getItsNatServlet();
        ItsNatDocFragmentTemplate template = servlet.getItsNatDocFragmentTemplate("test_svg_fragment_2");
        DocumentFragment fragment = template.loadDocumentFragment(itsNatDoc);
        Element rootElem = itsNatDoc.getDocument().getDocumentElement();
        rootElem.appendChild(fragment);
    }
}
TOP

Related Classes of test.svg.TestSVGIncludeFragment

TOP
Copyright © 2018 www.massapi.com. 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.