Style Intelligence v12.0

inetsoft.sree
Class BasicReplet

java.lang.Object
  extended by inetsoft.sree.BasicReplet
All Implemented Interfaces:
Replet
Direct Known Subclasses:
TemplateReplet

public abstract class BasicReplet
extends Object
implements Replet

This class should be used as the base class of all user implemented replet classes. It provides a higher level API than the Replet interface and hides some of the coordination between methods.

Actions or hyperlinks can be added to an element. If the element is a table, the action can be associated with an entire row or column, or a single cell. The cell is specified by inetsoft.report.event.EventPoint object. Use one of the factory method (row, column and cell) to create a event location for a row, column, or a specific cell.

For elements in section bands, the row number is the band the row corresponds to.


Field Summary
protected  UserCatalog catalog
           
protected  boolean destroyed
           
protected  Vector fieldelems
           
protected  RepletRequest lastreq
           
protected  Principal principal
           
 
Fields inherited from interface inetsoft.sree.Replet
DESIGN_MODE, RUN_MODE
 
Constructor Summary
BasicReplet()
           
 
Method Summary
 void addFormLink(String form, String replet)
          Add a hyperlink from a form to a replet.
 void addLink(String eid, Point item, String toeid, int row)
          Add a hyperlink from one element to another element inside the same report.
 void addLink(String eid, Point item, String replet, RepletRequest req)
          Add a hyperlink from an element (item) to a replet.
 void addLink(String eid, Point item, String replet, RepletRequest req, String frame)
          Add a hyperlink from an element (item) to a replet.
 void addLink(String eid, String replet)
          Add a hyperlink from an element to a replet.
 void addLinkURL(String eid, Point item, String url, String target)
          Add a link to a URL.
 void addMenuAction(String eid, Point item, String menuitem, RepletCommand action)
          Add a menu action to an element.
 void addMenuAction(String menuitem, RepletCommand action)
          Add a menu action.
 void addPopupMenu(String[] items)
          Add a popup menu for the report.
 void addPopupMenu(String eid, Point item, String[] items)
          Add a popup menu for an element.
 void addRepletMenuListener(inetsoft.sree.event.RepletMenuListener listener)
          Add a menu listener.
 void addRepletParameters(RepletParameters param)
          Add a parameter description.
 void addRepletSelectionListener(Object src, Point item, inetsoft.sree.event.RepletSelectionListener listener)
          Add a selection listener.
 void addRequest(String eid, Point item, RepletRequest req)
          Add a request link for an element (item).
 void addRequestListener(inetsoft.sree.event.RequestListener listener)
          Add a request listener.
 void addStatus(String eid, Point item, String msg)
          Add a status message associated with an element.
 void applyCalcTableSortOnHeader(inetsoft.report.internal.TableElementDef telem)
           
 boolean containsVariable(String name)
          Check if contains a variable.
 inetsoft.sree.script.RepletScriptable createRepletScriptable(BasicReplet replet)
          Create replet scriptable.
abstract  ReportSheet createReport(RepletRequest req)
          Generate a report.
 void destroy()
          Destroy this replet.
 void execute(ReportSheet report)
          Execute queries in a report.
 void execute(ReportSheet report, VariableTable vtable)
          Execute queries in a report.
protected  void finalize()
           
protected  RepletCommand fireRepletMenuEvent(inetsoft.sree.event.RepletMenuEvent event)
          Invoke the menu listeners.
protected  RepletCommand fireRequestEvent(inetsoft.sree.event.RequestEvent event)
          Invoke the request listeners.
protected  RepletCommand fireSelectionEvent(SelectionEvent event)
          Invoke the selection listeners.
 ReportSheet generate(RepletRequest req)
          This implements the generate() method.
 long getCacheTime()
          Get the maximum time this report is cached on the server.
