001    /*
002     * This file is part of the Echo Point Project.  This project is a
003     * collection of Components that have extended the Echo Web Application
004     * Framework Version 3.
005     *
006     * Version: MPL 1.1
007     *
008     * The contents of this file are subject to the Mozilla Public License Version
009     * 1.1 (the "License"); you may not use this file except in compliance with
010     * the License. You may obtain a copy of the License at
011     * http://www.mozilla.org/MPL/
012     *
013     * Software distributed under the License is distributed on an "AS IS" basis,
014     * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015     * for the specific language governing rights and limitations under the
016     * License.
017     */
018    
019    package echopoint.internal;
020    
021    import nextapp.echo.app.Component;
022    import nextapp.echo.app.util.Context;
023    import nextapp.echo.webcontainer.ServerMessage;
024    import nextapp.echo.webcontainer.Service;
025    import nextapp.echo.webcontainer.WebContainerServlet;
026    import nextapp.echo.webcontainer.service.JavaScriptService;
027    
028    /**
029     * Rendering peer for the {@link echopoint.internal.AbstractHtmlComponent} class.
030     *
031     * @author Rakesh 2008-03-22
032     * @version $Id: AbstractHtmlComponentPeer.java 86 2008-11-09 14:44:29Z sptrakesh $
033     */
034    public class AbstractHtmlComponentPeer extends AbstractContainerPeer
035    {
036      /** The name of the component for which this class is a peer. */
037      private static final String COMPONENT_NAME = AbstractHtmlComponent.class.getName();
038    
039      /** The JS service files to load. */
040      private static final String[] SERVICE_FILES =
041      {
042        "resource/js/Application.HtmlComponent.js",
043        "resource/js/Sync.AbstractHtmlComponent.js"
044      };
045    
046      /** The service for the client side peer for this component. */
047      private static final Service COMPONENT_SERVICE =
048        JavaScriptService.forResources( COMPONENT_NAME, SERVICE_FILES );
049    
050      /** Register the services */
051      static
052      {
053        WebContainerServlet.getServiceRegistry().add( COMPONENT_SERVICE );
054      }
055    
056      /**
057       * {@inheritDoc}
058       * @see nextapp.echo.webcontainer.AbstractComponentSynchronizePeer#init
059       */
060      @Override
061      public void init( final Context context, final  Component component )
062      {
063        super.init( context, component );
064        final ServerMessage serverMessage =
065          (ServerMessage) context.get( ServerMessage.class );
066        serverMessage.addLibrary( COMPONENT_NAME );
067      }
068    
069      /**
070       * {@inheritDoc}
071       * @see nextapp.echo.webcontainer.AbstractComponentSynchronizePeer#getComponentClass
072       */
073      @Override
074      public Class getComponentClass()
075      {
076        return AbstractHtmlComponent.class;
077      }
078    
079      /**
080       * {@inheritDoc}
081       * @see nextapp.echo.webcontainer.AbstractComponentSynchronizePeer#getClientComponentType
082       */
083      public String getClientComponentType( final boolean shortType )
084      {
085        return COMPONENT_NAME;
086      }
087    }