001    package echopoint.jquery;
002    
003    import nextapp.echo.webcontainer.Service;
004    import nextapp.echo.webcontainer.WebContainerServlet;
005    import nextapp.echo.webcontainer.ServerMessage;
006    import nextapp.echo.webcontainer.service.JavaScriptService;
007    import nextapp.echo.app.util.Context;
008    import nextapp.echo.app.Component;
009    
010    /**
011     * Rendering peer for the {@link echopoint.jquery.SlidingMenu} component.
012     *
013     * @author Hans Holmlund 2009-05-11
014     * @version $Id: SlidingMenuPeer.java 189 2009-05-11 13:46:42Z hansho $
015     */
016    public class SlidingMenuPeer extends JQueryAbstractPeer {
017    
018    
019        /** The component name for which this class is a peer. */
020        private static final String COMPONENT_NAME = SlidingMenu.class.getName();
021    
022    
023        /** The JS service files to load. */
024        private static final String[] SERVICE_FILES =
025                {
026                        "resource/js/jquery/Application.SlidingMenu.js",
027                        "resource/js/jquery/Sync.SlidingMenu.js"
028                };
029    
030    
031        /** The associated client-side JavaScript module <code>Service</code>. */
032        private static final Service COMPONENT_SERVICE =
033                JavaScriptService.forResources(COMPONENT_NAME, SERVICE_FILES);
034    
035        static {
036            WebContainerServlet.getServiceRegistry().add(COMPONENT_SERVICE);
037        }
038    
039        /**
040         * @see nextapp.echo.webcontainer.ComponentSynchronizePeer#getClientComponentType(boolean)
041         */
042        public String getClientComponentType(boolean shortType) {
043            return COMPONENT_NAME;
044        }
045    
046        /**
047         * @see nextapp.echo.webcontainer.ComponentSynchronizePeer#getComponentClass()
048         */
049        public Class getComponentClass() {
050            return SlidingMenu.class;
051        }
052    
053        /**
054         * @see nextapp.echo.webcontainer.ComponentSynchronizePeer#init(nextapp.echo.app.util.Context, nextapp.echo.app.Component)
055         */
056    
057    
058        public void init(final Context context, final Component component) {
059            super.init(context, component);
060            final ServerMessage serverMessage =
061                    (ServerMessage) context.get(ServerMessage.class);
062            serverMessage.addLibrary(COMPONENT_NAME);
063        }
064    
065    }