(Change order of sections) |
|||
Line 31: | Line 31: | ||
</source> | </source> | ||
* Similarily, some further adjustments of the <code>config.xml</code> file might be needed, like <code>baseUrl</code> and <code>baseDir</code> paths, for example. | * Similarily, some further adjustments of the <code>config.xml</code> file might be needed, like <code>baseUrl</code> and <code>baseDir</code> paths, for example. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Installing CKFinder as a JSP Page Tag == | == Installing CKFinder as a JSP Page Tag == | ||
Line 83: | Line 62: | ||
This code creates a CKFinder instance with a width of 700 pixels and height of 500 pixels. | This code creates a CKFinder instance with a width of 700 pixels and height of 500 pixels. | ||
+ | |||
+ | == Extending Configuration == | ||
+ | CKFinder implements some access control that is available from your application. You can create a class that inherits and extends the <code>Configuration</code> class. A sample code can be seen below: | ||
+ | |||
+ | <source lang="java"> | ||
+ | public class MyConfiguration extends Configuration { | ||
+ | |||
+ | public MyConfiguration(ServletConfig servletConfig) { | ||
+ | super(servletConfig); | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | public Boolean checkAuthentication() { | ||
+ | return false; | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | |||
+ | Special attention should be paid to the <code>checkAuthentication</code> method. It can be used to specify the pre-requisites (like administrator rights) that have to be met in order to make CKFinder available. | ||
+ | |||
+ | This option is obviously not the only one that you can control. You can override each of the <code>Configuration</code> class methods that represent CKFinder setting, including enabling and disabling CKFinder. | ||
+ | |||
+ | To make CKFinder aware of your custom configuration class, add the following to WEB-INF/web.xml: | ||
+ | <source lang="xml"> | ||
+ | <init-param> | ||
+ | <param-name>configuration</param-name> | ||
+ | <param-value>com.ckfinder.connector.MyConfiguration</param-value> | ||
+ | </init-param> | ||
+ | </source> |
Revision as of 22:29, 1 April 2011
Contents
This article describes various ways of integrating CKFinder for Java with your page.
Integrating CKFinder with your Application
After you download the CKFinder for Java .war
file, follow the steps below to integrate it with your application:
- Unpack CKFinder for Java.
- Copy the
ckfinder
folder to your application. - Copy the CKFinder
config.xml
file from itsWEB-INF
folder into theWEB-INF
folder of your application. - Copy the contents of the CKFinder
WEB-INF/lib
folder into theWEB-INF/lib
folder of your application. - Copy the
ConnectorServlet
settings from the CKFinderweb.xml
file to theweb.xml
file of your application. Note that the<servlet-class>
path and<url-pattern>
will need to be adjusted to your application.
<servlet> <servlet-name>ConnectorServlet</servlet-name> <servlet-class>com.ckfinder.connector.ConnectorServlet</servlet-class> <init-param> <param-name>XMLConfig</param-name> <param-value>/WEB-INF/config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>ConnectorServlet</servlet-name> <url-pattern> /ckfinder/core/connector/java/connector.java </url-pattern> </servlet-mapping>
- Just like in the sample application, by default CKFinder is disabled due to security reasons. To turn it on, change the
<enabled>
element value in theconfig.xml
file totrue
. Note that more sensitive authentication method by overriding thecheckAuthentication
method in recommended.
<enabled>true</enabled>
- Similarily, some further adjustments of the
config.xml
file might be needed, likebaseUrl
andbaseDir
paths, for example.
Installing CKFinder as a JSP Page Tag
In order to install CKFinder as a tag inside a .jsp
page, follow the steps outlined below:
- Install CKFinder as described in the section above.
- Copy the
ckfinder.tld
from theWEB-INF
folder of CKFinder and paste it into theWEB-INF
folder of your application. - In the
web.xml
file of your application add the following entry:
<jsp-config> <taglib> <taglib-uri>/WEB-INF/ckfinder</taglib-uri> <taglib-location>/WEB-INF/ckfinder.tld</taglib-location> </taglib> </jsp-config>
- In order to use the tag on the JSP page you should import the tag library by using the following directive:
<%@ taglib uri='../../WEB-INF/ckfinder.tld' prefix='ck' %>
You can now use the CKFinder tag on your JSP page in the following way:
<ck:ckfinder basePath="/CKFinderJava-1.0/ckfinder/" />
The only required attribute is the basePath
that specifies the path to the CKFinder folder. Numerous optional attributes are also available and can be used to customize CKFinder to your needs, like in the example below:
<ck:ckfinder basePath="/CKFinderJava-1.0/ckfinder/" width="700" height="500" />
This code creates a CKFinder instance with a width of 700 pixels and height of 500 pixels.
Extending Configuration
CKFinder implements some access control that is available from your application. You can create a class that inherits and extends the Configuration
class. A sample code can be seen below:
public class MyConfiguration extends Configuration { public MyConfiguration(ServletConfig servletConfig) { super(servletConfig); } @Override public Boolean checkAuthentication() { return false; } }
Special attention should be paid to the checkAuthentication
method. It can be used to specify the pre-requisites (like administrator rights) that have to be met in order to make CKFinder available.
This option is obviously not the only one that you can control. You can override each of the Configuration
class methods that represent CKFinder setting, including enabling and disabling CKFinder.
To make CKFinder aware of your custom configuration class, add the following to WEB-INF/web.xml:
<init-param> <param-name>configuration</param-name> <param-value>com.ckfinder.connector.MyConfiguration</param-value> </init-param>