protected  UserCatalog getCatalog()
          Get the user catalog containing report text string replacements.
 String getContextName()
          Get the context name for the report.
 Date getCreateDate()
          Get the date the replet is created.
 EventHandler getEventHandler()
          Get the client-side event handler of a replet.
 int getEventMask()
          Return the bitwise OR of the event masks for all events this replet is able to handle.
 Object getID()
          Get the replet ID.
 Date getLastAccessDate()
          Get the last access date.
 String getName()
          Get the replet name.
 Integer getOrientation()
          Get the orientation of this report.
 Size getPageSize()
          Get the page size of this report.
 Principal getPrincipal()
          Get the principal of the user who created this replet.
 ReportSheet getPrintReport()
          Get the original report with queries executed but scripts not yet executed.
 SelectionEvent[] getRegisteredSelections()
          Get a list of registered selection events.
 RepletParameters getRepletParameters(String reqname)
          Get the parameter descriptions of this replet.
 RepletRequest getRepletRequest()
          Get the last replet request used to generate the report.
 ReportSheet getReport()
          Get the cached report.
 long getReportLastModified()
          Get the report last modified time.
 int getReportMode()
          Get report mode, should be DESIGN_MODE or RUN_MODE.
 boolean getSaveParameters()
          Determine whether the parameter values are saved and reused.
 ActionListener getScheduleActionListener()
          Get the schedule action listener.
 VariableTable getVariableTable()
          Get the variable table.
 RepletCommand handleEvent(EventObject e)
          Handles replet events.
 RepletCommand handleRequestEvent(inetsoft.sree.event.RequestEvent event)
          Default handling of request event.
 void init(RepletRequest req)
          Initialize the replet.
protected  void initReport(ReportSheet report, RepletRequest req)
          Initialize the report.
protected  void initScript(ReportSheet report)
          Initialize the script environment.
 boolean isSortOnHeader()
          Determine whether tables in this replet will be sorted by the values in a column when that column's header is clicked.
protected  void processParameters()
          Process parameters.
 void processReport(ReportSheet report)
          Process report.
 void reexecute()
          Reexecute the report.
 void refreshVariableTable(RepletRequest req)
          Refresh variable table using a replet request.
 void refreshVariableTable(VariableTable table)
          Refresh the variable table.
 void regenerate()
          Regenerate the report.
 void removeAdhocVariables(List variables)
          Remove adhoc variables.
 void removeAllEventHandlers()
          Remove all event handling listeners and client-side handlers.
 void removeRepletMenuListener(inetsoft.sree.event.RepletMenuListener listener)
          Remove a menu listener.
 void removeRepletParameters(String reqname)
          Remove a parameter description.
 void removeRepletSelectionListener(String eid, Point item, inetsoft.sree.event.RepletSelectionListener listener)
          Remove a selection listener.
 void removeRequestListener(inetsoft.sree.event.RequestListener listener)
          Remove a request listener.
 void setAdhocVariables(List variables)
          Set adhoc variables.
 void setCacheTime(long maxtime)
          Set whether the report data should be cached.
 void setChanged()
          Set the changed flag.
 void setCreateDate(Date createDate)
          Set the date the replet is created.
 void setID(Object id)
          Set the ID of this replet.
 void setLastAccessDate(Date lastAccessDate)
          Set the last access date.
 void setName(String name)
          Set the name of this replet.
 void setOrientation(int orient)
          Set the orientation of this report, StyleConstants.PORTRAIT or StyleConstants.LANDSCAPE.
 void setPageSize(Size pagesize)
          Set the page size of this report.
 void setPrincipal(Principal principal)
          Set the principal of the user who created this replet.
 void setRepletRequest(RepletRequest req)
          Set the replet request to be used for generating report.
 void setReport(ReportSheet report)
          Set the report in this replet.
 void setReportMode(int mode)
          Set report mode, should be DESIGN_MODE or RUN_MODE.
 void setSaveParameters(boolean value)
          Set whether parameters of this report is to be saved and reused the next time the same user access this report.
 void setScheduleActionListener(ActionListener l)
          Set the schedule action listener to runtime replet.
 void setSortOnHeader(boolean value)
          Set whether tables in this replet should be sorted by the values in a column when that column's header is clicked.
 void waitForLoaded()
          Wait until report is loaded.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastreq

protected RepletRequest lastreq

principal

protected Principal principal

catalog

protected UserCatalog catalog

destroyed

protected boolean destroyed

fieldelems

protected Vector fieldelems
Constructor Detail

BasicReplet

public BasicReplet()
Method Detail

createReport

public abstract ReportSheet createReport(RepletRequest req)
                                  throws RepletException
Generate a report. This method must be implemented by the subclass. It is called at every request (including the initial request).

Parameters:
req - replet request, including replet parameter values.
Returns:
generated report.
Throws:
RepletException

getReport

public ReportSheet getReport()
Get the cached report. This may be null if generate() has not been called.

Specified by:
getReport in interface Replet

setReport

public void setReport(ReportSheet report)
Set the report in this replet. This is called by the server to modify the report in adhoc query.


getPrintReport

public ReportSheet getPrintReport()
Get the original report with queries executed but scripts not yet executed. This method is called to get a report for printing or exporting in case the report needs to be re-generated.

Specified by:
getPrintReport in interface Replet

init

public void init(RepletRequest req)
          throws RepletException
Initialize the replet. The initialization parameter is what's specified during replet registration. It is called once after a replet is loaded. Class overriding this method must call this method to initialize the report.

Specified by:
init in interface Replet
Parameters:
req - initialization request.
Throws:
RepletException

initReport

protected void initReport(ReportSheet report,
                          RepletRequest req)
                   throws RepletException
Initialize the report. Classes overriding this method should call this to initialize the report.

Parameters:
report - report sheet.
req - initialization request.
Throws:
RepletException

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

destroy

public void destroy()
Destroy this replet. It is called when this replet is no longer needed.

Specified by:
destroy in interface Replet

regenerate

public void regenerate()
Regenerate the report. This calls the createReport() method with the last replet request. The internal report object is refreshed with the newly created report object.

Specified by:
regenerate in interface Replet

reexecute

public void reexecute()
Reexecute the report. When generating report next time, the internal report will be executed.

Specified by:
reexecute in interface Replet

setChanged

public void setChanged()
Set the changed flag.

Specified by:
setChanged in interface Replet

generate

public final ReportSheet generate(RepletRequest req)
                           throws RepletException
This implements the generate() method. Subclasses should override createReport(), which is called by this method.

Specified by:
generate in interface Replet
Parameters:
req - replet request, including replet parameter values.
Returns:
generated report.
Throws:
RepletException

getReportLastModified

public long getReportLastModified()
Get the report last modified time.

Specified by:
getReportLastModified in interface Replet

getRepletParameters

public final RepletParameters getRepletParameters(String reqname)
Get the parameter descriptions of this replet. The parameter descriptions are used to construct a parameter prompting dialog to interactively collect parameter values from users.

Specified by:
getRepletParameters in interface Replet
Parameters:
reqname - request name.
Returns:
replet parameter description.

addRepletParameters

public void addRepletParameters(RepletParameters param)
Add a parameter description. This will be returned from getRepletParameters().

Parameters:
param - replet parameter description.

removeRepletParameters

public void removeRepletParameters(String reqname)
Remove a parameter description.

Parameters:
reqname - request name.

setPageSize

public void setPageSize(Size pagesize)
Set the page size of this report.

Parameters:
pagesize - page size in inches.

getPageSize

public Size getPageSize()
Get the page size of this report.


setOrientation

public void setOrientation(int orient)
Set the orientation of this report, StyleConstants.PORTRAIT or StyleConstants.LANDSCAPE.

Parameters:
orient - page orientation.

getOrientation

public Integer getOrientation()
Get the orientation of this report.


setID

public void setID(Object id)
Set the ID of this replet.

Specified by:
setID in interface Replet

getID

public Object getID()
Get the replet ID.

Specified by:
getID in interface Replet

setName

public void setName(String name)
Set the name of this replet.

Specified by:
setName in interface Replet

getName

public String getName()
Get the replet name.

Specified by:
getName in interface Replet

getContextName

public String getContextName()
Get the context name for the report.


setPrincipal

public void setPrincipal(Principal principal)
Set the principal of the user who created this replet.

