📄 cmsjspactionelement.java
字号:
}
try {
return CmsJspTagLabel.wpLabelTagAction(label, getRequest());
} catch (Throwable t) {
handleException(t);
}
CmsMessageContainer msgContainer = Messages.get().container(Messages.GUI_ERR_WORKPL_LABEL_READ_1, label);
return getMessage(msgContainer);
}
/**
* Calculate a link with the OpenCms link management,
* same as using the <code><cms:link>***</cms:link></code> tag.<p>
*
* This is important to get the right link for exported resources,
* e.g. for images in the online project.
*
* @param link the uri in the OpenCms to link to
* @return the translated link
*
* @see org.opencms.jsp.CmsJspTagLink
*/
public String link(String link) {
if (isNotInitialized()) {
return getMessage(NOT_INITIALIZED);
}
try {
return CmsJspTagLink.linkTagAction(link, getRequest());
} catch (Throwable t) {
handleException(t);
}
CmsMessageContainer msgContainer = Messages.get().container(Messages.GUI_ERR_GEN_LINK_1, link);
return getMessage(msgContainer);
}
/**
* Returns all properites of the current file.<p>
*
* @return Map all properties of the current file
*/
public Map properties() {
return properties(null);
}
/**
* Returns all properites of the selected file.<p>
*
* Please see the description of the class {@link org.opencms.jsp.CmsJspTagProperty} for
* valid options of the <code>file</code> parameter.<p>
*
* @param file the file (or folder) to look at for the properties
* @return Map all properties of the current file
* (and optional of the folders containing the file)
*
* @see org.opencms.jsp.CmsJspTagProperty
*/
public Map properties(String file) {
if (isNotInitialized()) {
return new HashMap();
}
Map value = new HashMap();
try {
if (file == null) {
file = CmsJspTagProperty.USE_URI;
}
switch (CmsJspTagProperty.ACTION_VALUES_LIST.indexOf(file)) {
case 0: // USE_URI
case 1: // USE_PARENT
value = CmsProperty.toMap(getCmsObject().readPropertyObjects(getRequestContext().getUri(), false));
break;
case 2: // USE_SEARCH
case 3: // USE_SEARCH_URI
case 4: // USE_SEARCH_PARENT
value = CmsProperty.toMap(getCmsObject().readPropertyObjects(getRequestContext().getUri(), true));
break;
case 5: // USE_ELEMENT_URI
case 6: // USE_THIS
// Read properties of this file
value = CmsProperty.toMap(getCmsObject().readPropertyObjects(
getController().getCurrentRequest().getElementUri(),
false));
break;
case 7: // USE_SEARCH_ELEMENT_URI
case 8: // USE_SEARCH_THIS
// Try to find property on this file and all parent folders
value = CmsProperty.toMap(getCmsObject().readPropertyObjects(
getController().getCurrentRequest().getElementUri(),
true));
break;
default:
// Read properties of the file named in the attribute
value = CmsProperty.toMap(getCmsObject().readPropertyObjects(toAbsolute(file), false));
}
} catch (Throwable t) {
handleException(t);
}
return value;
}
/**
* Returns a selected file property value, same as using
* the <code><cms:property name="***" /></code> tag or
* calling {@link #property(String, String, String, boolean)}.<p>
*
* @param name the name of the property to look for
* @return the value of the property found, or null if the property could not be found
*
* @see #property(String, String, String, boolean)
* @see org.opencms.jsp.CmsJspTagProperty
*/
public String property(String name) {
return property(name, null, null, false);
}
/**
* Returns a selected file property value, same as using
* the <code><cms:property name="***" file="***" /></code> tag or
* calling {@link #property(String, String, String, boolean)}.<p>
*
* @param name the name of the property to look for
* @param file the file (or folder) to look at for the property
* @return the value of the property found, or null if the property could not be found
*
* @see #property(String, String, String, boolean)
* @see org.opencms.jsp.CmsJspTagProperty
*/
public String property(String name, String file) {
return property(name, file, null, false);
}
/**
* Returns a selected file property value, same as using
* the <code><cms:property name="***" file="***" default="***" /></code> tag or
* calling {@link #property(String, String, String, boolean)}.<p>
*
* @param name the name of the property to look for
* @param file the file (or folder) to look at for the property
* @param defaultValue a default value in case the property was not found
* @return the value of the property found, or the value of defaultValue
* if the property could not be found
*
* @see #property(String, String, String, boolean)
* @see org.opencms.jsp.CmsJspTagProperty
*/
public String property(String name, String file, String defaultValue) {
return property(name, file, defaultValue, false);
}
/**
* Returns a selected file property value with optional HTML escaping, same as using
* the <code><cms:property name="***" file="***" default="***" /></code> tag.<p>
*
* Please see the description of the class {@link org.opencms.jsp.CmsJspTagProperty} for
* valid options of the <code>file</code> parameter.<p>
*
* @param name the name of the property to look for
* @param file the file (or folder) to look at for the property
* @param defaultValue a default value in case the property was not found
* @param escapeHtml if <code>true</code>, special HTML characters in the return value
* are escaped with their number representations (e.g. & becomes &#38;)
* @return the value of the property found, or the value of defaultValue
* if the property could not be found
*
* @see org.opencms.jsp.CmsJspTagProperty
*/
public String property(String name, String file, String defaultValue, boolean escapeHtml) {
if (isNotInitialized()) {
return getMessage(NOT_INITIALIZED);
}
try {
if (file == null) {
file = getController().getCmsObject().getRequestContext().getUri();
}
return CmsJspTagProperty.propertyTagAction(name, file, defaultValue, escapeHtml, getRequest());
} catch (CmsSecurityException e) {
if (defaultValue == null) {
handleException(e);
}
} catch (Throwable t) {
handleException(t);
}
if (defaultValue == null) {
CmsMessageContainer msgContainer = Messages.get().container(
Messages.GUI_ERR_FILE_PROP_MISSING_2,
name,
file);
return getMessage(msgContainer);
} else {
return defaultValue;
}
}
/**
* Checks if a template part should be used or not, same as using
* the <code><cms:template element="***" /></code> tag.<p>
*
* @param element the template element to check
* @return <code>true</code> if the element is active, <code>false</code> otherwise
*
* @see org.opencms.jsp.CmsJspTagUser
*/
public boolean template(String element) {
return template(element, null, false);
}
/**
* Checks if a template part should be used or not, same as using
* the <code><cms:template ifexists="***" /></code> tag.<p>
*
* @param elementlist the list of elements to check
* @param checkall <code>true</code> if all elements in the list should be checked
* @return <code>true</code> if the elements available, <code>false</code> otherwise
*
* @see org.opencms.jsp.CmsJspTagUser
*/
public boolean template(String elementlist, boolean checkall) {
return template(null, elementlist, checkall);
}
/**
* Checks if a template part should be used or not, same as using
* the <code><cms:template element="***" ifexists="***" /></code> tag.<p>
*
* @param element the template element to check
* @param elementlist the list of elements to check
* @param checkall <code>true</code> if all elements in the list should be checked
* @return <code>true</code> if the element is active, <code>false</code> otherwise
*
* @see org.opencms.jsp.CmsJspTagUser
*/
public boolean template(String element, String elementlist, boolean checkall) {
if (isNotInitialized()) {
return true;
}
try {
return CmsJspTagTemplate.templateTagAction(element, elementlist, checkall, false, getRequest());
} catch (Throwable t) {
handleException(t);
}
return true;
}
/**
* Converts a relative URI in the OpenCms VFS to an absolute one based on
* the location of the currently processed OpenCms URI.<p>
*
* @param target the relative URI to convert
* @return the target URI converted to an absolute one
*/
public String toAbsolute(String target) {
if (isNotInitialized()) {
return getMessage(NOT_INITIALIZED);
}
return CmsLinkManager.getAbsoluteUri(target, getController().getCurrentRequest().getElementUri());
}
/**
* Returns a selected user property, i.e. information about the currently
* logged in user, same as using
* the <code><cms:user property="***" /></code> tag.<p>
*
* @param property the user property to display, please see the tag documentation for valid options
* @return the value of the selected user property
*
* @see org.opencms.jsp.CmsJspTagUser
*/
public String user(String property) {
if (isNotInitialized()) {
return getMessage(NOT_INITIALIZED);
}
try {
return CmsJspTagUser.userTagAction(property, getRequest());
} catch (Throwable t) {
handleException(t);
}
CmsMessageContainer msgContainer = Messages.get().container(Messages.GUI_ERR_USER_PROP_READ_1, property);
return getMessage(msgContainer);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -