Jive API (4.5.7.0) Core Javadocs

com.jivesoftware.community.widget
Class BaseWidget

java.lang.Object
  extended by com.jivesoftware.community.widget.BaseWidget
All Implemented Interfaces:
com.jivesoftware.base.profiling.Profileable, com.jivesoftware.community.widget.JiveWidget, Widget

public abstract class BaseWidget
extends java.lang.Object
implements Widget, com.jivesoftware.base.profiling.Profileable

An abstract implementation of the Widget interface this class provides subclasses with built in support for processing a freemarker template and internationalization. It is recommended that all Widgets extend this base class, rather than implementing the Widget interface directly.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.jivesoftware.community.widget.Widget
Widget.ContainerSize
 
Field Summary
static java.lang.String ERROR_TEMPLATE_FILE
           
protected  com.jivesoftware.community.favorites.FavoriteManager favoriteManager
           
static java.lang.String FEATURE_DISABLED_FILE
           
protected  com.jivesoftware.community.web.struts.JiveFreemarkerManager freemarkerManager
           
protected  com.jivesoftware.community.license.JiveLicenseManager licenseManager
           
protected static org.apache.log4j.Logger log
           
static java.lang.String MARKUP_ENABLED
           
static int MORE_RESULTS_COUNT
           
static com.jivesoftware.base.profiling.ObservationScope PROFILE_SCOPE
           
protected  com.jivesoftware.base.profiling.ProfilerManager profilerManager
           
 
Constructor Summary
BaseWidget()
           
 
Method Summary
protected  void addError(java.util.Map<java.lang.String,java.lang.Object> properties, java.lang.String localizedString)
           
protected  java.lang.String applyFreemarkerTemplate(com.jivesoftware.community.widget.WidgetContext widgetContext, Widget.ContainerSize size, java.lang.String templateName)
          Processes the specified template file and returns a String containing the content of the template file.
 boolean equals(java.lang.Object o)
           
protected  JiveContainer getContainerFromContext(com.jivesoftware.community.widget.WidgetContext widgetContext)
          If this widget is a community, project, or social group widget, returns the community, project, or group.
 java.lang.String getCssClass()
          Returns a custom css class for the widget, or null if a custom css class does not exist.
 java.lang.String getCustomTitle()
          Returns a custom title that will override the default title when the widget is rendered, or null if a custom title does not exist.
 java.lang.String getFeedURL()
          Returns the location of a feed for this widget or null if no feed exists.
 long getID()
           
 java.lang.String getLocalizedString(java.lang.String key, com.jivesoftware.community.widget.WidgetContext widgetContext)
           
 java.lang.String getName()
          Profileable implementation.
 com.jivesoftware.base.profiling.ObservationScope getScope()
          Profileable implementation.
 java.lang.String getType()
           
 long getWidgetFrameID()
          Returns the ID of the widget frame containing this widget.
 int hashCode()
           
 boolean isEnabled(com.jivesoftware.community.widget.WidgetContext widgetContext)
          Gives widgets the ability to determine whether or not the widget should be available for end users / administrators to add in a specific widget context.
protected  boolean isModuleAvailable(java.lang.String name, com.jivesoftware.community.widget.WidgetContext widgetContext)
           
 boolean isPropertyEnabled(com.jivesoftware.community.widget.WidgetContext widgetContext, java.lang.String propName)
          Gives widgets the ability to determine whether or not a specific property should be available during editing of the widget by end users / administrators.
 boolean isRefreshable()
          Gives widgets the ability to determine whether or not they can be reloaded via an asynchrounous refresh.
protected  java.util.Map<java.lang.String,java.lang.Object> loadProperties(com.jivesoftware.community.widget.WidgetContext widgetContext, Widget.ContainerSize size)
          Responsible for parsing the request URL and adding the necessary parameters to the freemarker context.
protected  JiveActionSupport loadRemoteAction(com.jivesoftware.community.widget.WidgetContext widgetContext, JiveContext jiveContext)
           
