Edit file taglib ver. 1.3


    Custom JSP taglib - widget for text files. Lets you add a simple text editor to your web applications. For example the following code lets you edit a file /WEB-INF/web.xml
 


<%@ taglib uri="taglib.tld" prefix="e" %>
<e:EditFile file="/WEB-INF/web.xml"/>

and you will get this:


Attributes className and style lets you provide custom CSS settings for edit area. By default taglib uses build-in servlet for saving data. You have to describe it in your web.xml file:
 


<servlet>
  <servlet-name>SaveFileServlet</servlet-name>
  <servlet-class>com.cj.edit.SaveFileServlet</servlet-class>
</servlet>

You can provide JavaScript callbacks for this saving procedure. Attribute beforeSave describes a name for JavaScript function that will be called at the beginning. Attribute afterSave describes a name for JavaScript function that will be called at the end. So you can show/hide for example process indicator. Attribute callback describes a name for JavaScript function lets you display/process a result of saving. This function accepts text parameter indicates how many bytes were saved. A negative value means some error. For example:
 


<script language="JavaScript">
function f(amount)
{
if (eval(amount)<0) alert("Error!");
else alert("Success");
}
</script>

<e:EditFile file="myfile.jsp" callback="f"/>

Also you can provide your own server-side script (servlet, JSP etc.) for data saving (attribute action). This script (servlet) will get the following parameters in HTTP POST:

fileName - file name
directory - directory this file belongs to
fileContent - text for saving

Tags are:

EditFile

Body tag implements Edit File widget. Attributes are:

1) file describes an URI for your file.
2) className Optional attribute. Describes a CSS class for edit area
3) style Optional attribute. Describes a CSS style for edit area
4) showFileName Optional attribute. Lets you show/hide file name. Possible values are true or false. Default value is true - show file name.
5) fileClassName Optional attribute. Describes a CSS class for file name field
6) fileStyle Optional attribute. Describes a CSS style for file name field
7) beforeSave Optional attribute. Describes a JavaScript callback. By default is empty
8) afterSave Optional attribute. Describes a JavaScript callback. By default is empty
9) callback Optional attribute. Describes a JavaScript callback for build-in servlet
10) action Optional attribute. Describes an URI for custom CGI-script (servlet) that will save data
11) target Optional attribute. Describes a target frame for sutom saving
12) readonly Optional attribute. Describes a readonly attribute for edit area. Default values is false.
13) disabled Optional attribute. Describes a disabled attribute for edit area. Default values is false.

for downloading:

Library: editfiletag.jar    Description: taglib.tld

 © Coldbeans      Comments?

See also Coldtags suite - the largest collection of custom JSP tags.

Also in Coldtags: