Reference a WebFigure Using an Embeddable String

If you do not want to use the WebFigure JSP tag to display the figure, or want a servlet to display it directly, use this method to get a snippet of HTML that will embed an iFrame containing the figure in another page.

  1. Create an instance of the WebFigureHtmlGenerator class using either a scriptlet or a servlet. The constructor for this class has three overloads:

    //The import statement needed to invoke this class
    import com.mathworks.toolbox.javabuilder.webfigures.WebFigureHtmlGenerator;
    
    
    //WebFigureHtmlGenerator(HttpServletRequest servletRequest)
    //This overload just takes the ServletRequest and will map the 
    //  embed string to the same server and assumes that the 
    //  WebFiguresService was mapped to "WebFigures"
    WebFigureHtmlGenerator htmlGenerator = 
    			WebFigureHtmlGenerator(servletRequest);
    
    //OR
    
    //WebFigureHtmlGenerator(String webFigureServletNameMapping, HttpServletRequest 
    //     servletRequest)
    //This overload takes the ServletRequest and the name that 
    //  the WebFigureServlet was mapped to.  
    //It will reference this servlet on the same server 
    WebFigureHtmlGenerator htmlGenerator = 
    			WebFigureHtmlGenerator("SomeServletMappingName", servletRequest);
    
    //OR
    
    //WebFigureHtmlGenerator(String absolutePathName)
    //This overload takes the absolute URL path to a server that has 
    // WebFiguresService running.
    //This would be used if you have a cluster of servers that are all running 
    // WebFigureService 
    // a load balancer (all sharing cache state). Use 
    // this parameter to reference that base load balancer URL.
    WebFigureHtmlGenerator htmlGenerator = 
    			WebFigureHtmlGenerator("http://someLoadBalancer/someWebApplication/
                                                  WebFigureServletNameMapping");
    

  2. Call the method to get the embedded string (getFigureEmbedString). Use this table to specify appropriate attributes:

    Attribute NameAttribute TypeDescriptionOptionalDefault Value
    figureWebFigureWebFigure for which you want to create the embedded string.YesThis is used to determine the figure's default height and width if no other is provided .
    nameString Name used when attaching your figure to a cache. Case sensitive.NoNot optional
    scopeStringScope that figure has been saved to (application or session).NoNot optional
    styleStringEmbedded attribute you want attached to the iFrame.YesIf this is not passed, a basic iFrame is used.
    heightStringHeight of the iFrame that will be embedded.YesIf this is not passed, the height of the WebFigure is retrieved from cache. If the WebFigure cannot be found, the MATLAB® default height for a figure (420) is used.
    widthStringWidth of the iFrame that will be embedded.YesIf this is not passed, the width of the WebFigure is retrieved from cache. If the WebFigure cannot be found, the MATLAB default width for a figure (560) is used.
Was this topic helpful?