| bea.com | products | dev2dev | support | askBEA |
![]() |
![]() |
|
|||||||
| e-docs > WebLogic Platform > WebLogic Portal > JavaServer Page Guide > Navigation (Webflow) JSP Tags |
|
JavaServer Page Guide
|
Navigation (Webflow) JSP Tags
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:
URL Creation Tags
The Webflow 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 4-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.
|
Tag Library |
webflow.tld |
|
Import Statement |
<%@ taglib uri="webflow.tld" |
|
Class Implemented |
CreateWebflowURLTag |
Table 4-1 describes the <webflow:createWebflowURL> tag attributes.
Example Listing 4-1 illustrates how to use the <webflow:createWebflowURL> JSP tag and its many attributes: Note: It is recommended that you not hardcode values on a Web page. Listing 4-1 Using <webflow:createWebflowURL> Tag and Attributes <webflow:createResourceURL> The <webflow:createResourceURL> tag (Table 4-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.
<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>
Example
Listing 4-2 illustrates how you can use the <webflow:createResourceURL> JSP tag to point to a specific resource, in this case, a .gif file.
Listing 4-2 Using <webflow:createResourceURL>
<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 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.
Note: This tag does not support the embedded Webflow form tags like the <webflow:validatedForm> does. Table 4-3 lists the <webflow:form> tag attributes.
Example Listing 4-3 illustrates how to use the <webflow:form> JSP tag: Listing 4-3 Using <form>
<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 the Javadoc
. When a Web site visitor enters invalid information, the visitor's input is preserved and redisplayed with an appropriate error message.<webflow:validatedForm>
The <webflow:validatedForm> tag 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).
Table 4-4 describes the <webflow:validatedForm> tag attributes.
Example Listing 4-4 illustrates how to use the <webflow:validatedForm> JSP tag to dynamically create the URL that defines the action in an HTML form.. Listing 4-4 Using <webflow:validatedForm> <webflow:text> The <webflow:text> tag is used in a JSP to validate an HTML text field. This tag must be nested in the <webflow:validatedForm> tag.
<%
moreAttributes = "ENCTYPE=\"multipart/form-data\"";
%>
<p> use enctype="multipart/form-data" and hide="false"...
<br>
<webflow:validatedForm name="uploadFeedback"
htmlAttributes='<%= moreAttributes %>'
hide="false"
event="uploadFeedback.submit"
namespace="test_forms" >
<webflow:text size="50" name="testText"value="startingDefaultValue" />
<input type="submit" name="SubmitButton" value="SubmitButtonLabel" /></webflow:validatedForm>
Table 4-5 describes the <webflow:text> tag attributes.
<webflow:password> The <webflow:password> tag 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 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.
Table 4-7 describes the <webflow:radio> tag attributes.
<webflow:checkbox> The <webflow:checkbox> tag 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.
Table 4-8 describes the <webflow:checkbox> tag attributes.
<webflow:textarea> The <webflow:textarea> tag 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 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 4-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.
Table 4-11 describes the
Example
Listing 4-5 uses each of the validated form tags in an HTML form page that gathers some information about a Web site's visitors.
Listing 4-5 Using webflow.tld Form Tags
<%@ 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.
<webflow:setProperty>
The <webflow:setProperty> tag sets a property in the Pipeline Session.
Table 4-12 describes the <webflow:setProperty> tag attributes.
Example
Listing 4-6 illustrates how to use the <webflow:setProperty> JSP tag to set some arbitrary object in the Pipeline Session (Request-scoped):
Listing 4-6 Using <webflow:setProperty>
<% SomeObject so = new SomeObject("TWO"); %>
<webflow:setProperty property="myobject" value="<%= so %>" scope="request" />
<webflow:getProperty>
The <webflow:getProperty> tag (Table 4-13) retrieves a named property from the Pipeline Session. This tag can be inlined or return a scripting variable.
|
Tag Library |
webflow.tld |
|
Import Statement |
<%@ taglib uri="webflow.tld" |
|
Classes Implemented |
GetPropertyTag |
Table 4-13 describes the