![]() |
![]() |
|
|
Webflow JSP Tag Library Reference
The WebLogic Portal product suite includes a set of JSP tags designed to facilitate the development of JSPs using Webflow. Use of these predefined tags will eliminate the need for your JSPs to contain any Java code related to Webflow. This topic explains how to import this set of tags into your Web pages, and describes the purpose of each tag.
This topic includes the following sections:
Note: If you are using Webflow in a portal application, you will need to use specialized versions of the Webflow JSP tags. For more information, see Portal Management JSP Tag Library Reference in the Getting Started with Portals and Portlets documentation.
Importing the Webflow Tag Library
The Webflow JSP tags are utility tags used to simplify the implementation of JSPs that utilize the Webflow mechanism. To import all of Webflow JSP tags described in this topic, use the following code:
<%@ taglib uri="webflow.tld" prefix="webflow" %>
URL Creation Tags
The Webflow's URL tags described in this section are used to create dynamic or static URLs for links and other resources within a JSP.
Note: In the following tables, the Required column specifies if the attribute is required (yes) or optional (no). In the R/C column, C means that the attribute is a Compile time expression, and R means that the attribute can be either a Request time expression or a Compile time expression.
<webflow:createWebflowURL>
The <webflow:createWebflowURL> tag (Table 5-1) is used in a JSP to dynamically create a Webflow URL in a JSP. The Webflow URL may include the protocol, domain name, port, Web application URI, WebflowServlet URI, and query string.
Example
The following code fragments illustrate how to use the <webflow:createWebflowURL> JSP tag and its many attributes:
<a href="<webflow:createWebflowURL event="link.yo" pathSuffix="/morepath"
/>">A Path Suffix</a>
<br>
<a href="<webflow:createWebflowURL event="link.yo" pathPrefix="/pathprefix" />">A Path Prefix</a>
<br>
<a href="<webflow:createWebflowURL event="link.yo" pathPrefix="/pathprefix" pathSuffix="/suffix" />">A Path Prefix and Path Suffix</a>
<br>
<a href="<webflow:createWebflowURL event="link.yo" domainName="123.123.123.123" />">A Domain Name</a>
<br>
<a href="<webflow:createWebflowURL event="link.yo" pathSuffix="/morepath" extraParams="sex=male" />">A Path Suffix and One Extra Parameter</a>
<br>
<a href="<webflow:createWebflowURL event="link.yo" pathSuffix="/morepath" extraParams="sex=male&animal=dog" />">A Path Suffix and Two Extra Parameters</a>
<br>
<a href="<webflow:createWebflowURL event="link.yo" httpsInd="https" />">Always Use HTTPS</a>
<br>
<a href="<webflow:createWebflowURL event="link.yo" httpsInd="http" />">Always Use HTTP</a>
<br>
<a href="<webflow:createWebflowURL event="link.yo" httpsInd="calculate" />">Calculate HTTPS</a>
<br>
<a href="<webflow:createWebflowURL event="link.yo" encode="false" />">Do Not Encode the URL</a>
<br>
<a href="<webflow:createWebflowURL event="link.yo" doRedirect="true" />">Redirect, Instead of Forward</a>
<br>
<webflow:createResourceURL>
The <webflow:createResourceURL> tag (Table 5-2) is used in a JSP to create a static URL for a resource, using the value of the P13N_STATIC_ROOT context parameter in the application's WEB-INF/web.xml file. This tag may be used to load GIF images from a separate server.
Example
The following code fragment illustrates how you might use the <webflow:createResourceURL> JSP tag:
<img src="<webflow:createResourceURL
resource="/images/button_checkout.gif"/>" border="0" alt="Proceed
To Checkout" border="0"></a>
Form Tags
The Webflow JSP form tags described in this section are used to create simple dynamic links for form actions.
Note: In the following tables, the Required column specifies if the attribute is required (yes) or optional (no). In the R/C column, C means that the attribute is a Compile time expression, and R means that the attribute can be either a Request time expression or a Compile time expression.
<webflow:form>
The <webflow:form> tag (Table 5-3) is used in a JSP to dynamically generate an HTML form tag. This tag is not as sophisticated as the <webflow:validatedForm> tag, but is simpler. For more information about the <webflow:validatedForm> tag, refer to the next section.
Note: This tag does not support the embedded Webflow form tags like the <webflow:validatedForm> does.
Example
The following code fragment illustrates how you might use the <webflow:form> JSP tag:
<webflow:form event="button.go" >
<input type="text" name="username" >
</webflow:form>
Validated Form Tags
The Webflow's validated form JSP tags are used to dynamically generate HTML forms that can be validated. These tags work in conjunction with an Input Processor and the ValidatedValues class, described in Webflow Validators and Input Processors. When a Web site visitor enters invalid information, the the visitor's input is preserved and redisplayed with an appropriate error message.
<webflow:validatedForm>
The <webflow:validatedForm> tag (Table 5-4) is used in a JSP to dynamically create the URL that defines the action in an HTML form. This tag should be used in conjunction with the com.bea.p13n.appflow.webflow.forms.* package and the other nested form tags defined in the webflow.tld file (which are described later in this section).
<webflow:text>
The <webflow:text> tag (Table 5-5) is used in a JSP to validate an HTML text field. This tag must be nested in the <webflow:validatedForm> tag.
<webflow:password>
The <webflow:password> tag (Table 5-6) is similar to the <webflow:text> tag except that field input is masked with asterisks (****). This tag must be nested in the <webflow:validatedForm> tag.
<webflow:radio>
The <webflow:radio> tag (Table 5-7) is used in a JSP to represent an HTML radio button, but preserves the input. This tag must be nested in the <webflow:validatedForm> tag.
<webflow:checkbox>
The <webflow:checkbox> tag (Table 5-8) is used in a JSP to generate the required HTML for a check box. This tag will preserve input upon the InputProcessor throwing an InvalidFormFieldException. This tag must be nested in the <webflow:validatedForm> tag.
<webflow:textarea>
The <webflow:textarea> tag (Table 5-9) is used in a JSP to represent an HTML text area, but preserves the input. This tag must be nested in the <webflow:validatedForm> tag.
<webflow:select>
The <webflow:select> tag (Table 5-10) is used in a JSP to represent a list box, but preserves its input. This tag must be nested in the <webflow:validatedForm> tag
<webflow:option>
The <webflow:option> tag (Table 5-11) is used in a JSP to represent an HTML option, but preserves the input. An option is one value in a list box. This tag must be nested in the <webflow:select> tag
Example
The following code uses each of the validated form tags in an HTML form page that gathers some information about a Web site's visitors.
<%@ taglib uri="webflow.tld" prefix="webflow" %>
<% String validStyle="background: white; color: black; font-family: Arial"; %>
<% String invalidStyle="background: white; color: red; font-style: italic"; %>
<%-- If there was an InvalidFormDataException thrown, display the message --%>
<font size="5" color="green"><webflow:getException/></font>
<br>
<webflow:validatedForm event="button.go" applyStyle="message"
messageAlign="right" validStyle="<%=validStyle%>"
invalidStyle="<%=invalidStyle%>" unspecifiedStyle="<%=validStyle%>" >
<p>
Username:
<webflow:text name="username" value="start" size="15" maxlength="30"
htmlAttributes="onMouseOver=\\"self.status='User ID';return true\\"" />
<br>
Password:
<webflow:password name="password" size="15" retainValue="true" maxlength="30"
htmlAttributes="onMouseOver=\\"self.status='Secret Password';return true\\"" />
<br>
Sex:
<webflow:radio name="sex" checked="true" value="M"/>Male
<webflow:radio name="sex" value="F" />Female
<br>
Favorite Pet(s):
<webflow:checkbox name="cat" value="cat" />Cat <br>
<webflow:checkbox name="dog" checked="true" value="dog" />Dog <br>
<webflow:checkbox name="bird" value="bird" />Bird
<p>
Comment:
<webflow:textarea name="comment" cols="20" rows="3" value="hello" />
<br>
Hobbies:
<webflow:select name="hobbies" size="3" multiple="true">
<webflow:option value="Running"/>Running
<webflow:option value="Skiing"/>Skiing
<webflow:option value="Motocross"/>MotoX
<webflow:option value="Rugby"/>Rugby
</webflow:select>
<br>
<input type="submit" name="Submit"/>
</webflow:validatedForm>
Pipeline Session Tags
A Pipeline Session is used to share information between Input Processors, Pipeline Components, and presentation nodes. The Pipeline Session JSP tags are used to retrieve and set properties in the Pipeline Session. Presentation nodes (such as JSPs) are typically used to retrieve information from the Pipeline Session, while Input Processors and Pipeline Components place properties into the Pipeline Session. There are, however, JSP tags for setting properties in the Pipeline Session.
Note: For more information about the Pipeline Session, see The Pipeline Session and Pipeline Session Internals.
<webflow:setProperty>
The <webflow:setProperty> tag (Table 5-12) sets a property in the Pipeline Session.
Example
The following code fragment illustrates how you might use the <webflow:setProperty> JSP tag to set some arbitrary object in the Pipeline Session (Request-scoped):
<% SomeObject so = new SomeObject("TWO"); %>
<webflow:setProperty property="myobject" value="<%= so %>" scope="request" />
<webflow:getProperty>
The <webflow:getProperty> tag (Table 5-13) retrieves a named property from the Pipeline Session. This tag can be inlined or return a scripting variable.
Example 1
The following code fragment is an example of how you might use the <webflow:getProperty> JSP tag inline. The toString() method is called on the instance of SomeObject:
result = <webflow:getProperty property="myobject" scope="request" />
Example 2
The following code fragment is an example of how you might use the <webflow:getProperty> JSP tag to return a scripting variable of type SomeObject:
<webflow:getProperty id="myObj" property="myobject" type="com.bea.test.SomeObject" scope="request" />
result = <%= myObj.getValue() %>
<webflow:setValidatedValue>
The <webflow:setValidatedValue> tag (Table 5-14) is used in a JSP to configure the display of fields in a form that a Web site visitor must correct. Usually this is done within an Input Processor, but it can also be done from a JSP by using this tag. The <webflow:setValidatedValue> tag is used in tandem with the <webflow:getValidatedValue> tag.
Note: You may want to consider using the <webflow:validatedForm> tags instead. This tag supports the validatedValues class from previous releases. However, if there is some low-level functionality that needs to be accessed, then these tags are still valid.
Example
When used in a JSP, this sample code will obtain the current value and processing status of the <field_name> form field.
<webflow:setValidatedValue fieldName="<field_name>" fieldValue="<field_value>" fieldStatus="status" />
<webflow:getValidatedValue>
The <webflow:getValidatedValue> tag (Table 5-15) is used in a JSP to display the fields in a form that a Web site visitor must correct. The <webflow:getValidatedValue> tag is used in tandem with the<webflow:setValidatedValue> tag.
Note: You may want to consider using the <webflow:validatedForm> tags instead. This tag supports the ValidatedValues class from previous releases. However, if there is some low-level functionality that needs to be accessed, then these tags are still valid.
These fields are determined and marked by an Input Processor after performing its validation activities. All InputProcessors use a ValidatedValues object to communicate which fields were successfully processed as well as those that were determined to be invalid. For more information, see Webflow Validators and Input Processors.
Example 1
When used in a JSP, this sample code will obtain the current value and processing status of the <field_name> form field.
<webflow:getValidatedValue fieldName="<field_name>" fieldValue="<field_value>" fieldStatus="status" />
Example 2
The <webflow:getValidatedValue> tag refers to the webflow.tld tag library to retrieve available elements/attributes. In this example, a request is being made to obtain the following values from the HTTP session:
fieldName
fieldValue
fieldStatus
validColor
invalidColor
unspecifiedColor
fieldColor
These attributes are used for display purposes. (In this case, indicate that this field is required and mark it in red.) The overall goal is to display values back to the Web site visitor, indicating which pieces are valid/invalid as returned from the Input Processor.
<webflow:getValidatedValue
fieldName="<%=HttpRequestConstants.CUSTOMER_FIRST_NAME%>"
fieldValue="customerFirstName" fieldStatus="status" validColor="black"
invalidColor="red" unspecifiedColor="black" fieldColor="fontColor"
/>
<webflow:getException>
The <webflow:getException> tag (Table 5-16) is used to retrieve the exception or message thrown by a Webflow processor. This can be the message associated with an InvalidFormFieldException exception or a ProcessingException exception. This tag can be inlined (in which it calls the getMessage() method on the exception) or return a scripting variable representing the exception.
Example
The following code fragment illustrates how you might use the <webflow:getException> JSP tag:
<%-- If there was an InvalidFormDataException thrown, display the message --%>
<font size="5" color="red"><webflow:getException/></font>
![]() |
![]() |
![]() |
|
Copyright © 2001 BEA Systems, Inc. All rights reserved.
|