Chapter 17. Expresso Taglib Descriptions

Table of Contents

Introduction
Tag Library Descriptor
Expresso Extended Struts Tags
Expresso Bean Tag Library (WEB-INF/tld/expresso-bean.tld)
Expresso HTML Tags (WEB-INF/tld/expresso-html.tld)
Expresso Logic Tags (WEB-INF/tld/expresso-logic.tld)
How to Use Struts Tags in Expresso
Expresso Tag Library (WEB-INF/tld/expresso.tld)
Example JSP code
Expresso Tags Described
Expresso Library Tag Details
ActionTag - Renders an Expresso action, and associated hidden fields
AttributeTag - Displays an attribute from an Input or Output object
Back - Displays a "Back" button or image to go back to a page
Block - Acts as a container for child InputTag, OutputTag,TransitionTag and Block tags
config - Defines a scripting variable based on the specified values
ContentTag - Displays an Expresso Output element's Contents field.
Context - Inserts the web-app context
DBDescription - Displays the description text for the current DB context
DBMaint - Includes a row with calls to DBMaint for a dbobject
ElementCollection - Retrieves a collection of a controller elements that can later be iterated through using the ElementIterator tag
ElementIterator - iterates through each controller element inside a parent ElementCollection tag
ErrorMessages - Displays an Expresso Error Collection from the Message Bundle
ErrorTag - Displays an Expresso Error Collection
IfElementExists - Checks if a particular controller element exists.
IfErrorExists - Checks if the controller generated errors and stored it in the page context.
IfLoggedIn - Checks if a session is established and a valid user is logged in.
IfMemberOfGroup - Checks if the user logged in has access to the specified group
InputTag - Displays an Expresso Input Object
LabelTag - Prints the label of a controller element
Login - Tries to make the user log in
output - Defines a scripting variable based on the specified values
OutputTag - Displays an Expresso Output Element
RestrictAccess - Allows quick and dirty restriction of access to jsp pages
session - Defines a scripting variable based on the specified values
setup - Defines a scripting variable based on the specified values
TableHead - Displays a pipe-delimited string as a table header
TransitionTag - Displays an Expresso Transition Button
TransitionParamsTag - Displays the parameters with an Expresso Transition
UserName - Displays the logged in user-name
Conclusion
Contributors

Note

If you find this EDG documentation helpful please consider DONATING! to keep the doc alive and current.

 Maintainer:Turgay Zengin

Introduction

Expresso Taglibs is a custom tag library. Expresso of course extends the Struts and JSTL, including an Action, Input, and Error tag that make page design much easier and cleaner.

These tags are fairly simple and work well. Give them a try. You will find that after you create one page with them, you will never go back to the old way. They make a HUGE difference!

Tag Library Descriptor

Also included is the tag library descriptor, expresso.tld, under the /WEB-INF/ directory in CVS. If you have questions about which options are required, optional, etc., just scan the expresso.tld. This expresso.tld should be placed in your WEB-INF/ directory. Then, edit your web.xml file to include this:

<taglib>
        <taglib-uri>/expresso</taglib-uri>

        <taglib-location>/WEB-INF/expresso.tld</taglib-location>
</taglib>
This is also done in the web.xml file in CVS.

Quick usage: Include this at the top of the page:

<%@ taglib uri="/expresso" prefix="expresso" %>
and then the tags wherever you want them.

Note

The custom tags make some assumptions about how your jsp page is defined. One important assumption is that your controller is called "controller" in the jsp page (jsp:useBean id="controller" scope="session" class="myControllerClass" /). If you have used an id in your usebean tag that is something other then "controller", then you need to specify the controller name to each of your expresso tags as an argument, like: <expresso:InputTag name="expresso.input.first_name" controller="mycontrollername" />

Expresso Extended Struts Tags

Expresso applications can take advantage of all of the standard Struts tag libraries. Expresso has also extended a number or Struts Tags. This section describes how to make maximum use of the Struts taglib capabilities in Expresso. The 5.5 release is integrated with Struts 1.1.

Special extensions are available to some tags to allow them access to the ControllerResponse object returned by a Controller after it's execution. Although it is possible to write an ActionForm bean and use the standard Struts tag libraries to access properties from this bean, these "extended" tags allow direct access to the ControllerResponse and it's Inputs, Outputs, Transitions and Blocks. For convenience, the extended tag libraries include definitions for the Struts tags that are *not* extended as well, simply referring to the same classes as the corresponding Struts .tld file would - this allows use of the entire collection of tags without having to import both tag libraries. The following extended tag libraries are available (click definition for detailed documentation on each):

Table 17.1. Extended Tag Libraries

DefinitionsDescriptionPackage
WEB-INF/tld/expresso-bean.tldExpresso-aware bean tags, allowing easy access to write contents of Output objects and various attributes of other ControllerElements found in the ControllerResponse.com.jcorporate.expresso.ext.struts.taglib.bean
WEB-INF/tld/expresso-html.tldExpresso-aware HTML tags, particularly tags used to produce various types of input fields for use in HTML forms.com.jcorporate.expresso.ext.struts.taglib.html
WEB-INF/tld/expresso-logic.tldExpresso-aware logic tags, allowing the presence or absence of specific ControllerElements to be tested for, and iterations across nested elements to be performed.com.jcorporate.expresso.ext.struts.taglib.logic
WEB-INF/tld/expresso.tldExpresso tags that are independant of the Struts tag libraries, allowing acces to various ControllerElements and Expresso-specific logic.com.jcorporate.expresso.ext.taglib

It is also possible to use both the extended tags and the standard Struts tags within the same jsp (simply declaring a separate prefix for tags with the same name), for those applications where this is appropriate. For example, you might have this code in your JSP: <%@ taglib uri="/WEB-INF/tld/expresso-bean.tld" prefix="exbean" %> <%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>

You would then be able to use <bean:write ...> to refer to the standard Struts "write" tag, and <exbean:write ...> to refer to the extended "Expresso-aware" "write" tag, both in the same JSP.

Expresso Bean Tag Library (WEB-INF/tld/expresso-bean.tld)

This tag library defines Expresso-aware bean tags, allowing easy access to write contents of Output objects and various attributes of other ControllerElements found in the ControllerResponse. /home/expresso/expresso/expresso-web/WEB-INF/classes/com/jcorporate/expresso/ext/struts/taglib/bean/ExWriteTag.java

Expresso HTML Tags (WEB-INF/tld/expresso-html.tld)

This tag library extends selected Struts HTML tags, creating Expresso-aware HTML tags, particularly tags used to produce various types of input fields for use in HTML forms. The package extends the following tags:

Table 17.2. Expresso HTML Tags

Tag NameDescription
ExBaseFieldTagAn extension of BaseFieldTag to create Expresso-aware versions of tags that inherit from this class.
ExCheckboxTagTag for rendering Checkbox input fields from Input elements.
ExSelectTagTag for rendering Select lists (drop-down lists) from Input elements.
ExSubmitTag 
FileTag 
HiddenTag 
PasswordTag 
TextTag 

For each of the above tags, the attributes and usage of the tag is identical to the Struts tag that it extends, with one exception: the "property" attribute, instead of referring to a property of the current ActionForm bean, refers instead to an Input element of the current ControllerResponse. The property field can contain an XPath-like "controller element path", as described here, to refer to nested ControllerElements and sub-properties of those elements.

Expresso Logic Tags (WEB-INF/tld/expresso-logic.tld)

This tag library contains extensions of a few of the Struts "logic" tags, making them "aware" of Expresso's ControllerResponse object.

Table 17.3. Expresso Logic Tags

Tag NameDescription
ExNotPresentTag/home/expresso/expresso/expresso-web/WEB-INF/classes/com/jcorporate/expresso/ext/struts/taglib/logic/ExNotPresentTag.java
ExPresentTag/home/expresso/expresso/expresso-web/WEB-INF/classes/com/jcorporate/expresso/ext/struts/taglib/logic/ExPresentTag.java
ExIterateTag

/home/expresso/expresso/expresso-web/WEB-INF/classes/com/jcorporate/expresso/ext/struts/taglib/logic/ExIterateTag.java

For example, the following page will display every Output in the current ControllerResponse, one per line: <%@ page language="java" %> <%@ taglib uri="/WEB-INF/expresso-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/expresso-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/expresso-logic.tld" prefix="logic" %>

How to Use Struts Tags in Expresso

