Get Property taglib ver. 1.3


    Gets the value of a Bean property so that you can display it in a result page. Taglib mimics jsp:getProperty and adds a list of useful features. You can control the output if your bean or property does not exist, tag works with HasMap (Hashtable) as well as with indexed properties. For example:
 


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

<jsp:useBean id="calendar" scope="page" class="employee.Calendar" />
Calendar of <g:getProperty name="calendar" property="username" />

The getProperty element gets a Bean property value using the property's getter methods and displays the property value in a JSP page (saves in the page scope variable). If your bean is HashMap (Hashtable) tag threats property as a key and uses get method. Tag prints nothing if bean (property) does not exist or the calculated value is null.

Actually this tag is a body tag. You you can define how your outputs will looks like:
 


<g:getProperty name="calendar" property="username">
   value="<%=propertyValue%>"
</g:getProperty>

here propertyValue is a predefined nested page scope variable with the calculated value.

Tags are:

getProperty

Body tag getProperty gets a Bean property value using the property's getter methods. Parameters are:

1) name The name of an object (usually an instance of a Bean)
2) property The name of the Bean property (or key for HashMap). The property is declared as a variable in a Bean and must have a corresponding getter method.
3) defaultValue Optional parameter. Describes a default value if bean (property) does not exist. By default is empty (blank string).
4) index Optional parameter. Describes an index for indexed properties
5) id Optional parameter. Describes a name for page scope variable (type is java.lang.Object) for the calculated data. Without this parameter tag just prints data.

for downloading:

Library: getproptag.jar    Description: taglib.tld

© Coldbeans      Comments?

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

Also in Coldtags: