Class HTMLPageAssembler

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class HTMLPageAssembler
    extends TypedAtomicActor

    HTMLPageAssembler reads contents from its ports and appends them into the corresponding parts in the template file that must satisfy the following requirement: for each port, there must be a corresponding DOM object whose ID is the same as the port name in the template file, or in the content provided to another port that is created before this port.

    HTMLPageAssembler processes the ports in the order that they are added to it. Each port can consists of a single or multiple channels. In the latter case, contents from multiple channels are appended in the order that they are connected to this port.

    The content for a channel can be a string or an array of strings. HTML scripts, such as JavaScript, can also be part of the content. For a long content, it is better to first store the content in a separated file, then read this file using the FileReader actor to provide the content to the port. A demo is available at $PTII/ptolemy/vergil/basic/export/html/demo/PageAssembler/PageAssembler.xml. If the content is provided through a StringConst actor, only the tags defined in the standard Java library (javax.swing.text.html.HTML.Tag) can be supported. If the content is read from a file, then all valid HTML tags can be supported. Unknown tags are ignored without throwing any exceptions.

    The content of the final HTML page is sent to the output port and saved to a file if specified.

    For more information, please refer to "Manual for Creating Web Pages" in Ptolemy.

    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Baobing (Brian) Wang, Elizabeth Latronico
    Pt.AcceptedRating:
    Yellow (bwang)
    Pt.ProposedRating:
    Yellow (bwang)
    • Field Detail

      • htmlTitle

        public StringParameter htmlTitle
        The title of the generated HTML page. The default value is the string "Page Generated by HTMLPageAssembler".
      • output

        public TypedIOPort output
        The output port, which is of type String.
      • outputFile

        public FileParameter outputFile
        The file to save the content of the generated page. The default value is "result.html".
      • saveToFile

        public Parameter saveToFile
        Specify whether the content of the generated page should be save to a separated file. The default value is a boolean with the value false.
      • template

        public FileParameter template
        The template file. The default value is "template.html".
    • Constructor Detail

      • HTMLPageAssembler

        public HTMLPageAssembler​(CompositeEntity container,
                                 java.lang.String name)
                          throws NameDuplicationException,
                                 IllegalActionException
        Create a new actor in the specified container with the specified name. The name must be unique within the container or an exception is thrown. The container argument must not be null, or a NullPointerException will be thrown.
        Parameters:
        container - The container.
        name - The name of this actor within the container.
        Throws:
        IllegalActionException - If this actor cannot be contained by the proposed container (see the setContainer() method).
        NameDuplicationException - If the name coincides with an entity already in the container.