protected static java.lang.String processFreemarkerTemplate(freemarker.template.Configuration config, freemarker.template.SimpleHash model, java.lang.String templateName, java.util.Locale locale, java.util.TimeZone timeZone)
          Processes the specified template file and returns a String containing the content of the template file.
 void setCustomTitle(java.lang.String customTitle)
          Sets a custom title that will override the default title when the widget is rendered.
 void setFavoriteManager(com.jivesoftware.community.favorites.FavoriteManager favoriteManager)
           
 void setFreemarkerManager(com.jivesoftware.community.web.struts.JiveFreemarkerManager mgr)
           
 void setID(long ID)
          Sets the internal id of the widget
 void setLicenseManager(com.jivesoftware.community.license.JiveLicenseManager licenseManager)
           
 void setProfilerManager(com.jivesoftware.base.profiling.ProfilerManager profileManager)
           
 void setWidgetFrameID(long widgetFrameID)
          The id of the widget frame that this widget is contained in.
protected  java.lang.String stripHTMLTags(java.lang.String html)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jivesoftware.community.widget.Widget
getDescription, getTitle, render
 

Field Detail

log

protected static final org.apache.log4j.Logger log

PROFILE_SCOPE

public static final com.jivesoftware.base.profiling.ObservationScope PROFILE_SCOPE

MARKUP_ENABLED

public static final java.lang.String MARKUP_ENABLED
See Also:
Constant Field Values

FEATURE_DISABLED_FILE

public static final java.lang.String FEATURE_DISABLED_FILE
See Also:
Constant Field Values

ERROR_TEMPLATE_FILE

public static final java.lang.String ERROR_TEMPLATE_FILE
See Also:
Constant Field Values

MORE_RESULTS_COUNT

public static final int MORE_RESULTS_COUNT
See Also:
Constant Field Values

freemarkerManager

protected com.jivesoftware.community.web.struts.JiveFreemarkerManager freemarkerManager

licenseManager

protected com.jivesoftware.community.license.JiveLicenseManager licenseManager

favoriteManager

protected com.jivesoftware.community.favorites.FavoriteManager favoriteManager

profilerManager

protected com.jivesoftware.base.profiling.ProfilerManager profilerManager
Constructor Detail

BaseWidget

public BaseWidget()
Method Detail

setFreemarkerManager

public void setFreemarkerManager(com.jivesoftware.community.web.struts.JiveFreemarkerManager mgr)

setProfilerManager

public void setProfilerManager(com.jivesoftware.base.profiling.ProfilerManager profileManager)

setLicenseManager

public void setLicenseManager(com.jivesoftware.community.license.JiveLicenseManager licenseManager)

setFavoriteManager

public void setFavoriteManager(com.jivesoftware.community.favorites.FavoriteManager favoriteManager)

getID

public final long getID()
Specified by:
getID in interface com.jivesoftware.community.widget.JiveWidget

getType

public java.lang.String getType()
Specified by:
getType in interface com.jivesoftware.community.widget.JiveWidget

setID

public final void setID(long ID)
Description copied from interface: Widget
Sets the internal id of the widget

Specified by:
setID in interface Widget
Parameters:
ID - the internal id of the widget

getWidgetFrameID

public long getWidgetFrameID()
Description copied from interface: Widget
Returns the ID of the widget frame containing this widget.

Specified by:
getWidgetFrameID in interface Widget
Returns:
the ID of the widget frame.

setWidgetFrameID

public void setWidgetFrameID(long widgetFrameID)
Description copied from interface: Widget
The id of the widget frame that this widget is contained in.

Specified by:
setWidgetFrameID in interface Widget

getCustomTitle

public final java.lang.String getCustomTitle()
Description copied from interface: Widget
Returns a custom title that will override the default title when the widget is rendered, or null if a custom title does not exist.

Specified by:
getCustomTitle in interface Widget
Returns:
a custom title that will override the default title when the widget is rendered, or null if a custom title does not exist.

setCustomTitle

public final void setCustomTitle(java.lang.String customTitle)
Description copied from interface: Widget
Sets a custom title that will override the default title when the widget is rendered.

Specified by:
setCustomTitle in interface Widget
Parameters:
customTitle - a custom title that will override the default title when the widget is rendered.

getCssClass

public java.lang.String getCssClass()
Description copied from interface: Widget
Returns a custom css class for the widget, or null if a custom css class does not exist.

Specified by:
getCssClass in interface Widget
Returns:
a custom css class for the widget, or null if a custom css class does not exist.

getFeedURL

public java.lang.String getFeedURL()
Description copied from interface: Widget
Returns the location of a feed for this widget or null if no feed exists.