The "extended" Struts tags implemented in the com.jcorporate.expresso.ext.struts.taglib.* packages all use a consistent meaning for the "name" and "property" attributes for the tags that are somewhat different than the normal Struts meanings.

  1. Name Attribute: The name attribute for the extended tags refers to a specific ControllerElement in the current session. Such an element can be defined by means of the tag or the tag. For the "input field" related tags (e.g. text, textarea, hidden, file, checkbox, password and select), the ControllerElement being referred to should be an "Input" object. For example: <logic:iterate id="oneInput" property="inputs"/> <html:text name="oneInput"/> </logic:iterate> Would iterate over each "input" element in the ControllerResponse and display this input as a text field. Note that the "text" tag does *not* require the "property" attribute, unlike the corresponding Struts tag that it inherits from.

  2. Property Attribute: The "property" attribute can take one of several "forms" for the extended tags, these being:

    • Directly Supported Property: Each type of ControllerElement supports a few "built-in" properties. When referring to a specific element (e.g. via the "name" parameter, or via the "Reference to Element" method described below) this property name can be used directly. For example: <bean:write name="oneInput" property="name"> Would write the element name of the input element on the JSP page.

    • "Special" Name: Several special names can be used to refer to entire groups of elements, for convenience:

      • inputs: All Input elements in the ControllerResponse

      • outputs: All Output elements in the ControllerResponse

      • blocks: All Block elements in the ControllerResponse

      • transitions All Transition elements in the ControllerResponse

    • Attribute: ControllerElements can have additional meta-data stored with them by the State that generates them: This might take the form of "formatting hints" (such as "table" to indicate that a block should be rendered as a table), or any other useful information specific to the Controller. These attributes can be referenced by prefixing their name with the "@" symbol, so, for example: <bean:write name="oneOutput" property="@specialAttribute"/> Would print the value of the attribute "specialAttribute" of the specified Output element. This attribute would have been set via the setAttribute(String, String) method by the Controller or State generating the output.

  3. Reference to Element: Use of the property attribute in a tag *without* the name attribute refers to an element directly - for example: <html:text property="customerName"/>

    Creates an input field of type "text" from the element called "customerName" (customerName must be of type "Input"). In this case, customerName is not nested within any other input. If it were nested, for example, in a block stored as a session bean called "bigBlock" (say by an iterate or bean:define tag), then the following syntax would refer to it:

    <html:text name="bigBlock" property="customerName"/>

  4. Nested Reference to Element: A nested reference to an element provides the means to refer to elements nested with other elements by name. For example, if an output "customer" has a nested output called "address", you can refer to this element with a property value of "customer/address". Nested references can be combined with property or attribute references, so for example:

    • a/b.label Refers to the "label" property of the element called "b" nested within the element called "a".

    • a/b@something Refers to the *attribute* of the element b, found nested within the element "a"

Expresso Tag Library (WEB-INF/tld/expresso.tld)

The Expresso Tag Library contains a number of JSP custom tags to help build JSP pages easily, and eliminate the Java usage in JSP pages. All tags are currently in the com.jcorporate.expresso.ext.taglib package. Many of these tag are being depreciated in favor of JSTL. They are included in this documentation for reference to help you transition to JSTL.

Example JSP code

The following JSP will try to illustrate the tags in the library:

1. <font color="red">
2.     <expresso:ErrorTag/>
3. </font>

4. <table class="jc-default" border="0" align="center">
5. <expresso:TableHead value="ID|Name|Start Date|End Date|Duration|Command"/>

6. <expresso:ElementCollection type="block">
7. <expresso:ElementIterator>
8.      <expresso:ElementCollection type="output">
9.      <expresso:ElementIterator>
10.         <expresso:OutputTag name="xxx"> 
11.           <tr>
12.             <td><expresso:AttributeTag name="CourseId"/> &nbsp; </td>
13.             <td><expresso:AttributeTag name="CourseName"/> &nbsp; </td>
14.             <td><expresso:AttributeTag name="CourseStartDate"/> &nbsp; </td>
15.             <td><expresso:AttributeTag name="CourseEndDate"/> &nbsp; </td>
16.             <td><expresso:AttributeTag name="CourseDuration"/> &nbsp; </td> 
17.         </expresso:OutputTag> 
18.     </expresso:ElementIterator>
19.     </expresso:ElementCollection>

