Class Widget
- All Implemented Interfaces:
HtmlWidget
- Direct Known Subclasses:
MenuItemWidget
,PoweredByApache
,PoweredByJuneau
Widgets must provide one of the following public constructors:
public Widget();public Widget(ContextProperties);
Widgets can be defined as inner classes of REST resource classes.
See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected FileFinder
getFileFinder
(RestRequest req) Returns the file finder to use for finding files on the file system.getHtml
(RestRequest req, RestResponse res) Resolves the HTML content for this widget.getHtml
(VarResolverSession session) Resolves the HTML content for this widget.getName()
The widget key.getScript
(RestRequest req, RestResponse res) Resolves any Javascript that should be added to the<head>/<script> element.getScript
(VarResolverSession session) Resolves any Javascript that should be added to the<head>/<script> element.getStyle
(RestRequest req, RestResponse res) Resolves any CSS styles that should be added to the<head>/<style> element.getStyle
(VarResolverSession session) Resolves any CSS styles that should be added to the<head>/<style> element.protected String
loadHtml
(RestRequest req, String name) Loads the specified HTML file and strips HTML comments from the file.protected String
loadHtmlWithVars
(RestRequest req, RestResponse res, String name) Same asloadHtml(RestRequest,String)
but replaces request-time SVL variables.protected String
loadScript
(RestRequest req, String name) Loads the specified javascript file and strips any Javascript comments from the file.protected String
loadScriptWithVars
(RestRequest req, RestResponse res, String name) Same asloadScript(RestRequest,String)
but replaces request-time SVL variables.protected String
loadStyle
(RestRequest req, String name) Loads the specified CSS file and strips CSS comments from the file.protected String
loadStyleWithVars
(RestRequest req, RestResponse res, String name) Same asloadStyle(RestRequest,String)
but replaces request-time SVL variables.
-
Constructor Details
-
Widget
public Widget()
-
-
Method Details
-
getName
The widget key.(i.e. The variable name inside the
"$W{...}" variable).The returned value must not be
null .If not overridden, the default value is the class simple name.
- Specified by:
getName
in interfaceHtmlWidget
- Returns:
- The widget key.
-
getHtml
Description copied from interface:HtmlWidget
Resolves the HTML content for this widget.A returned value of
null will cause nothing to be added to the page.- Specified by:
getHtml
in interfaceHtmlWidget
- Parameters:
session
- The current serializer session.- Returns:
- The HTML content of this widget.
-
getScript
Description copied from interface:HtmlWidget
Resolves any Javascript that should be added to the<head>/<script> element.A returned value of
null will cause nothing to be added to the page.- Specified by:
getScript
in interfaceHtmlWidget
- Parameters:
session
- The current serializer session.- Returns:
- The Javascript needed by this widget.
-
getStyle
Description copied from interface:HtmlWidget
Resolves any CSS styles that should be added to the<head>/<style> element.A returned value of
null will cause nothing to be added to the page.- Specified by:
getStyle
in interfaceHtmlWidget
- Parameters:
session
- The current serializer session.- Returns:
- The CSS styles needed by this widget.
-
getHtml
Resolves the HTML content for this widget.A returned value of
null will cause nothing to be added to the page.- Parameters:
req
- The HTTP request object.res
- The current HTTP response.- Returns:
- The HTML content of this widget.
-
getScript
Resolves any Javascript that should be added to the<head>/<script> element.A returned value of
null will cause nothing to be added to the page.- Parameters:
req
- The HTTP request object.res
- The current HTTP response.- Returns:
- The Javascript needed by this widget.
-
getStyle
Resolves any CSS styles that should be added to the<head>/<style> element.A returned value of
null will cause nothing to be added to the page.- Parameters:
req
- The HTTP request object.res
- The current HTTP response.- Returns:
- The CSS styles needed by this widget.
-
getFileFinder
Returns the file finder to use for finding files on the file system.- Parameters:
req
- The HTTP request object.- Returns:
- The file finder to used for finding files on the file system.
-
loadScript
Loads the specified javascript file and strips any Javascript comments from the file.Comments are assumed to be Java-style block comments:
"/*" .- Parameters:
req
- The HTTP request object.name
- Name of the desired resource.- Returns:
- The resource converted to a string, or
null if the resource could not be found.
-
loadScriptWithVars
protected String loadScriptWithVars(RestRequest req, RestResponse res, String name) throws IOException Same asloadScript(RestRequest,String)
but replaces request-time SVL variables.See Also:
- Parameters:
req
- The current HTTP request.res
- The current HTTP response.name
- Name of the desired resource.- Returns:
- The resource converted to a string, or
null if the resource could not be found. - Throws:
IOException
- Thrown by underlying stream.
-
loadStyle
Loads the specified CSS file and strips CSS comments from the file.Comments are assumed to be Java-style block comments:
"/*" .- Parameters:
req
- The HTTP request object.name
- Name of the desired resource.- Returns:
- The resource converted to a string, or
null if the resource could not be found.
-
loadStyleWithVars
protected String loadStyleWithVars(RestRequest req, RestResponse res, String name) throws IOException Same asloadStyle(RestRequest,String)
but replaces request-time SVL variables.See Also:
- Parameters:
req
- The current HTTP request.res
- The current HTTP response.name
- Name of the desired resource.- Returns:
- The resource converted to a string, or
null if the resource could not be found. - Throws:
IOException
- Thrown by underlying stream.
-
loadHtml
Loads the specified HTML file and strips HTML comments from the file.Comment are assumed to be
"<!-- -->" code blocks.- Parameters:
req
- The HTTP request object.name
- Name of the desired resource.- Returns:
- The resource converted to a string, or
null if the resource could not be found.
-
loadHtmlWithVars
protected String loadHtmlWithVars(RestRequest req, RestResponse res, String name) throws IOException Same asloadHtml(RestRequest,String)
but replaces request-time SVL variables.See Also:
- Parameters:
req
- The current HTTP request.res
- The current HTTP response.name
- Name of the desired resource.- Returns:
- The resource converted to a string, or
null if the resource could not be found. - Throws:
IOException
- Thrown by underlying stream.
-