Class FileViewerUtil
- java.lang.Object
-
- net.sf.basedb.clients.web.extensions.fileviewer.FileViewerUtil
-
public class FileViewerUtil extends Object
Helper class for handling the "file-viewer" extension point. AJspContext
andFileViewerContext
is needed. This class will initialize the extension point in the constructor. To invoke extensions, first update the FileViewerContext with the current file and other information and then callrender()
.- Since:
- 3.16
- Author:
- nicklas
-
-
Field Summary
Fields Modifier and Type Field Description private ExtensionsInvoker<ButtonAction>
fileActions
private FileViewerContext
fileContext
private JspContext
jspContext
private String
prefix
private String
suffix
-
Constructor Summary
Constructors Constructor Description FileViewerUtil(JspContext jspContext, FileViewerContext fileContext)
Deprecated.In 3.17, usegetOrCreate(JspContext, FileViewerContext)
instead
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FileViewerUtil
get(JspContext jspContext)
Get an existing instance that is stored in the given JSP context.FileViewerContext
getFileContext()
Get the file context.ExtensionsInvoker<ButtonAction>
getInvoker()
Get the invoker that is handling the extensions.JspContext
getJspContext()
Get the JSP context.static FileViewerUtil
getOrCreate(JspContext jspContext, FileViewerContext fileContext)
Get an existing instance or create a new instance.void
render()
Render the extensions with the current file context information and write it to the JSP output.String
renderAsString()
Render the extensions with the current file context information and return it as a string.void
setPrefixAndSuffix(String prefix, String suffix)
Sets a prefix and suffix string to use before and after the list of actions.
-
-
-
Field Detail
-
jspContext
private final JspContext jspContext
-
fileContext
private final FileViewerContext fileContext
-
fileActions
private final ExtensionsInvoker<ButtonAction> fileActions
-
prefix
private String prefix
-
suffix
private String suffix
-
-
Constructor Detail
-
FileViewerUtil
@Deprecated public FileViewerUtil(JspContext jspContext, FileViewerContext fileContext)
Deprecated.In 3.17, usegetOrCreate(JspContext, FileViewerContext)
instead
-
-
Method Detail
-
get
public static FileViewerUtil get(JspContext jspContext)
Get an existing instance that is stored in the given JSP context.- Returns:
- A FileViewerUtil instance or null
- Since:
- 3.17
-
getOrCreate
public static FileViewerUtil getOrCreate(JspContext jspContext, FileViewerContext fileContext)
Get an existing instance or create a new instance. If a new instance is created it is stored in the given JSP context ifExtensionsInvoker.getNumExtensions()
is more than 0.- Returns:
- A FileViewerUtil instance
- Since:
- 3.17
-
getFileContext
public FileViewerContext getFileContext()
Get the file context.
-
getJspContext
public JspContext getJspContext()
Get the JSP context.
-
getInvoker
public ExtensionsInvoker<ButtonAction> getInvoker()
Get the invoker that is handling the extensions.- Since:
- 3.17
-
setPrefixAndSuffix
public void setPrefixAndSuffix(String prefix, String suffix)
Sets a prefix and suffix string to use before and after the list of actions. The default is "[" and "]".
-
render
public void render() throws IOException
Render the extensions with the current file context information and write it to the JSP output.- Throws:
IOException
-
renderAsString
public String renderAsString()
Render the extensions with the current file context information and return it as a string. Returns an empty string if there are no actions.
-
-