20.     <expresso:ElementCollection type="transition">
21.     <expresso:ElementIterator>
22.         <html:form action="/training/TrainingController.do&state=promptUpdateCourse" method="POST">
23.             <td><expresso:TransitionTag name="promptUpdateCourse" /></td> 
24.         </html:form>
25.     </expresso:ElementIterator>
26.     </expresso:ElementCollection>

27.           </tr>
28. </expresso:ElementIterator>
29. </expresso:ElementCollection> 
30. </table>

This example will: Display the Expresso Error Collection if it exists (Lines 1-3) Construct and display a table header with header names ID, Name, Start Date, End Date, Duration, Command (Lines 4,5) Iterate through all Block objects found in the ControllerResponse (Lines 6,7) --->Iterate through all Output objects in the current Block (Lines 8,9) -------->Use an OutputTag to help OutputAttribute tags (Line 10) ------------>Display the various attributes of the current Output object (Lines 12-16) ---->Iterate through all Transition objects found in the ControllerResponse (Lines 20,21) -------->Display the current Transition as a submit box (Lines 22-24)

Expresso Tags Described

The following outlines the Expresso Tags. We'll be adding another column to describe how JSTL replaces some of these tags.

Table 17.4. Expresso Tags Described

Tag NameDescriptionIf Depreciated then by
ActionTagRenders an Expresso action, and associated hidden fields 
AttributeTagA tag to display an Attribute from an Expresso Input or Output tag. 
BackDisplays a "Back" button or image to go back to a page 
BlockA tag to act as a container for child InputTag, OutputTag, TransitionTag and Block tags. Directly related to the Expresso Block controller element. 
configDefines a scripting variable out of the ConfigManager object 
ContentTagA tag to display an Expresso Output Element's Contents Field. 
ContextA tag to insert the web-app context, optionally including the expresso-dir and the path to an application's files 
DBDescriptionA tag to display the description text for the current DB context 
DBMaintA tag to include a row with calls to DBMaint for a dbobject 
ElementCollectionA tag that retrieves a collection of a controller elements that can later be iterated through using the ElementIterator tag 
ElementIteratorA tag to iterate through each controller element inside a parent ControllerCollection tag 
ErrorMessagesA tag to display error messages based on their key's in the MessageBundle.properties 
ErrorTagA tag to display an Expresso Error Collection as a Unordered List (UL) 
IfElementExistsA tag to check if a particular controller element exists as part of the parent: controller-response, block or element-iterator tags. 
IfErrorExistsA tag to check if the controller generated errors and stored it in the page context. 
IfLoggedInA tag to check if a session is established and a valid user is logged in. 
IfMemberOfGroupThis tag checks the currently logged in user for membership into a specified security group. 
InputTagA tag to display an Expresso Input Object 
LabelTagA tag to print the label of a controller element 
LoginTries to make the user log in 
outputDefines a scripting variable out of an Output object 
OutputTagA tag to display an Expresso Output Element. 
RestrictAccessA tag to allow quick and dirty restriction of access to jsp pages. 
sessionDefines a scripting variable out of the current session. 
setupDefines a scripting variable out of the Setup object 
TransitionTagA tag to display an Expresso Transition Button 
TransitionParamsTagA tag to display the parameters with an Expresso Transition 
TableHeadA tag to display a pipe-delimited string as a table header 
UserNameA tag to display the logged in user-name 

Expresso Library Tag Details

Below describes each tag and how it is used.

ActionTag - Renders an Expresso action, and associated hidden fields

<expresso:ActionTag name="refreshCompany" /> - renders the expresso action button with that name. This tag also takes care of the hidden form field that action tags rely on to pass parameters. This action tag allows seamless changes between GET and POST form actions. All three tags have no body (no closing tag). These simplest examples will work for most all cases, but there are many options you can set to override the default behaviors. Sufficient code and info has been included here to cover three out of four common expresso cases (Output is missing...this is easy in its simple case, but the nested cases may be a little tricky to create as tags).

AttributeTag - Displays an attribute from an Input or Output object

The AttributeTag can be used to display attributes from Input or Output objects. These attributes are the ones that you put in Input or Output objects by out1.setAttribute(String attrName, String value) in your States. The AttributeTag can either be used stand-alone, in which case all the arguments are required, or nested within an OutputTag or InputTag, in which case only the attribute name must be specified. If no valid Input or Output objects can be found, a JspTagException will be thrown, saying "A controllerElement was not specified for this attribute tag, or a parent tag did not supply a controllerElement." Examples:

  1. <expresso:AttributeTag controllerElement="product" name="product_desc" type="OUTPUT" /> Will display the value of the "product_desc" attribute, contained in the "product" Output object.

  2. <expresso:OutputTag name="product"> <expresso:AttributeTag name="product_desc"/> </expresso:OutputTag> This one does the same thing as the 1st example but this time the OutputTag must be enclosed in a Block or ElementIterator tag

Table 17.5. Attribute Tag

Attribute NameDescription
nameSpecifies the name of the attribute whose value will be displayed (If the attribute is not found, "ATTRIBUTE NOT FOUND" is displayed.. [Required] [RT Expr]
controllerElementIf supplied, specifies the name of the ControllerElement object holding the attribute. If not supplied, the tag will try to use the enclosing InputTag or OutputTag, if there is any. [RT Expr]
typeIf supplied, specifies the type of the ControllerElement (Must be "INPUT or "OUTPUT"). If not supplied, the tag will put the correct value according to the enclosing InputTag or OutputTag, if there is any. [RT Expr]

Back - Displays a "Back" button or image to go back to a page

Constructs an anchor to go to a specified URL, to go to the previous page, or to refresh the current page.

Table 17.6. Back Attributes

Attribute NameDescription
pageSpecifies the page to go to. If null, a hyperlink to go back to the previous page is constructed. If "current", a hyperlink to refresh the current page is constructed, if something else, a hyperlink to go to the desired URL is constructed. [RT Expr]
imageDefaults to expresso-images-dir/FingerLeft.gif [RT Expr]
keyTitle will be read from the locale file if supplied. [RT Expr]
titleTitle to be displayed. [RT Expr]

Block - Acts as a container for child InputTag, OutputTag,TransitionTag and Block tags

The Block tag is used to provide a container tag for other tags. Just like a Block object being a container for ControllerElement objects. If there is a container for a Block tag, it must either be an ElementIterator tag, or another Block tag. Examples: <expresso:Block name="courseDataInput"> <tr> <td> <expresso:InputTag name="CourseName" /> </tr> <td><expresso:InputTag name="CourseDuration" /></td> </tr> </expresso:Block> The Block tag helps the InputTag tags to retrieve the Block object and then execute Block.getInput()

Table 17.7. Block Attributes

Attribute NameDescription
nameThe name of the block that we want to act as a container for child tags. [Required] [RT Expr]

config - Defines a scripting variable based on the specified values

This tag puts the specified value to the desired scope. If "value" is not supplied, gets the value as ConfigManager.getProperty(). If "value" is supplied, this is used to be placed in the desired scope.

Table 17.8. config Attributes

Attribute NameDescription
idSpecifies the name of the scripting variable that will be made available. [Required] [RT Expr]
propertySpecifies which property to get from ConfigManager. [Required][RT Expr]
dbIf supplied, specifies the database definition to get configuration parameter from. [RT Expr]
toScopeOne of "page" (default if not supplied), "request", "session", "application". [RT Expr]
type? [RT Expr]
valueIf supplied, this will be placed in the desired scope. [RT Expr]

ContentTag - Displays an Expresso Output element's Contents field.

ContentTag must be nested within an OutputTag tag. The ContentTag has no body, and simply displays the content from the parent OutputTag (Output.getContent()). Examples: <expresso:OutputTag name="product"> <expresso:ContentTag /></br> </expresso:OutputTag> Gets the Output object from the OutputTag tag, and then displays Output.getContent(). No tag attributes are needed.

Context - Inserts the web-app context

Writes the context path and/or the "expresso" directory. Optionally figures out context paths for specific schema's as well. Examples: <expresso:Context> Writes: /expresso/expresso/components/training for example

Table 17.9. Context Attributes

Attribute NameDescription
schemaThe specific schema whose context path we want to get. [RT Expr]

DBDescription - Displays the description text for the current DB context

Retrieves the CurrentLogin object(if any) from the pageContext object, and displays ConfigManager.getContext(currentLogin.getDBName()).getDescription(). If there is no CurrentLogin, "default" is used for the dbName. Examples: <expresso:DBDescription> Displays "Oracle Database", for example. No tag attribute is needed.

DBMaint - Includes a row with calls to DBMaint for a dbobject

Provides a row for a table that contains links to the DBMaint controller providing add/update/delete functionality for a specific DB object.

Table 17.10. DBMaint Attributes

Attribute NameDescription
dbobjThe DBObject class. [Required] [RT Expr]
labelLabel to be displayed. [RT Expr]
helpThe URL for a help file about this DBObject. [RT Expr]

ElementCollection - Retrieves a collection of a controller elements that can later be iterated through using the ElementIterator tag

This tag provides an Enumeration object to an ElementIterator tag, providing access to the desired ControllerElements. The ElementIterator may iterate through all the elements found in the ElementCollection.

Table 17.11. ElementCollection Attributes

Attribute NameDescription
typeWhat type of objects do we want to get? Type should be one of "block", "input", "output", "transition" or "nested". If something else is supplied, the tag will do nothing. [Required] [RT Expr]

ElementIterator - iterates through each controller element inside a parent ElementCollection tag

This tag can only be used nested in an ElementCollection tag. It will iterate through all the elements found in the ElementCollection, and provide each element to the nested tags. No tag attributes are needed.

ErrorMessages - Displays an Expresso Error Collection from the Message Bundle

This tag is a lot like the ErrorTag in that it looks for an Expresso ErrorCollection in the page request. If an errorCollection is found, the tag iterates through the errors and displays them as an unordered (bulleted) list, however this tag goes one step further, it will display the text from the Message Bundle This is done by adding the Message Bundle key for the string that is associated with that error. Examples: In your JSP <expresso:ErrorMessages /> Now in the java code you simple put ErrorCollection errors = new ErrorCollection(); errors.addError( "error.username.required" ); Then make sure that this maps to the MessageBundle associated with controller (done in the Schema class) error.username.required=<li>Username is required

Table 17.12. ErrorMessages Attributes

Attribute NameDescription
nameName of the ErrorCollection object. If not supplied, defaults to ErrorCollection.ERRORCOLLECTIONKEY [RT Expr]
propertyIf supplied, the tag will display the set of error messages related to a specific property, if not supplied, the tag will display all error messages. [RT Expr]

ErrorTag - Displays an Expresso Error Collection

This tag looks for an Expresso ErrorCollection in the page request. If an errorCollection is found, the tag iterates through the errors and displays them as an unordered (bulleted) list. An errorCollection object is generally inserted into the page request by calling controller.saveErrors(errorCollection), which saves the errorCollection under the proper parameter name. If no errorCollection is found in the page request, this tag does nothing, so it is safe to include this on all of your jsp pages if desired. The ErrorTag renders an Expresso ErrorCollection on a page. The error list is rendered as an html unordered (bulleted) list. The errors are displayed in the order they where saved to the ErrorCollection. Examples: <expresso:ErrorTag /> <expresso:ErrorTag name="myErrors" property="validationErrors" />

Table 17.13. ErrorTag Attributes

Attribute NameDescription
nameName of the ErrorCollection object. If not supplied, defaults to ErrorCollection.ERRORCOLLECTIONKEY [RT Expr]
propertyIf supplied, the tag will display the set of error messages related to a specific property, if not supplied, the tag will display all error messages. [RT Expr]

IfElementExists - Checks if a particular controller element exists.

Tries to find the named element in the current ControllerResponse, ElementIterator or Block, whichever is appropriate. If finds, the body of the tag will be processed. "inverse" attribute can be used to mean "If Element Does Not Exist"

Table 17.14. IfElementExists Attributes

Attribute NameDescription
nameName of the element to be checked. [Required] [RT Expr]
typeLThe type of the element to be checked (Must be "block", "input", "output", or "transition") [Required] [RT Expr]
inverseIf "true", the tag will mean "IfElementDoesNotExist" [RT Expr]

IfErrorExists - Checks if the controller generated errors and stored it in the page context.

If finds the Expresso ErrorCollection in the page context, then the body of the tag will be processed. No tag attributes are needed.

IfLoggedIn - Checks if a session is established and a valid user is logged in.

If there is a valid user logged in, the body of the tag will be processed. "inverse" attribute can be used to to something if there is no valid login.

Table 17.15. IfLoggedIn Attributes

Attribute NameDescription
inverseIf this attribute is set to true, the tag will mean "IfNotLoggedIn". [RT Expr]

IfMemberOfGroup - Checks if the user logged in has access to the specified group

Tag checks to see if the user in the specified groupname is apart of that security group.

Table 17.16. IfMemberOfGroup Attributes

Attribute NameDescription
GroupnameThis is the groupname which you are checking to see logged in user is apart of. [RT Expr]
inverseIf this attribute is set to true, the tag will mean if the user is in the specified group return true. [RT Expr]
delimiterIf this attribute is set, it will be used as the delimiter to seperate the groupname in multiple entries. The results will be logical OR'd together.

InputTag - Displays an Expresso Input Object

<expresso:InputTag name="expresso.input.first_name" /> - renders the expresso input with that name. This tag can currently render the simplest html input box, along with all of the associated directives such as displayLength, type, etc. The tag will also render pulldown-style select boxes, and will ensure that the default value will be selected when the select box is rendered. Currently, the Expresso input must be defined as type = "LISTBOX" to be rendered as a select box. Produces html code for a <html input>. The type will tell the tag what html input to produce(listbox, radio boxes, input box, check boxes, hidden). This tag must be contained in one of: ControllerResponse (top level), Block tag, or ElementIterator tag.

Table 17.17. InputTag Attributes

Attribute NameDescription
nameName of the Input object. [Required] [RT Expr]
typeMust be one of: listbox, checkbox, checkbox-vertical, radio, radio-vertical, text, textarea, hidden, readonly. The tag will produce the correct type of html input. If no type is supplied, a normal input box is produced. [RT Expr]
sizeSize of the input to be produced. [RT Expr]
maxlengthThe maximum length for input boxes. [RT Expr]
showlabelIf "true", the label of the Input object will be displayed. [RT Expr]

LabelTag - Prints the label of a controller element

Displays the specified element's label (with element.getLabel()).

Table 17.18. LabelTag Attributes

Attribute NameDescription
nameName of the element whose label will be displayed. [Required] [RT Expr]
typeType of the element ("input", "output", "transition" or "block"). [RT Expr]

Login - Tries to make the user log in

Tag to transition between database contexts, either logging the user into a new context (if possible with cookies, etc), or taking them to the login screen if it is not possible.

Table 17.19. Login Attributes

Attribute NameDescription
dbIf supplied, tries to log in to this database context. [RT Expr]
forwardIf "false", tries to to logInAsNone(request,db) [RT Expr]

output - Defines a scripting variable based on the specified values

This tag puts the specified value to the desired scope. Must be nested within an OutputTag tag. If "value" is not supplied, gets the value as getContent() from the enclosing OutputTag. If "value" is supplied, this is used to be placed in the desired scope.

Table 17.20. output Attributes

Attribute NameDescription
idSpecifies the name of the scripting variable that will be made available. [Required] [RT Expr]
toScopeOne of "page" (default if not supplied), "request", "session", "application". [RT Expr]
type? [RT Expr]
valueIf supplied, this will be placed in the desired scope. [RT Expr]

OutputTag - Displays an Expresso Output Element

OutputTag is a tag that by itself does not display anything. The OutputTag must have a start and end tag. Between these tags, the ContentTag can be used to place the content from the Output, and the AttributeTag can be used to place attributes of the Output. The OutputTag can also be used to fetch out nested outputs, if one OutputTag is nested within another one.

Table 17.21. OutputTag Attributes

Attribute NameDescription
nameName of the element to be used in the nested ContentTag and AttributeTag tags. Will be automatically set if nested in an ElementIterator tag. [Required] [RT Expr]

RestrictAccess - Allows quick and dirty restriction of access to jsp pages

Provides an easy way to restrict access to particular pages. If the user is not found to be allowed to access this page, s/he will be forwarded to a specified page, or a JspTagException saying "Access to this page is denied". This tag allows quick access restriction to a jsp page. Example Usage: <expresso:RestrictAccess allowedUsers='Admin,scann' allowedGroups='Admin,Everyone /> or <expresso:RestrictAccess denyURL='join.jsp'/> or <expresso:RestrictAccess/>

Table 17.22. RestrictAccess Attributes

Attribute NameDescription
allowedUsersA comma delimited list of user names that are allowed to access this page (Case Sensitive). [RT Expr]
allowedGroupsA comma delimited list of groups that are allowed to access to this page, also case sensitive. [Note that you can have BOTH allowedUsers and allowedGroups]. [RT Expr]
denyURLURL to forward to, if the user is not allowed to access this page. The URL to forward to if access is denied If this attribute is not supplied, then a JspTagException is thrown with the message 'Access to this page is denied'. If no allowedUsers or allowedGroups are given, then as long as the person is logged in as ANYTHING other than NONE, they'll be given access to the page. [RT Expr]

session - Defines a scripting variable based on the specified values

This tag puts the specified value to the desired scope. If "value" is not supplied, gets the value as pageContext.getRequest().getAttribute(property). If "value" is supplied, this is used to be placed in the desired scope. (TODO: should be getSession??)

Table 17.23. session Attributes

Attribute NameDescription
idSpecifies the name of the scripting variable that will be made available. [Required] [RT Expr]
propertySpecifies which property to get from session scope. [Required][RT Expr]
toScopeOne of "page" (default if not supplied), "request", "session", "application". [RT Expr]
type? [RT Expr]
valueIf supplied, this will be placed in the desired scope. [RT Expr]

setup - Defines a scripting variable based on the specified values

This tag puts the specified value to the desired scope. If "value" is not supplied, gets the value as Setup.getValueRequired(). If "value" is supplied, this is used to be placed in the desired scope.

Table 17.24. setup Attributes

Attribute NameDescription
idSpecifies the name of the scripting variable that will be made available. [Required] [RT Expr]
propertySpecifies which property to get from Setup. [Required][RT Expr]
dbIf supplied, specifies the database definition to get setup parameter from. [RT Expr]
toScopeOne of "page" (default if not supplied), "request", "session", "application". [RT Expr]
type? [RT Expr]
valueIf supplied, this will be placed in the desired scope. [RT Expr]

TableHead - Displays a pipe-delimited string as a table header

Parses apart a pipe-delimited string into a table heading row. The pipe-delimited string is a convenience used by a number of Expresso controllers to pass the table headings required for various tables to the view. If the keys attribute is used instead of "value", the headers will be read from the appropriate MessagesBundle.properties file.

Table 17.25. TableHead Attributes

Attribute NameDescription
valueValues separated by a pipe - these don't get "translated. [Required] [RT Expr]
keysKeys into the language file - these are translated for display. [RT Expr]

TransitionTag - Displays an Expresso Transition Button

Displays a submit button with the information contained in the current Transition element. If "value" is not supplied, the label of the button will come from element.getLabel().

Table 17.26. TransitionTag Attributes

Attribute NameDescription
nameName of the Transition element to be displayed. [Required] [RT Expr]
ClassValueIf supplied, will be used to render the class value for the button if you use Cascading Style Sheets. [RT Expr]
OnClickIf supplied, will be used to render the onclick parameter for javascript submit box. [RT Expr]

TransitionParamsTag - Displays the parameters with an Expresso Transition

Writes: element.getParamString(). This tag does not construct the submit button therefore makes for a great tag for creating hrefs. <a href="/Login.do?<expresso:TransitionParamsTag name="promptFirstTime" />">I don't have a Username</a>

Table 17.27. TransitionParamsTag Attributes

Attribute NameDescription
nameName of the Transition element whose parameters are to be displayed. [Required] [RT Expr]
value? [RT Expr]

UserName - Displays the logged in user-name

If there is a valid login, displays the username. If not, displays "Not Logged In". No attribute required.

nbb,m ,

Conclusion

For additional technical information about how to use taglibs, please refer to any of the below resources:

Contributors

The following persns have contributed their time to this chapter:

  • Sandra Cann

  • Turgay Zengin

  • Peter Pilgrim

  • Michael Rimov

Note

Was this EDG documentation helpful? Do you wish to express your appreciation for the time expended over years developing the EDG doc? We now accept and appreciate monetary donations. Your support will keep the EDG doc alive and current. Please click the Donate button and enter ANY amount you think the EDG doc is worth. In appreciation of a $35+ donation, we'll give you a subscription service by emailing you notifications of doc updates; and donations $75+ will also receive an Expresso T-shirt. All online donation forms are SSL secured and payment can be made via Credit Card or your Paypal account. Thank you in advance.

Copyright © 2001-2004 Jcorporate Ltd. All rights reserved.