Package com.jalios.jcms.taglib
Class MediaTag
- java.lang.Object
-
- javax.servlet.jsp.tagext.TagSupport
-
- com.jalios.jcms.taglib.MediaTag
-
- All Implemented Interfaces:
java.io.Serializable
,javax.servlet.jsp.tagext.IterationTag
,javax.servlet.jsp.tagext.JspTag
,javax.servlet.jsp.tagext.Tag
public class MediaTag extends javax.servlet.jsp.tagext.TagSupport
Print the HTML required to provide a media player for any file.- Since:
- jcms-6.1
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CSS
Request attribute name to retrieve the css classes to be displayed, might be null.static java.lang.String
HTML_ATTRIBUTES
Request attribute name to retrieve the html attributes to be displayed, might be null.static java.lang.String
MEDIA_DATA
Request attribute name to retrieve the Data to be displayed, might be null.static java.lang.String
MEDIA_DESCRIPTION
Request attribute name to retrieve the description to be displayed, might be null.static java.lang.String
MEDIA_MAX_HEIGHT
Request attribute name to retrieve the maximum height of the media file to be displayed.static java.lang.String
MEDIA_MAX_WIDTH
Request attribute name to retrieve the maximum width of the media file to be displayed.static java.lang.String
MEDIA_PATH
Request attribute name to retrieve the path of the media file to be displayed.static java.lang.String
REVISION
-
Constructor Summary
Constructors Constructor Description MediaTag()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description int
doEndTag()
int
doStartTag()
static java.lang.String
getMediaTemplatePath(java.lang.String templateName, Data data)
Deprecated.use insteadMediaManager.getMediaTemplatePath(String, Data)
static java.lang.String
getMediaTemplatePath(java.lang.String templateName, java.lang.String mediaPath, java.lang.String mediaContentType)
Deprecated.void
includeMediaTemplate()
Include the JSP suitable to display the specified media.void
setCss(java.lang.String css)
Sets optional css classes to the main html attribute provided by the media template jspvoid
setData(Data data)
void
setDescription(java.lang.String mediaDescription)
Sets a optional description to use in appropriate HTML attribute if any (img alt text, title or such).void
setFile(java.io.File file)
void
setFileDoc(FileDocument fileDoc)
void
setHtmlAttributes(java.lang.String htmlAttributes)
Sets optional html attributes tag to the main html attribute provided by the media template jsp (Video tag or other html5 tag)void
setMaxHeight(int height)
void
setMaxWidth(int width)
void
setPath(java.lang.String path)
void
setTemplate(java.lang.String templateName)
Sets the name of the template to be used by this tag.
-
-
-
Field Detail
-
REVISION
public static final java.lang.String REVISION
- See Also:
- Constant Field Values
-
MEDIA_PATH
public static final java.lang.String MEDIA_PATH
Request attribute name to retrieve the path of the media file to be displayed.String path = (String) request.getAttribute(MediaTag.MEDIA_PATH);
- See Also:
- Constant Field Values
-
MEDIA_MAX_WIDTH
public static final java.lang.String MEDIA_MAX_WIDTH
Request attribute name to retrieve the maximum width of the media file to be displayed.int maxWidth = Util.toInt(request.getAttribute(MediaTag.MEDIA_MAX_WIDTH), 320);
- See Also:
- Constant Field Values
-
MEDIA_MAX_HEIGHT
public static final java.lang.String MEDIA_MAX_HEIGHT
Request attribute name to retrieve the maximum height of the media file to be displayed.int maxHeight = Util.toInt(request.getAttribute(MediaTag.MEDIA_MAX_HEIGHT), 240);
- See Also:
- Constant Field Values
-
MEDIA_DATA
public static final java.lang.String MEDIA_DATA
Request attribute name to retrieve the Data to be displayed, might be null.Data data = (Data) request.getAttribute(MediaTag.MEDIA_DATA);
- See Also:
- Constant Field Values
-
MEDIA_DESCRIPTION
public static final java.lang.String MEDIA_DESCRIPTION
Request attribute name to retrieve the description to be displayed, might be null.String mediaDescription = (String) request.getAttribute(MediaTag.MEDIA_DESCRIPTION);
- Since:
- jcms-7.1.2 (improvement JCMS-3003)
- See Also:
- Constant Field Values
-
HTML_ATTRIBUTES
public static final java.lang.String HTML_ATTRIBUTES
Request attribute name to retrieve the html attributes to be displayed, might be null.String htmlAttributes = (String) request.getAttribute(MediaTag.HTML_ATTRIBUTES);
- Since:
- jcms-10.0.5
- See Also:
- Constant Field Values
-
CSS
public static final java.lang.String CSS
Request attribute name to retrieve the css classes to be displayed, might be null.String css = (String) request.getAttribute(MediaTag.CSS);
- Since:
- jcms-10.0.6
- See Also:
- Constant Field Values
-
-
Method Detail
-
setData
public void setData(Data data)
-
setFileDoc
public void setFileDoc(FileDocument fileDoc)
-
setPath
public void setPath(java.lang.String path)
-
setFile
public void setFile(java.io.File file)
-
setMaxWidth
public void setMaxWidth(int width)
-
setMaxHeight
public void setMaxHeight(int height)
-
setTemplate
public void setTemplate(java.lang.String templateName)
Sets the name of the template to be used by this tag.See properties
media.template.{templateName}.{type-mime}
injcms.prop
for example on how to define new templates.- Parameters:
templateName
- a template name (default value is "default").- Since:
- jcms-6.1.2 (fix bug JCMS-2105)
-
setDescription
public void setDescription(java.lang.String mediaDescription)
Sets a optional description to use in appropriate HTML attribute if any (img alt text, title or such).If empty, the data's name or the media's path is used.
- Parameters:
mediaDescription
- a short description for use in HTML attributes- Since:
- jcms-7.1.2 (improvement JCMS-3003)
-
setHtmlAttributes
public void setHtmlAttributes(java.lang.String htmlAttributes)
Sets optional html attributes tag to the main html attribute provided by the media template jsp (Video tag or other html5 tag)- Parameters:
htmlAttributes
- a String representing additional html attributes to add to the produced media tag- Since:
- jcms-10.0.6
-
setCss
public void setCss(java.lang.String css)
Sets optional css classes to the main html attribute provided by the media template jsp- Parameters:
css
- a String representing additional html attributes to add to the produced media tag- Since:
- jcms-10.0.6
-
doStartTag
public int doStartTag() throws javax.servlet.jsp.JspException
- Specified by:
doStartTag
in interfacejavax.servlet.jsp.tagext.Tag
- Overrides:
doStartTag
in classjavax.servlet.jsp.tagext.TagSupport
- Throws:
javax.servlet.jsp.JspException
-
doEndTag
public int doEndTag()
- Specified by:
doEndTag
in interfacejavax.servlet.jsp.tagext.Tag
- Overrides:
doEndTag
in classjavax.servlet.jsp.tagext.TagSupport
-
includeMediaTemplate
public void includeMediaTemplate() throws javax.servlet.ServletException, java.io.IOException
Include the JSP suitable to display the specified media.- Throws:
java.io.IOException
- if such an exception occursjavax.servlet.ServletException
- if such an exception occurs- See Also:
MediaManager
-
getMediaTemplatePath
@Deprecated public static java.lang.String getMediaTemplatePath(java.lang.String templateName, java.lang.String mediaPath, java.lang.String mediaContentType)
Deprecated.Retrieve the path of the JSP suitable to display the specified media.- Parameters:
templateName
- the name of the template to retrievemediaPath
- the path of the media to display, relative to the webapp root (eg. upload/docs/myfile.ext) can also be an URL such ashttps://www.youtube.com/watch?v=abc
(if supported in template declarations)mediaContentType
- the content type of the media to display (eg. image/jpeg)- Returns:
- the relative path of the Media JSP template to use to display the specified media, may return null if no suitable template was find for the media
-
getMediaTemplatePath
@Deprecated public static java.lang.String getMediaTemplatePath(java.lang.String templateName, Data data)
Deprecated.use insteadMediaManager.getMediaTemplatePath(String, Data)
Retrieve the path of the JSP suitable to display the specified Data.- Parameters:
templateName
- the name of the template to retrievedata
- the Data to display- Returns:
- the relative path of the Media JSP template to use to display the specified Data
-
-