@jpf:forward Annotation

You can use the @jpf:forward annotation to describe the location the page flow runtime should go to next. The location may be a JSP, a page flow, a specific page flow action, or an external URL. This annotation may be used on action methods and the page flow class, and in the /WEB-INF/src/global/Global.app. Using the @jpf:forward at the class level results in a global forward that can be used by any action method in the page flow class.

The Remarks section includes a discussion about what happens if you use overloaded actions. Also, the Remarks section contains a description about the behavior seen when you forward directly from one action to another, and the effects of form scoping.

Syntax

@jpf:forward

name = "<forward name>"

{ path = "<path>"  |  return-action = "<action name>" |  return-to = {"currentPage" | "previousPage" | "previousAction"}  }

{ return-form = "<form name>" |  return-form-type = "<form type>"  }

[ redirect = { "true" | "false" } ]

Attributes

name

Required. Specifies the name of the forward, which causes the navigation to occur. Note that @jpf:forward names on exception-handlers can conflict with @jpf:forward names on actions and at the class level. The @jpf:forward names that you specify must be unique in the page flow.

You must specify only one of the following: the path, return-to, or the return-action attributes.

path

The path attribute is a string that maps to one of the following entities:

If the path begins with a protocol such as "http:" the page flow runtime will look outside of this web application for the resource, and it will automatically cause a redirect (rather than a server forward) to the resource. If the path begins with a forward slash, "/", the runtime will start at the web application's root directory to locate the resource. If the path omits the forward slash, "/", the reference is relative to the page flow's directory.

return-to

The return-to attribute always applies to the current page flow, whether it is a nested page flow or the main page flow. To return to an action in the “nesting” page flow use the return-action attribute.

The value for the return-to attribute must be a keyword, either "currentPage", or "previousPage", or "previousAction".

Note: To clarify the purpose of the return-to attribute, the keywords "page" and "action" were deprecated as of WebLogic Workshop 8.1 Service Pack 2. Instead of "page", the equivalent function is "previousPage". Instead of "action", the equivalent function is "previousAction".

If the value is "currentPage", the same JSP page is rendered again by the server, along with any updated data that occurred as a result of executing the annotated action method.

If the value is "previousPage", the page that was shown before the current page is rendered.

If the value is "previousAction", the previous action in the current page flow is run.

return-action

The return-action attribute, which is only valid in a nested page flow, causes control to return to the calling (or "nesting") page flow (leaving the current page flow), and then causes the specified action to be raised on the calling page flow.

return-form

Optional. The return-form attribute, which is only valid when used with the return-action attribute, causes the given page flow member variable to be attached to the returned Forward automatically.

return-form-type

Optional. The return-form-type attribute, which is only valid when used with the return-action attribute, is used in conjunction with the Forward that is returned. Forward takes the actual FormData instance as the second argument to its constructor. This attribute declares the type of the form bean that will be returned to the calling page flow.

Note: If multiple actions with the same name (such as "success") exist in the calling page flow, either the return-form-type value or the return-form member variable type will be used to determine the appropriate action.

redirect

Optional. A boolean, true or false. Default is false. When set to true, navigation causes a browser redirect to the specified destination. Redirecting is useful when you want to clear out any data that was attached to a request, or when it is important that the user's URL bar reflect the actual page that is displayed (instead of the action name). For details, see the Remarks section.

Action Method Signatures

An action method has several possible signatures. One signature takes no parameters. For example:

public Forward shopping()

The second type of signature uses a form. For example:

public Forward shopping(CheckoutForm form)

The form bean is a class that extends com.bea.wlw.netui.pageflow.FormData. You can define the form bean as an inner class within the page flow class, or separately in the web project.

If you are using the <netui-data:declarePageInput> tag in your JSP, you may use a third type of signature, where you return a new Forward that contains three parameters. For example:

 /**
  * @jpf:action
  * @jpf:forward name="success" path="next.jsp"
  */
  public Forward next()
      throws SQLException
  {
      Item[] items = itemsDB.getAllItems();
      return new Forward("success", "items", items);
  } 

In the new Forward, the parameters in new Forward("success", "items", items) for this example are as follows:

If you need to add more than one page input, you can first create the Forward object and then call its addPageInput method. For example:

 /**
  * @jpf:action
  * @jpf:forward name="success" path="next.jsp"
  */
  public Forward next()
      throws SQLException
  {
      Forward fwd = new Forward("success");
      fwd.addPageInput("products", productsDB.getAllProducts());
      fwd.addPageInput( "items", itemsDB.getAllItems());
      return fwd;
  }

Remarks

The following rules apply to this annotation's use:

 

Related Topics

@jpf:action Annotation

@jpf:catch Annotation

@jpf:controller Annotation

@jpf:exception-handler Annotation

@jpf:message-resources Annotation

@jpf:validation-error-forward Annotation

Form Bean Scopings

Data Flow Sample