Edit div taglib ver. 1.3


    Custom JSP taglib lets you provide an editable area. It is a standard div area that you can edit in-place. For example:
 


<script language="JavaScript" src="cjajax.js"></script>

<%@ taglib uri="taglib.tld" prefix="e" %>

<e:EditDiv id="d1" style="width:200px">
  you can edit this content
</e:EditDiv>

and you will get the following picture:

you can edit this content

Try to move the mouse over this area. The background color will be changed (it is an attribute activeColor). Try to click on this area. You will see now the textarea where your content could be updated. And your updates could be posted back to your server side via Ajax POST. You have two options for setting target server-side script: set it via tag's attribute url or create some JavaScript function that calculates URL dynamically and provide a name for that function via tag's attribute urlFunction.

In order to use this tag you have to describe an external JavaScript file cjajax.js on your page.

Edit area could be customized (see attributes editStyle and editClassName). Your updates could be posted via Ajax to your servlet (JSP). You can provide either url or JavaScript function that will return an url (see JavaScript link taglib also):
 


<script language="JavaScript" src="cjajax.js"></script>

<%@ taglib uri="taglib.tld" prefix="e" %>

<e:EditDiv id="d1" url="/servlet/MVC" style="width:200px">
  you can edit this content and post it to /servlet/MVC
</e:EditDiv>

Your server side stuff will get HTTP POST request where parameter name corresponds to the id of your area: id_content. E.g. in the above-mentioned example this name will be d1_content (div's id is d1).

After the posting tag will show in the area content returned by your server side. If your servlet (JSP page) will return an empty value than tag will simply show the updated content.

Tags are:

EditDiv

Body tag defines a div block that could be edit in-place. Parameters are:

1) id Describes a CSS (DHTML) id.
2) url Optional parameter. Describes an URL for your requests.
3) urlFunction Optional parameter. Describes a JavaScript function that will return an URL for Ajax call.
4) className Optional parameter. Describes your own CSS class for this area.
5) style Optional parameter. Describes your own CSS style for this area.
6) error Optional parameter. Describes a name for your own JavaScript function that will be called in case of errors. By default is empty.
7) editClassName Optional parameter. Describes your own CSS class for the edit area.
8) editStyle Optional parameter. Describes your own CSS style for the edit area.
9) activeColor Optional parameter. Describes a color that will be used when mouse is over your area. Default value is yellow.
10) cond Optional parameter. Describes a boolean value tag's behavior depends on. Default value is true (allow edit).
 

for downloading:

 Library: editdivtag.jar     Description: taglib.tld  JavaScript library: cjajax.js

 © Coldbeans      Comments?

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

Also in Coldtags: