Home  |  Software Components  |  Examples  |  Books  
   GO Custom Taglib -> Documentation   

GO Tag Library

Note: This library was created about a year before the Java Standard Tag Library (JSTL) was released. We recommend that you look at the new JSTL first since it makes many of these tags obsolete.

Introduction

This tag library contains a collection of custom action tags that simplifies use of the TVM bean in JavaServer PagesTM (JSP) and reduces the need for scripts. Even though they were designed with the TVM bean in mind, the tags are generic (except for getAmortization) and can be used with any bean. An example page shows how to use the library and tags within a simple JSP application.

The tags can be used to:

  • set, format, and display BigDecimal bean properties with localization.
  • invoke bean methods other than property getters/setters
  • display amortization tables from the TVM bean

 

Tag Descriptions

 

locale

The locale action tag creates a new Locale and places it in the specified scope. The locale created by this action can be used directly in the locale attribute of the getDecimalProperty and setDecimalProperty attribute tags.

If a reference with the same name (id) already exists within the scope, it will be replaced. Note that references with the same name can simultaneously exist in different scopes.

Syntax: <go:locale id=id {fromRequest=fromRequest} {language=language} {country=country} {variant=variant} {scope=scope} />

where:

attributedescriptionrequireddefault
idname of the reference to this localeyes none
fromRequestspecifies a default locale when the language attribute is missing.
  true - use the Locale specified in the request (usually the browser's preferred Locale).
  false - use the server's default locale
no false
languageTwo character ISO-639 language codeno (see fromRequest attribute)
countryTwo character ISO-3166 country code. The language attribute must be specified.no ""
variantAny string. The language and country attributes must also be specified.no none
scopeid reference will be placed in this scopeno page
changeResponseWhen true, the locale in the response object will be changed to this localenotrue

Examples:
<go:locale id="loc" language="fr" country="FR" />
<go:locale id="loc" fromRequest="true" />

 

getDecimalProperty

Retrieves a BigDecimal property from a bean and formats it according to the rules of the language and country specified by either the locale attribute or the default locale. At run time, the tag will be replaced by the formatted value of the property.

The number of decimal places and the rounding method can be specified by the scale and round optional attributes. The scale of the BigDecimal property is used if the scale attribute is omitted.

Syntax:
<go:getDecimalProperty name=name property=property {scale=scale} {round=round} {locale=locale} />

where:

attributedescriptionrequireddefault
namebean identifier that was specified in the id attribute of a useBean tag. yesnone
propertythe BigDecimal property to be setyesnone
scalenumber of positive decimal placesnoscale of property
roundtrue: round half up; false: round downnotrue
localescope variable that refers to a Locale objectnoserver default

Examples:
<jsp:useBean id="tvm" class="com.getobjects.tvm.TVM" />
<go:getDecimalProperty name="tvm" property="futureValue" />
 
<go:locale id="loc" language="fr" country="FR" />
<go:getDecimalProperty name="tvm" property="presentValue" scale="2" round="true" locale="loc" />

 

setDecimalProperty

Sets the BigDecimal property of a bean. At run time, the tag will change the state of the bean, but it does not produce any page content. The value to be set into the bean is taken from the numerical string of the value attribute if it is present, or else from a parameter of the request whose name matches the param attribute. If neither value or parm attributes are present, the property name itself will be used to find a matching name in the request. Wildcards in the property name (i.e property='*') are not supported in this release.

The number of decimal places and the rounding method can be specified by the scale and round optional attributes. The number of decimal places found in the value or parameter string is used if scale is omitted.

Syntax:
<go:setDecimalProperty name=name property=property {value=value} {param=param} {scale=scale} {round=round} {locale=locale} />

where:

attributedescriptionrequireddefault
namebean identifier that was specified the id attribute of a useBean tag.yesnone
propertyBigDecimal property to be setyesnone
valuenumerical stringnorequest param
paramrequest parameter namenoproperty name
scalenumber of positive decimal placesnoplaces in input string
roundtrue: round half up; false: round downnotrue
localescope variable that refers to a Locale objectnoserver default

Examples:
<jsp:useBean id="tvm" class="com.getobjects.tvm.TVM" />
<go:setDecimalProperty name="tvm" property="futureValue" value="100,000.00" />
<go:setDecimalProperty name="tvm" property="presentValue" param="PV" />
 
<go:locale id="loc" language="fr" country="FR" />
<go:setDecimalProperty name="tvm" property="presentValue" scale="2" round="true" locale="loc" />

 

press

The press action tag invokes a method in the bean referenced by the name attribute. The method must perform some behavior that changes the state of the bean, but doesn't accept parameters or return a value. In our TVM bean, it can be used to invoke methods such as: reset, clear, clearMessage, and computeProperty.

Syntax: <go:press name=name button=method />

where:

attributedescriptionrequireddefault
namebean identifier that was specified in the id attribute of a useBean tag. yes none
methodmethod in the bean with pattern: public void method()yes none

Examples:
<jsp:useBean id="tvm" class="com.getobjects.tvm.TVM" />
<go:press name="tvm" button="reset" />
<go:press name="tvm" button="computePayment" />

 

getAmortization (TVM Bean Only)

The getAmortization action tag can display an AmortizationSchedule of a TVM bean, version 1.2.0 or greater. The schedule is a list that contains an Amortization object for each payment period. Each Amortization object contains the principal, interest, and balance for that period. The tag iterates through the schedule making the Amortization object for each period available in the body of the tag. Typically, you would nest getDecimalProperty tags within the body of this tag to retrieve the values from the Amortization objects.

The sumPeriods attribute can be used to sum the interest and principal values for a range of periods. For example, if there are 360 monthly payment periods in the schedule, you might set sumPeriods to 12 to summarize the principal and interest paid during each year and to give the balance at the end of the range. In this example, the tag will create 30 iterations (one for each year).

You should set the presentValue, interestRate and numberOfPeriods properties and then invoke the computePayment method of the TVM bean before using this tag to display the AmortizationSchedule.

Syntax:
<go:getAmortization name=name id=id row=row {sumPeriods=sumPeriods} >
...body...
</go:getAmortization>

where:

attributedescriptionrequireddefault
namebean identifier that was specified in the id attribute of a useBean tag. The name must refer to a TVM bean, version 1.2.0 or greateryes none
idreference to the Amortization object for this iteration.yesnone
rowreference to a string that contains the iteration number. yesnone
sumPeriodsnumber of periods to summarize. If total periods in the schedule is not evenly divisible by this number, the last iteration will summarize to the end of the schedule.no1

Example:
<go:getAmortization name="tvm" id="amort" row="row" sumPeriods="12" >

<tr>
<td><%= row %></td>
<td><go:getDecimalProperty name="amort" property="principal" scale="2" /></td>
<td><go:getDecimalProperty name="amort" property="interest" scale="2" /></td>
<td><go:getDecimalProperty name="amort" property="balance" scale="2" /></td>
</tr>
</go:getAmortization>

 


Download | Version History | Wish List


 
Copyright ©1998-2004 GetObjects.com  All Rights Reserved
Privacy | Legal & Terms of Use | Trademarks | Feedback | About