Specified by:
setPrincipal in interface Replet

getPrincipal

public Principal getPrincipal()
Get the principal of the user who created this replet.

Specified by:
getPrincipal in interface Replet

setReportMode

public void setReportMode(int mode)
Set report mode, should be DESIGN_MODE or RUN_MODE.

Specified by:
setReportMode in interface Replet
Parameters:
mode - the specified report mode

getReportMode

public int getReportMode()
Get report mode, should be DESIGN_MODE or RUN_MODE.

Specified by:
getReportMode in interface Replet
Returns:
report mode

getEventHandler

public final EventHandler getEventHandler()
Get the client-side event handler of a replet. The client-side commands are handled entirely on the client-side without any server involvement.

Specified by:
getEventHandler in interface Replet
Returns:
client-side commands.

getEventMask

public final int getEventMask()
Return the bitwise OR of the event masks for all events this replet is able to handle.

Specified by:
getEventMask in interface Replet
Returns:
event mask.

handleEvent

public RepletCommand handleEvent(EventObject e)
Handles replet events. This calls the appropriate event handlers.

Specified by:
handleEvent in interface Replet
Parameters:
e - the EventObject to handle
Returns:
viewer command.

waitForLoaded

public void waitForLoaded()
                   throws RepletException
Wait until report is loaded.

Specified by:
waitForLoaded in interface Replet
Throws:
RepletException

execute

public void execute(ReportSheet report)
             throws Exception
Execute queries in a report. This method should be used to execute a report in a replet. If the XSessionManager is used directly, the replet must call initScript() before the report is executed to set up the scripting environment. This method does not need to be called if the report does not contain any embedded queries.

Throws:
Exception

execute

public void execute(ReportSheet report,
                    VariableTable vtable)
             throws Exception
Execute queries in a report. This method should be used to execute a report in a replet. If the XSessionManager is used directly, the replet must call initScript() before the report is executed to set up the scripting environment. This method does not need to be called if the report does not contain any embedded queries.

Throws:
Exception

getCatalog

protected UserCatalog getCatalog()
Get the user catalog containing report text string replacements. If the principal set for the replet has the SRPrincipal.LOCALE property set to a valid locale, the user catalog will contain the replacements specific to that locale.


initScript

protected void initScript(ReportSheet report)
Initialize the script environment. This method only needs to be called if a replet executes a report using XSessionManager without calling the BasicReplet.execute() method.


createRepletScriptable

public inetsoft.sree.script.RepletScriptable createRepletScriptable(BasicReplet replet)
Create replet scriptable.

Returns:
the created replet scriptable.

getRepletRequest

public RepletRequest getRepletRequest()
Get the last replet request used to generate the report. The request is reused when a regenerate() is called. A replet can modify the request parameter values before calling regenerate() to customize the report.

Specified by:
getRepletRequest in interface Replet
Returns:
last replet request of current replet.

setRepletRequest

public void setRepletRequest(RepletRequest req)
Set the replet request to be used for generating report.

Specified by:
setRepletRequest in interface Replet

addLink

public void addLink(String eid,
                    String replet)
Add a hyperlink from an element to a replet.

Parameters:
eid - element ID.
replet - replet name.

addLink

public void addLink(String eid,
                    Point item,
                    String replet,
                    RepletRequest req)
Add a hyperlink from an element (item) to a replet.

Parameters:
eid - element ID.
item - the item inside the element. If it's null, the link is from the whole element. Otherwise, only clicks inside the specified item (e.g. cell or band) activates the link. Use inetsoft.report.event.EventPoint to create a point object.
replet - replet name.
req - replet request.

addLink

public void addLink(String eid,
                    Point item,
                    String replet,
                    RepletRequest req,
                    String frame)
Add a hyperlink from an element (item) to a replet.

Parameters:
eid - element ID.
item - the item inside the element. If it's null, the link is from the whole element. Otherwise, only clicks inside the specified item (e.g. cell or band) activates the link. Use inetsoft.report.event.EventPoint to create a point object.
replet - replet name.
req - replet request.
frame - the target frame for the link in a browser.

