|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.opencms.workplace.CmsWorkplace
Master class for the JSP based workplace which provides default methods and session handling for all JSP workplace classes.
| Field Summary | |
static boolean |
DEBUG
The debug flag. |
static String |
DEFAULT_LANGUAGE
Parameter for the default language. |
static Locale |
DEFAULT_LOCALE
Parameter for the default locale. |
protected static String |
DIALOG_PATH_COMMON
Constant for the JSP common files (e.g. |
protected static String |
FILE_DIALOG_CLOSE
Constant for the JSP common close dialog page. |
protected static String |
FILE_DIALOG_SCREEN_CONFIRM
Constant for the JSP common confirmation dialog. |
protected static String |
FILE_DIALOG_SCREEN_ERROR
Constant for the JSP common error dialog. |
protected static String |
FILE_DIALOG_SCREEN_ERRORPAGE
Constant for the JSP common error dialog. |
protected static String |
FILE_DIALOG_SCREEN_WAIT
Constant for the JSP common wait screen. |
static String |
FILE_EXPLORER_FILELIST
Constant for the JSP explorer filelist file. |
protected static String |
FILE_REPORT_OUTPUT
Constant for the JSP common report page. |
static int |
HTML_END
Helper variable to deliver the html end part. |
static int |
HTML_START
Helper variable to deliver the html start part. |
static String |
PATH_DIALOGS
Constant for the JSP dialogs path. |
static String |
PATH_WORKPLACE
Constant for the JSP workplace path. |
protected static String |
REQUEST_ATTRIBUTE_MULTIPART
Key name for the request attribute to indicate a multipart request was already parsed. |
protected static String |
REQUEST_ATTRIBUTE_RELOADTREE
Key name for the request attribute to reload the folder tree view. |
static String |
RFS_PATH_RESOURCES
Path to exported system image folder. |
protected static String |
SESSION_WORKPLACE_CLASS
Key name for the session workplace class. |
static String |
TEMP_FILE_PREFIX
Prefix for temporary files in the VFS. |
static String |
VFS_DIR_DEFAULTBODIES
Directory name of content default_bodies folder. |
static String |
VFS_DIR_TEMPLATES
Directory name of content templates folder. |
static String |
VFS_PATH_GALLERIES
Path to the galleries. |
static String |
VFS_PATH_LOCALES
Path to locales. |
static String |
VFS_PATH_MODULES
Path to modules folder. |
static String |
VFS_PATH_RESOURCES
Path to system image folder. |
static String |
VFS_PATH_SYSTEM
Path to system folder. |
static String |
VFS_PATH_VIEWS
Path to workplace views. |
static String |
VFS_PATH_WORKPLACE
Path to the workplace. |
| Constructor Summary | |
CmsWorkplace(CmsJspActionElement jsp)
Public constructor. |
|
CmsWorkplace(PageContext context,
HttpServletRequest req,
HttpServletResponse res)
Public constructor with JSP variables. |
|
| Method Summary | |
protected void |
addMessages(String bundleName)
Auxiliary method for initialization of messages. |
String |
allParamsAsHidden()
Returns all parameters of the current workplace class as hidden field tags that can be inserted in a form. |
String |
allParamsAsRequest()
Returns all present request parameters as String. |
protected Map |
allParamValues()
Returns the values of all parameter methods of this workplace class instance. |
String |
bodyEnd()
Builds the end html of the body. |
String |
bodyStart(String className)
Builds the start html of the body. |
String |
bodyStart(String className,
String parameters)
Builds the start html of the body. |
String |
buildSelect(String parameters,
List options,
List values,
int selected)
Generates a html select box out of the provided values. |
static String |
buildSelect(String parameters,
List options,
List values,
int selected,
boolean useLineFeed)
Generates a html select box out of the provided values. |
String |
button(String href,
String target,
String image,
String label,
int type)
Generates a button for the OpenCms workplace. |
String |
button(String href,
String target,
String image,
String label,
int type,
String imagePath)
Generates a button for the OpenCms workplace. |
String |
buttonBar(int segment)
Returns the html for a button bar. |
String |
buttonBar(int segment,
String attributes)
Returns the html for a button bar. |
String |
buttonBarHorizontalLine()
Generates a horizontal button bar separator line with maximum width. |
String |
buttonBarLabel(String label)
Generates a button bar label. |
String |
buttonBarLabel(String label,
String className)
Generates a button bar label. |
String |
buttonBarLine(int leftPixel,
int rightPixel,
String className)
Generates a variable button bar separator line. |
String |
buttonBarLineSpacer(int pixel)
Generates a variable button bar separator line spacer. |
String |
buttonBarSeparator(int leftPixel,
int rightPixel)
Generates a button bar separator. |
String |
buttonBarSpacer(int width)
Returns the html for an invisible spacer between button bar contents like buttons, labels, etc. |
String |
buttonBarStartTab(int leftPixel,
int rightPixel)
Generates a button bar starter tab. |
String |
calendarIncludes()
Displays a javascript calendar element with the standard "opencms" style. |
String |
calendarIncludes(String style)
Displays a javascript calendar element. |
String |
calendarInit(String inputFieldId,
String triggerButtonId,
String align,
boolean singleClick,
boolean weekNumbers,
boolean mondayFirst,
String dateStatusFunc)
Initializes a javascript calendar element to be shown on a page. |
String |
calendarInit(String inputFieldId,
String triggerButtonId,
String align,
boolean singleClick,
boolean weekNumbers,
boolean mondayFirst,
String dateStatusFunc,
boolean showTime)
Initializes a javascript calendar element to be shown on a page. |
void |
checkLock(String resource)
Checks the lock state of the resource and locks it if the autolock feature is enabled. |
void |
checkLock(String resource,
int mode)
Checks the lock state of the resource and locks it if the autolock feature is enabled. |
protected String |
decodeParamValue(String paramName,
String paramValue)
Decodes an individual parameter value. |
void |
fillParamValues(HttpServletRequest request)
Fills all class parameter values from the data provided in the current request. |
String |
getBroadcastMessageString()
Returns the message String for the broadcast message alert of the workplace. |
long |
getCalendarDate(String dateString,
boolean useTime)
Creates the time in milliseconds from the given parameter. |
static String |
getCalendarJavaDateFormat(String dateFormat)
Parses the JS calendar date format to the java patterns of SimpleDateFormat. |
String |
getCalendarLocalizedTime(long timestamp)
Returns the given timestamp as String formatted in a localized pattern. |
CmsObject |
getCms()
Returns the initialized cms object for the current user. |
String |
getEncoding()
Returns the current workplace encoding. |
String |
getExplorerFileListFullUri()
Returns the uri (including context path) to the explorer file list. |
String |
getFrameSource(String frameName,
String uri)
Returns the html for the frame name and source and stores this information in the workplace settings. |
CmsJspActionElement |
getJsp()
Returns the JSP action element. |
Locale |
getLocale()
Returns the current users locale setting. |
CmsMacroResolver |
getMacroResolver()
Returns the current used macro resolver instance. |
CmsMessages |
getMessages()
Returns the current used message object. |
List |
getMultiPartFileItems()
Returns a list of FileItem instances parsed from the request, in the order that they were transmitted. |
protected Map |
getParameterMap()
Returns the map of parameters read from the current request. |
String |
getResourceUri()
Returns the path to the workplace static resources. |
static String |
getResourceUri(String resourceName)
Returns the full Workplace resource path to the selected resource. |
HttpSession |
getSession()
Returns the current user http session. |
CmsWorkplaceSettings |
getSettings()
Returns the current users workplace settings. |
static String |
getSkinUri()
Returns the path to the skin resources. |
static String |
getStyleUri(CmsJspActionElement jsp)
Returns the path to the cascading stylesheets. |
static String |
getStyleUri(CmsJspActionElement jsp,
String filename)
Returns the path to the cascading stylesheets. |
String |
getStyleUri(String filename)
Returns the path to the cascading stylesheets. |
String |
htmlEnd()
Builds the end html of the page. |
String |
htmlStart(String title)
Builds the start html of the page, including setting of DOCTYPE and inserting a header with the content-type. |
protected void |
initMessages()
Initializes the message object. |
static CmsWorkplaceSettings |
initUserSettings(CmsObject cms,
CmsWorkplaceSettings settings,
boolean update)
Updates the user settings in the given workplace settings for the current user, reading the user settings from the database if required. |
protected void |
initWorkplaceMembers(CmsJspActionElement jsp)
Initializes this workplace class instance. |
protected abstract void |
initWorkplaceRequestValues(CmsWorkplaceSettings settings,
HttpServletRequest request)
Analyzes the request for workplace parameters and adjusts the workplace settings accordingly. |
static CmsWorkplaceSettings |
initWorkplaceSettings(CmsObject cms,
CmsWorkplaceSettings settings,
boolean update)
Updates the given workplace settings, also re-initializing the state of the Workplace to the users preferences (for example setting the startup site and project). |
boolean |
isForwarded()
Returns the forwarded flag. |
boolean |
isHelpEnabled()
Returns true if the online help for the users current workplace language is installed. |
boolean |
isSubElement()
Returns true if the currently processed element is an included sub element. |
String |
key(String keyName)
Returns the localized resource string for a given message key, checking the workplace default resources and all module bundles. |
String |
key(String keyName,
Object[] params)
Returns the localized resource string for a given message key, with the provided replacement parameters. |
String |
key(String keyName,
String defaultValue)
Returns the localized resource string for the given message key, checking the workplace default resources and all module bundles. |
String |
nullToEmpty(String value)
Returns the empty String "" if the provided value is null, otherwise just returns the provided value. |
String |
pageBody(int segment,
String className,
String parameters)
Builds the html of the body. |
String |
pageHtml(int segment,
String title)
Returns the default html for a workplace page, including setting of DOCTYPE and inserting a header with the content-type. |
String |
pageHtmlStyle(int segment,
String title,
String stylesheet)
Returns the default html for a workplace page, including setting of DOCTYPE and inserting a header with the content-type, allowing the selection of an individual style sheet. |
String |
paramsAsHidden()
Returns all initialized parameters of the current workplace class as hidden field tags that can be inserted in a form. |
String |
paramsAsHidden(Collection excludes)
Returns all initialized parameters of the current workplace class that are not in the given exclusion list as hidden field tags that can be inserted in a form. |
Map |
paramsAsParameterMap()
Returns all initialized parameters of the current workplace class in the form of a parameter map, i.e. |
String |
paramsAsRequest()
Returns all initialized parameters of the current workplace class as request parameters, i.e. |
protected Map |
paramValues()
Returns the values of all parameter methods of this workplace class instance. |
String |
resolveMacros(String input)
Resolves the macros in the given String and replaces them by their localized keys. |
void |
sendCmsRedirect(String location)
Sends a http redirect to the specified URI in the OpenCms VFS. |
void |
setForwarded(boolean forwarded)
Sets the forwarded flag. |
String |
shortKey(String keyName)
Get a localized short key value for the workplace. |
protected void |
switchToCurrentProject()
Helper method to change back from the temporary project to the current project. |
protected int |
switchToTempProject()
Helper method to change the current project to the temporary file project. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String FILE_EXPLORER_FILELIST
public static final String PATH_DIALOGS
public static final String PATH_WORKPLACE
public static final boolean DEBUG
public static final int HTML_END
public static final int HTML_START
protected static final String DIALOG_PATH_COMMON
protected static final String FILE_DIALOG_CLOSE
protected static final String FILE_DIALOG_SCREEN_CONFIRM
protected static final String FILE_DIALOG_SCREEN_ERROR
protected static final String FILE_DIALOG_SCREEN_ERRORPAGE
protected static final String FILE_DIALOG_SCREEN_WAIT
protected static final String FILE_REPORT_OUTPUT
protected static final String SESSION_WORKPLACE_CLASS
protected static final String REQUEST_ATTRIBUTE_MULTIPART
protected static final String REQUEST_ATTRIBUTE_RELOADTREE
public static final String TEMP_FILE_PREFIX
public static final String RFS_PATH_RESOURCES
public static final String VFS_DIR_DEFAULTBODIES
public static final String VFS_DIR_TEMPLATES
public static final String VFS_PATH_SYSTEM
public static final String VFS_PATH_GALLERIES
public static final String VFS_PATH_MODULES
public static final String VFS_PATH_WORKPLACE
public static final String VFS_PATH_LOCALES
public static final String VFS_PATH_RESOURCES
public static final String VFS_PATH_VIEWS
public static final Locale DEFAULT_LOCALE
public static final String DEFAULT_LANGUAGE
| Constructor Detail |
public CmsWorkplace(CmsJspActionElement jsp)
jsp - the initialized JSP context
public CmsWorkplace(PageContext context,
HttpServletRequest req,
HttpServletResponse res)
context - the JSP page contextreq - the JSP requestres - the JSP response| Method Detail |
public static String buildSelect(String parameters,
List options,
List values,
int selected,
boolean useLineFeed)
parameters - a string that will be inserted into the initial select tag,
if null no parameters will be insertedoptions - the optionsvalues - the option values, if null the select will have no value attributesselected - the index of the pre-selected option, if -1 no option is pre-selecteduseLineFeed - if true, adds some formatting "\n" to the output String
public static String getCalendarJavaDateFormat(String dateFormat)
dateFormat - the dateformat String of the JS calendar
public static String getResourceUri(String resourceName)
resourceName - the name of the resource to get the resource path for
public static String getSkinUri()
public static String getStyleUri(CmsJspActionElement jsp)
jsp - the JSP context
public static String getStyleUri(CmsJspActionElement jsp,
String filename)
jsp - the JSP contextfilename - the name of the stylesheet
public static CmsWorkplaceSettings initUserSettings(CmsObject cms,
CmsWorkplaceSettings settings,
boolean update)
cms - the cms object for the current usersettings - the workplace settings to update (if null a new instance is created)update - flag indicating if settings are only updated (user preferences)
initWorkplaceSettings(CmsObject, CmsWorkplaceSettings, boolean)
public static CmsWorkplaceSettings initWorkplaceSettings(CmsObject cms,
CmsWorkplaceSettings settings,
boolean update)
initUserSettings(CmsObject, CmsWorkplaceSettings, boolean)
before updating the workplace project, selected site etc.
cms - the cms object for the current usersettings - the workplace settings to update (if null a new instance is created)update - flag indicating if settings are only updated (user preferences)
initUserSettings(CmsObject, CmsWorkplaceSettings, boolean)public String allParamsAsHidden()
public String allParamsAsRequest()
The String is formatted as a parameter String ("param1=val1¶m2=val2") with UTF-8 encoded values.
public String bodyEnd()
public String bodyStart(String className)
className - optional class attribute to add to the body tag
public String bodyStart(String className,
String parameters)
className - optional class attribute to add to the body tagparameters - optional parameters to add to the body tag
public String buildSelect(String parameters,
List options,
List values,
int selected)
parameters - a string that will be inserted into the initial select tag,
if null no parameters will be insertedoptions - the optionsvalues - the option values, if null the select will have no value attributesselected - the index of the pre-selected option, if -1 no option is pre-selected
public String button(String href,
String target,
String image,
String label,
int type)
href - the href link for the button, if none is given the button will be disabledtarget - the href link target for the button, if none is given the target will be same windowimage - the image name for the button, skin path will be automattically added as prefixlabel - the label for the text of the buttontype - 0: image only (default), 1: image and text, 2: text only
public String button(String href,
String target,
String image,
String label,
int type,
String imagePath)
href - the href link for the button, if none is given the button will be disabledtarget - the href link target for the button, if none is given the target will be same windowimage - the image name for the button, skin path will be automattically added as prefixlabel - the label for the text of the buttontype - 0: image only (default), 1: image and text, 2: text onlyimagePath - the path to the image
public String buttonBar(int segment)
segment - the HTML segment (START / END)
public String buttonBar(int segment,
String attributes)
segment - the HTML segment (START / END)attributes - optional attributes for the table tag
public String buttonBarHorizontalLine()
public String buttonBarLabel(String label)
label - the label to show
public String buttonBarLabel(String label,
String className)
label - the label to showclassName - the css class name for the formatting
public String buttonBarLine(int leftPixel,
int rightPixel,
String className)
leftPixel - the amount of pixel left to the linerightPixel - the amount of pixel right to the lineclassName - the css class name for the formatting
public String buttonBarLineSpacer(int pixel)
pixel - the amount of pixel space
public String buttonBarSeparator(int leftPixel,
int rightPixel)
leftPixel - the amount of pixel left to the separatorrightPixel - the amount of pixel right to the separator
public String buttonBarSpacer(int width)
width - the width of the invisible spacer
public String buttonBarStartTab(int leftPixel,
int rightPixel)
leftPixel - the amount of pixel left to the starterrightPixel - the amount of pixel right to the starter
public String calendarIncludes()
Creates the HTML javascript and stylesheet includes for the head of the page.
public String calendarIncludes(String style)
Creates the HTML javascript and stylesheet includes for the head of the page.
style - the name of the used calendar style, e.g. "system", "blue"
public String calendarInit(String inputFieldId,
String triggerButtonId,
String align,
boolean singleClick,
boolean weekNumbers,
boolean mondayFirst,
String dateStatusFunc)
This method must be called at the end of a HTML page, e.g. before the closing <body> tag.
inputFieldId - the ID of the input field where the date is pasted totriggerButtonId - the ID of the button which triggers the calendaralign - initial position of the calendar popup elementsingleClick - if true, a single click selects a date and closes the calendar, otherwise calendar is closed by doubleclickweekNumbers - show the week numbers in the calendar or notmondayFirst - show monday as first day of weekdateStatusFunc - name of the function which determines if/how a date should be disabled
public String calendarInit(String inputFieldId,
String triggerButtonId,
String align,
boolean singleClick,
boolean weekNumbers,
boolean mondayFirst,
String dateStatusFunc,
boolean showTime)
This method must be called at the end of a HTML page, e.g. before the closing <body> tag.
inputFieldId - the ID of the input field where the date is pasted totriggerButtonId - the ID of the button which triggers the calendaralign - initial position of the calendar popup elementsingleClick - if true, a single click selects a date and closes the calendar, otherwise calendar is closed by doubleclickweekNumbers - show the week numbers in the calendar or notmondayFirst - show monday as first day of weekdateStatusFunc - name of the function which determines if/how a date should be disabledshowTime - true if the time selector should be shown, otherwise false
public void checkLock(String resource)
throws CmsException
resource - the resource name which is checked
CmsException - if reading or locking the resource fails
public void checkLock(String resource,
int mode)
throws CmsException
resource - the resource name which is checkedmode - flag indicating the mode (temporary or common) of a lock
CmsException - if reading or locking the resource failspublic void fillParamValues(HttpServletRequest request)
All methods that start with "setParam" are possible candidates to be automatically filled. The remaining part of the method name is converted to lower case. Then a parameter of this name is searched in the request parameters. If the parameter is found, the "setParam" method is automatically invoked by reflection with the value of the parameter.
request - the current JSP requestpublic String getBroadcastMessageString()
Caution: returns the pure message String (not escaped) or null, if no message is pending.
public long getCalendarDate(String dateString,
boolean useTime)
throws ParseException
dateString - the String representation of the dateuseTime - true if the time should be parsed, too, otherwise false
ParseException - if something goes wrongpublic String getCalendarLocalizedTime(long timestamp)
timestamp - the time to format
public CmsObject getCms()
public String getEncoding()
public String getExplorerFileListFullUri()
public String getFrameSource(String frameName,
String uri)
frameName - the name of the frameuri - the absolute path of the frame
public CmsJspActionElement getJsp()
public Locale getLocale()
This is a convenience method that just
executes the following code:
getCms().getRequestContext().getLocale().
public CmsMacroResolver getMacroResolver()
public CmsMessages getMessages()
public List getMultiPartFileItems()
This list is automatically initialized from the createParameterMapFromMultiPart(HttpServletRequest) method.
public String getResourceUri()
Workplaces static resources are images, css files etc. These are exported during the installation of OpenCms, and are usually only read from this exported location to avoid the overhaead of accessing the database later.
public HttpSession getSession()
public CmsWorkplaceSettings getSettings()
public String getStyleUri(String filename)
filename - the name of the stylesheet
public String htmlEnd()
public String htmlStart(String title)
title - the content for the title tag
public boolean isForwarded()
public boolean isHelpEnabled()
public boolean isSubElement()
public String key(String keyName)
If the key was not found, the return value is
"??? " + keyName + " ???".
If the key starts with "help." and is not found,
the value "index.html" is returned.
keyName - the key for the desired string
CmsMessages.key(String)
public String key(String keyName,
Object[] params)
If the key was found in the bundle, it will be formatted using
a using the provided parameters.MessageFormat
If the key was not found in the bundle, the return value is
"??? " + keyName + " ???". This will also be returned
if the bundle was not properly initialized first.
keyName - the key for the desired stringparams - the parameters to use for formatting
CmsMessages.key(String)
public String key(String keyName,
String defaultValue)
If the key was not found, the provided default value is returned.
keyName - the key for the desired stringdefaultValue - the default value in case the key does not exist in the bundle
CmsMessages.key(String, String)public String nullToEmpty(String value)
Use this method in forms if a getParamXXX method is used, but a String (not null) is required.
value - the String to check
public String pageBody(int segment,
String className,
String parameters)
segment - the HTML segment (START / END)className - optional class attribute to add to the body tagparameters - optional parameters to add to the body tag
public String pageHtml(int segment,
String title)
segment - the HTML segment (START / END)title - the title of the page, if null no title tag is inserted
public String pageHtmlStyle(int segment,
String title,
String stylesheet)
segment - the HTML segment (START / END)title - the title of the page, if null no title tag is insertedstylesheet - the used style sheet, if null the default stylesheet 'workplace.css' is inserted
public String paramsAsHidden()
public String paramsAsHidden(Collection excludes)
excludes - the parameters to exclude
public Map paramsAsParameterMap()
public String paramsAsRequest()
key1=value1&key2=value2 etc.
public String resolveMacros(String input)
The following macro contexts are available in the Workplace:
CmsObject).CmsMessages).getJsp()).
input - the input String containing the macros
CmsMacroResolver.resolveMacros(String)
public void sendCmsRedirect(String location)
throws IOException
location - the location the response is redirected to
IOException - in case redirection failspublic void setForwarded(boolean forwarded)
forwarded - the forwarded flag to setpublic String shortKey(String keyName)
keyName - name of the key
protected void addMessages(String bundleName)
bundleName - the bundle name to instanciateinitMessages()protected Map allParamValues()
protected String decodeParamValue(String paramName,
String paramValue)
In special cases some parameters might require a different-from-default encoding. This is the case if the content of the parameter was encoded using the JavaScript encodeURIComponent() method on the client, which always encodes in UTF-8.
paramName - the name of the parameterparamValue - the unencoded value of the parameter
protected Map getParameterMap()
This method will also handle parameters from forms
of type multipart/form-data.
protected void initMessages()
By default the workplace messages object is used.
You SHOULD override this method for setting the bundles you really need,
using the method.addMessages(String)
protected void initWorkplaceMembers(CmsJspActionElement jsp)
This method can be used in case there a workplace class was generated using
Class.forName(java.lang.String) to initialize the class members.
jsp - the initialized JSP context
protected abstract void initWorkplaceRequestValues(CmsWorkplaceSettings settings,
HttpServletRequest request)
settings - the workplace settingsrequest - the current requestprotected Map paramValues()
protected void switchToCurrentProject()
throws CmsException
CmsException - if switching back fails
protected int switchToTempProject()
throws CmsException
The id of the old project is stored in a member variable to switch back.
CmsException - if getting the tempfileproject id fails
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||