1 package com.atlassian.plugin.web.model;
2
3 import java.io.IOException;
4 import java.io.Writer;
5 import java.util.Map;
6
7 /**
8 * The module that is responsive for providing the raw content for a Web Panel.
9 * Whatever is returned by {@link #getHtml(java.util.Map)} is inserted into the
10 * host application's page, so it has to be valid HTML.
11 *
12 * @see com.atlassian.plugin.web.descriptors.DefaultWebPanelModuleDescriptor#getModule()
13 * @since 2.5.0
14 */
15 public interface WebPanel
16 {
17 /**
18 * Returns the HTML that will be placed in the host application's page.
19 *
20 * @param context the contextual information that can be used during
21 * rendering. Context elements are not standardized and are
22 * application-specific, so refer to your application's documentation to
23 * learn what is available.
24 * @return the HTML that will be placed in the host application's page.
25 */
26 String getHtml(Map<String, Object> context);
27
28 /**
29 * Writes the HTML for this panel into the supplied writer. This method should be
30 * preferred over {@link #getHtml} for large panels or for applications that make
31 * frequent use of panels, to avoid creating a lot of large garbage buffer strings.
32 *
33 * @param writer the writer to append the panel output to
34 * @param context the contextual information that can be used during
35 * rendering. Context elements are not standardized and are
36 * application-specific, so refer to your application's documentation to
37 * learn what is available.
38 * @throws IOException if there is some problem writing to the supplied writer
39 * @since 2.11
40 */
41 void writeHtml(Writer writer, Map<String, Object> context) throws IOException;
42 }