Provides custom tags for information from an asset database to be inserted into a JSP. In this environment, custom tags are typically either models or views. The custom tag Asset is a model type of custom tag. The AssetDatabase custom tag is more of an environment setting/ease-of-use type of tag.

AssetDatabase
In populating a JSP with Asset custom tags, you may discover that database= had to be specified for every tag. In a scenario in which you have only one asset database, the repetition is not particularly productive. The AssetDatabase custom tag was designed as a tag to wrap around a collection of  Asset tags, which would then inherit the value of database.

Asset
Transformation beans can pair up with a variety of models, several of which access the asset database. Currently the only two transformation beans that interact with the asset database models are Image and StaticText. Both of these beans may have a link to another URL or not. Therefore, as of now there are four models that access the asset database that you can use:

  1. AssetImageModelAdapter - provides a reference to the image picture and optional alternate text
  2. AssetImageLinkModelAdapter - provides a reference to the image picture, optional alternate text, and a link to another URL when the image is selected.
  3. AssetStaticTextModelAdapter - provides a reference to a text string
  4. AssetTextLinkModelAdapter - provides a reference to a text and a link to another URL when the text is selected.

The model that you select for the Asset tag is specified in the type= parameter:

Use this type... ...to get this model
image AssetImageModelAdapter
imagelink AssetImageLinkModelAdapter
text AssetStaticTextModelAdapter
link AssetTextLinkModelAdapter

In addition, there are lookup parameters used to narrow down the search in the asset database. One is the elementName. Each web element defined in the asset database has a unique name, and doing the lookup based on elementName will return just those portions of the web element that you need. elementID works in a similar fashion; the elementID is a number or GUID generated when the web element is defined by collect the assets it needs from the image table, the text table, and the URL table of the asset database. The third form of lookup is by content or by content and usage. This type of lookup retrieves any assets that fit the search criteria requirements and forms them into web elements, whether the assets were initially defined as part of a web element or not, and can retrieve the latest assets entered into the database.

Usage
The Asset custom tags may either precede the transformation bean that they're paired with or be nested inside the transformation bean. These are examples of the Asset tag preceding the transformation bean.

<sasads:Asset id="foundations" elementName="Foundations" database="Pubcat" type="imagelink" />
<sasads:Image useAsFormElement="false" model="foundations" />

places an image on the page and gives it a URL to go to if selected. The entry in the asset database will be found under the name Foundations. The Image transformation bean will find the asset model under the name foundations.

<sasads:Asset id="empire" elementName="Empire" database="Pubcat" type="link" />
<sasads:StaticText model="empire" />

places some text on the page and gives it a URL to go to if selected. The entry in the asset database will be found under the name Empire. The StaticText transformation bean will find the asset model under the name empire.

<sasads:Asset id="book" database="Pubcat" content="55073" type="image" />
<sasads:Image useAsFormElement="false" model="book" />

places an image on the page with no URL to go to if selected. The entry in the asset database will be found under the content value 55073. The Image transformation bean will find the asset model under the name book.

These are the same examples with the model nested inside the transformation bean:

<sasads:Image useAsFormElement="false" >
<sasads:Asset elementName="Foundations" database="Pubcat" type="imagelink" />
<sasads:Image />

<sasads:StaticText >
<sasads:Asset elementName="Empire" database="Pubcat" type="link" />
<sasads:StaticText />

<sasads:Image useAsFormElement="false" >
<sasads:Asset database="Pubcat" content="55073" type="image" />
<sasads:Image />

Note that model= is missing from the transformation bean tags and id= is missing from the Asset tags.

The AssetDatabase tag eliminates repetitive references to the asset database name by specifying it once in this tag and then wrapping this tag around Asset tags. This is the same example as the first one, wrapped by an AssetDatabase tag.

<sasads:AssetDatabase database="Pubcat" >
<sasads:Asset id="foundations" elementName="Foundations" type="imagelink" />
<sasads:Image useAsFormElement="false" model="foundations" />
<sasads:Asset id="empire" elementName="Empire" type="link" />
<sasads:StaticText model="empire" />
<sasads:Asset id="book" content="55073" type="image" />
<sasads:Image useAsFormElement="false" model="book" />
<sasads:AssetDatabase />


Key Classes
The following are the key classes in the com.sas.taglib.assets package:

  1. AssetTag - sets up a model for resources from the asset database to be used by view custom tags, such as those supported by transformation beans.
  2. AssetDatabase - specifies the name of the asset database; other custom tags may be nested inside which would inherit the name of the database.