001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.html;
014
015import org.apache.juneau.svl.*;
016
017/**
018 * Defines an interface for resolvers of <js>"$W{...}"</js> string variables.
019 *
020 * <p>
021 * Widgets must provide one of the following public constructors:
022 * <ul>
023 *    <li><code><jk>public</jk> Widget();</code>
024 * </ul>
025 *
026 * <p>
027 * Widgets can be defined as inner classes of REST resource classes.
028 *
029 * <h5 class='section'>See Also:</h5><ul>
030 *    <li class='link'><a class="doclink" href="../../../../index.html#jrs.HtmlWidgets">Widgets</a>
031 *    <li class='link'><a class="doclink" href="../../../../index.html#jm.HtmlDetails">HTML Details</a>
032 * </ul>
033 */
034public interface HtmlWidget {
035
036   /**
037    * The name for this widget.
038    *
039    * @return A unique identifying name for this widget.
040    */
041   public String getName();
042
043   /**
044    * Resolves the HTML content for this widget.
045    *
046    * <p>
047    * A returned value of <jk>null</jk> will cause nothing to be added to the page.
048    *
049    * @param session The current serializer session.
050    * @return The HTML content of this widget.
051    */
052   public String getHtml(VarResolverSession session);
053
054   /**
055    * Resolves any Javascript that should be added to the <xt>&lt;head&gt;/&lt;script&gt;</xt> element.
056    *
057    * <p>
058    * A returned value of <jk>null</jk> will cause nothing to be added to the page.
059    *
060    * @param session The current serializer session.
061    * @return The Javascript needed by this widget.
062    */
063   public String getScript(VarResolverSession session);
064
065   /**
066    * Resolves any CSS styles that should be added to the <xt>&lt;head&gt;/&lt;style&gt;</xt> element.
067    *
068    * <p>
069    * A returned value of <jk>null</jk> will cause nothing to be added to the page.
070    *
071    * @param session The current serializer session.
072    * @return The CSS styles needed by this widget.
073    */
074   public String getStyle(VarResolverSession session);
075}