Specified by:
getFeedURL in interface Widget
Returns:
the location of a feed for this widget or null if no feed exists.

isEnabled

public boolean isEnabled(com.jivesoftware.community.widget.WidgetContext widgetContext)
Description copied from interface: Widget
Gives widgets the ability to determine whether or not the widget should be available for end users / administrators to add in a specific widget context.

Specified by:
isEnabled in interface Widget
Parameters:
widgetContext - the context the widget would be rendered in
Returns:
true if the widget should be available to choose, false otherwise.

isPropertyEnabled

public boolean isPropertyEnabled(com.jivesoftware.community.widget.WidgetContext widgetContext,
                                 java.lang.String propName)
Description copied from interface: Widget
Gives widgets the ability to determine whether or not a specific property should be available during editing of the widget by end users / administrators.

Specified by:
isPropertyEnabled in interface Widget
Parameters:
widgetContext - the context the widget would be rendered in
propName - the property to enable for editing
Returns:
true it the property should be editable, false otherwise.

getName

public java.lang.String getName()
Profileable implementation.

Specified by:
getName in interface com.jivesoftware.base.profiling.Profileable
Returns:

getScope

public com.jivesoftware.base.profiling.ObservationScope getScope()
Profileable implementation.

Specified by:
getScope in interface com.jivesoftware.base.profiling.Profileable
Returns:

applyFreemarkerTemplate

protected java.lang.String applyFreemarkerTemplate(com.jivesoftware.community.widget.WidgetContext widgetContext,
                                                   Widget.ContainerSize size,
                                                   java.lang.String templateName)
Processes the specified template file and returns a String containing the content of the template file.

Parameters:
widgetContext - the widget context used to render this widget
size - the ContainerSize to render
templateName - name of the template
Returns:
the content of the specified template file

processFreemarkerTemplate

protected static java.lang.String processFreemarkerTemplate(freemarker.template.Configuration config,
                                                            freemarker.template.SimpleHash model,
                                                            java.lang.String templateName,
                                                            java.util.Locale locale,
                                                            java.util.TimeZone timeZone)
Processes the specified template file and returns a String containing the content of the template file.

Parameters:
config - the freemarker configuration
model - used for the freemarker context
templateName - name of the template
locale - the locale of the template or null for the default locale
timeZone - the timeZone of the template or null for the default timezone
Returns:
the content of the specified template file

loadProperties

protected java.util.Map<java.lang.String,java.lang.Object> loadProperties(com.jivesoftware.community.widget.WidgetContext widgetContext,
                                                                          Widget.ContainerSize size)
Responsible for parsing the request URL and adding the necessary parameters to the freemarker context. The parameters will then be available for use in the freemarker template.

Parameters:
widgetContext - the widget context used to render the widget
size - the ContainerSize to render
Returns:
a map containing all the necessary parameters for the requested options

isModuleAvailable

protected boolean isModuleAvailable(java.lang.String name,
                                    com.jivesoftware.community.widget.WidgetContext widgetContext)

getLocalizedString

public java.lang.String getLocalizedString(java.lang.String key,
                                           com.jivesoftware.community.widget.WidgetContext widgetContext)

isRefreshable

public boolean isRefreshable()
Description copied from interface: Widget
Gives widgets the ability to determine whether or not they can be reloaded via an asynchrounous refresh. This would be used for widgets where content changes frequently enough that the user could reload the widget individually, rather than do a full page refresh.

Specified by:
isRefreshable in interface Widget
Returns:
true if the widget can be refresheed asynchronously

stripHTMLTags

protected java.lang.String stripHTMLTags(java.lang.String html)

addError

protected void addError(java.util.Map<java.lang.String,java.lang.Object> properties,
                        java.lang.String localizedString)

loadRemoteAction

protected JiveActionSupport loadRemoteAction(com.jivesoftware.community.widget.WidgetContext widgetContext,
                                             JiveContext jiveContext)

getContainerFromContext

protected JiveContainer getContainerFromContext(com.jivesoftware.community.widget.WidgetContext widgetContext)
If this widget is a community, project, or social group widget, returns the community, project, or group. Otherwise returns null.

Parameters:
widgetContext - the widgetContext representing where the widget is displayed
Returns:
the container from this context or null if this widget isn't a community, project, or social group widget

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

Jive Product Page

Copyright © 1999-2007 Jive Software.