Class WpdExtendlet

  • All Implemented Interfaces:
    org.zkoss.web.util.resource.Extendlet

    public class WpdExtendlet
    extends java.lang.Object
    The extendlet to handle WPD (Widget Package Descriptor).

    Note: it assumes all JavaScript files are encoded in UTF-8.

    Bootstrapping

    In additions to loading, WPD allows to bootstrap a JavaScript codes by specifying a parameter called main. For example, the following link

    <script type="text/javascript" src="/zkdemo/zkau/web/js/zk.wpd?main=foo.Go&what=12&more=xy" charset="UTF-8">
    </script>
    will cause the following to be executed
    zk.load('foo', function() {foo.Go.main({what: '123', more: 'xy'})});
    In other words, it loads the package called foo, and then invoke the main method of the foo.Go class.
    Since:
    5.0.0
    Author:
    tomyeh
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String SOURCE_MAP_JAVASCRIPT_PATH  
      • Fields inherited from interface org.zkoss.web.util.resource.Extendlet

        ALLOW_DIRECT_INCLUDE
    • Constructor Summary

      Constructors 
      Constructor Description
      WpdExtendlet()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String getDeviceType()
      Returns the device type for this WpdExtendlet.
      boolean getFeature​(int feature)  
      ScriptManager getScriptManager()  
      void init​(org.zkoss.web.util.resource.ExtendletConfig config)  
      boolean isDebugJS()
      Returns whether to generate JS files that is easy to debug.
      protected byte[] mergeJavaScript​(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, java.lang.String pkgTo, byte[] data)
      Merges the JavaScript code of the mergeable packages defined in LanguageDefinition.getMergedJavaScriptPackages(java.lang.String).
      protected byte[] retrieve​(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, java.lang.String path)
      Retrieves the content of the given path.
      void service​(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, java.lang.String path)  
      void setDebugJS​(boolean debugJS)
      Sets whether to generate JS files that is easy to debug.
      java.util.List<java.lang.String> splitSourceMapJsPathIfAny​(java.lang.String path)
      Internal use only (since 10.0.0)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SOURCE_MAP_JAVASCRIPT_PATH

        public static final java.lang.String SOURCE_MAP_JAVASCRIPT_PATH
        See Also:
        Constant Field Values
    • Constructor Detail

      • WpdExtendlet

        public WpdExtendlet()
    • Method Detail

      • init

        public void init​(org.zkoss.web.util.resource.ExtendletConfig config)
      • service

        public void service​(jakarta.servlet.http.HttpServletRequest request,
                            jakarta.servlet.http.HttpServletResponse response,
                            java.lang.String path)
                     throws jakarta.servlet.ServletException,
                            java.io.IOException
        Throws:
        jakarta.servlet.ServletException
        java.io.IOException
      • retrieve

        protected byte[] retrieve​(jakarta.servlet.http.HttpServletRequest request,
                                  jakarta.servlet.http.HttpServletResponse response,
                                  java.lang.String path)
                           throws jakarta.servlet.ServletException,
                                  java.io.IOException
        Retrieves the content of the given path.
        Throws:
        jakarta.servlet.ServletException
        java.io.IOException
        Since:
        5.0.4
      • getDeviceType

        protected java.lang.String getDeviceType()
        Returns the device type for this WpdExtendlet.

        Default: ajax. The derived class might override it to implement a Wpd extendlet for other devices.

        Since:
        5.0.4
      • mergeJavaScript

        protected byte[] mergeJavaScript​(jakarta.servlet.http.HttpServletRequest request,
                                         jakarta.servlet.http.HttpServletResponse response,
                                         java.lang.String pkgTo,
                                         byte[] data)
                                  throws jakarta.servlet.ServletException,
                                         java.io.IOException
        Merges the JavaScript code of the mergeable packages defined in LanguageDefinition.getMergedJavaScriptPackages(java.lang.String).
        Throws:
        jakarta.servlet.ServletException
        java.io.IOException
        Since:
        5.0.4.
      • splitSourceMapJsPathIfAny

        public java.util.List<java.lang.String> splitSourceMapJsPathIfAny​(java.lang.String path)
                                                                   throws java.lang.Exception
        Internal use only (since 10.0.0)
        Throws:
        java.lang.Exception
      • setDebugJS

        public void setDebugJS​(boolean debugJS)
        Sets whether to generate JS files that is easy to debug.
      • isDebugJS

        public boolean isDebugJS()
        Returns whether to generate JS files that is easy to debug.
      • getFeature

        public boolean getFeature​(int feature)
        Specified by:
        getFeature in interface org.zkoss.web.util.resource.Extendlet