addLink

public void addLink(String eid,
                    Point item,
                    String toeid,
                    int row)
Add a hyperlink from one element to another element inside the same report.

Parameters:
eid - source element ID.
item - source element item, null to ignore. Use inetsoft.report.event.EventPoint to create a point object.
toeid - target element ID.
row - target element row number (if table).

addLinkURL

public void addLinkURL(String eid,
                       Point item,
                       String url,
                       String target)
Add a link to a URL. The document referenced by the URL is displayed in a browser. If this is run from a DHTML viewer or a viewer launched from an applet, the current browser is used. Otherwise, the viewer executes a browser command and passes the URL to the browser. The browser command is defined by the html.browser property.

Parameters:
eid - source element ID.
item - source element item, null to ignore. Use inetsoft.report.event.EventPoint to create a point object.
url - url string.
target - target frame name.

addRequest

public void addRequest(String eid,
                       Point item,
                       RepletRequest req)
Add a request link for an element (item). If the element/item is clicked, the request is sent to the replet as a RequestEvent.

Parameters:
eid - element ID.
item - the item inside the element. If it's null, the link is from the whole element. Otherwise, only clicks inside the specified item (e.g. cell) will activate the link. Use inetsoft.report.event.EventPoint to create a point object.
req - replet request.

addStatus

public void addStatus(String eid,
                      Point item,
                      String msg)
Add a status message associated with an element. The message is shown in the status bar when the mouse moves inside the element.

Parameters:
eid - element ID.
item - element item. Use inetsoft.report.event.EventPoint to create a point object.
msg - status message.

addPopupMenu

public void addPopupMenu(String[] items)
Add a popup menu for the report. The menu will pop up when a menu trigger mouse button is pushed anywhere on the report.

Parameters:
items - menu items.

addPopupMenu

public void addPopupMenu(String eid,
                         Point item,
                         String[] items)
Add a popup menu for an element. The menu will pop up when a menu trigger mouse button is pushed inside the element (item).

Parameters:
eid - element ID.
item - element item, null to ignore. Use inetsoft.report.event.EventPoint to create a point object.
items - menu items.

addMenuAction

public void addMenuAction(String menuitem,
                          RepletCommand action)
Add a menu action. The command is executed when the menu item is selected.

Parameters:
menuitem - menu item name.
action - action command.

addMenuAction

public void addMenuAction(String eid,
                          Point item,
                          String menuitem,
                          RepletCommand action)
Add a menu action to an element. The action is performed when a menu item associated with the element is selected.

Parameters:
eid - element ID.
item - element item, null to ignore. Use inetsoft.report.event.EventPoint to create a point object.
menuitem - menu item.
action - menu action command.

addFormLink

public void addFormLink(String form,
                        String replet)
Add a hyperlink from a form to a replet. When the form is submitted, the request is used to create the specified replet.

Parameters:
form - form name.
replet - replet name.

addRepletMenuListener

public void addRepletMenuListener(inetsoft.sree.event.RepletMenuListener listener)
Add a menu listener. This listener is invoked when a menu item is selected and no specified action is associated with the menu item.


removeRepletMenuListener

public void removeRepletMenuListener(inetsoft.sree.event.RepletMenuListener listener)
Remove a menu listener.


addRequestListener

public void addRequestListener(inetsoft.sree.event.RequestListener listener)
Add a request listener. This listener is invoked when a request event (generated from a request dialog submission) is generated.


removeRequestListener

public void removeRequestListener(inetsoft.sree.event.RequestListener listener)
Remove a request listener.


addRepletSelectionListener

public void addRepletSelectionListener(Object src,
                                       Point item,
                                       inetsoft.sree.event.RepletSelectionListener listener)
Add a selection listener. This listener is invoked when an element is selected on a report.

Parameters:
src - element ID, String or ReportElement.
item - element item, null to ignore. Use inetsoft.report.event.EventPoint to create a point object.
listener - the selection listener.

removeRepletSelectionListener

public void removeRepletSelectionListener(String eid,
                                          Point item,
                                          inetsoft.sree.event.RepletSelectionListener listener)
Remove a selection listener. Use inetsoft.report.event.EventPoint to create a point object as item.


removeAllEventHandlers

public void removeAllEventHandlers()
Remove all event handling listeners and client-side handlers.


getRegisteredSelections

public final SelectionEvent[] getRegisteredSelections()
Get a list of registered selection events. These are the events this replet is interested in.

Specified by:
getRegisteredSelections in interface Replet

setSortOnHeader

public void setSortOnHeader(boolean value)
Set whether tables in this replet should be sorted by the values in a column when that column's header is clicked.

Parameters:
value - true if tables should be sorted when a header is clicked

isSortOnHeader

public boolean isSortOnHeader()
Determine whether tables in this replet will be sorted by the values in a column when that column's header is clicked.

Returns:
true if tables will be sorted when a header is clicked

setCacheTime

public void setCacheTime(long maxtime)
Set whether the report data should be cached. If the value is not zero, this report is cached on the server for the period specified by the parameter, and subsequent access to the report will use the cached report and avoid executing the query.

Parameters:
maxtime - the maximum time a report is cached, in milliseconds.

getCacheTime

public long getCacheTime()
Get the maximum time this report is cached on the server. Return zero if the report is not cached.


getCreateDate

public Date getCreateDate()
Get the date the replet is created.

Returns:
the date the replet is created.

setCreateDate

public void setCreateDate(Date createDate)
Set the date the replet is created.

Parameters:
createDate -

getLastAccessDate

public Date getLastAccessDate()
Get the last access date.

Returns:
the last access date.

setLastAccessDate

public void setLastAccessDate(Date lastAccessDate)
Set the last access date.

Parameters:
lastAccessDate - the last access date.

setSaveParameters

public void setSaveParameters(boolean value)
Set whether parameters of this report is to be saved and reused the next time the same user access this report.

Parameters:
value - true if parameters should be saved.

getSaveParameters

public boolean getSaveParameters()
Determine whether the parameter values are saved and reused.

Returns:
true if parameters are saved.

fireSelectionEvent

protected RepletCommand fireSelectionEvent(SelectionEvent event)
Invoke the selection listeners.


handleRequestEvent

public RepletCommand handleRequestEvent(inetsoft.sree.event.RequestEvent event)
Default handling of request event.


fireRequestEvent

protected RepletCommand fireRequestEvent(inetsoft.sree.event.RequestEvent event)
Invoke the request listeners.


fireRepletMenuEvent

protected RepletCommand fireRepletMenuEvent(inetsoft.sree.event.RepletMenuEvent event)
Invoke the menu listeners.


processParameters

protected final void processParameters()
Process parameters.


processReport

public void processReport(ReportSheet report)
Process report.


refreshVariableTable

public void refreshVariableTable(VariableTable table)
Refresh the variable table.

Parameters:
table - the specified variable table.

refreshVariableTable

public void refreshVariableTable(RepletRequest req)
Refresh variable table using a replet request.

Parameters:
req - the specified replet request contains parameters.

containsVariable

public boolean containsVariable(String name)
Check if contains a variable.

Parameters:
name - the specified variable name.
Returns:
true if contains, false otherwise.

removeAdhocVariables

public void removeAdhocVariables(List variables)
Remove adhoc variables.

Parameters:
variables - list stores specified adhoc variables.

setAdhocVariables

public void setAdhocVariables(List variables)
Set adhoc variables.

Parameters:
variables - list stores specified adhoc variables.

getVariableTable

public VariableTable getVariableTable()
Get the variable table.

Specified by:
getVariableTable in interface Replet
Returns:
the variable table.

applyCalcTableSortOnHeader

public void applyCalcTableSortOnHeader(inetsoft.report.internal.TableElementDef telem)

setScheduleActionListener

public void setScheduleActionListener(ActionListener l)
Set the schedule action listener to runtime replet.


getScheduleActionListener

public ActionListener getScheduleActionListener()
Get the schedule action listener.


Copyright © 1996-2014 InetSoft Technology Corp. All Rights Reserved.