Chapter 22. Command Chain FAQ

Q:. In which file is the command-chain configuration located?
Q:. What is the actions mapping used for?
Q:. Which commands can I use?
Q:. How do I add my own command?
Q:. How do I share objects between my commands?
Q:. How do I read field valus submitted in a multipart request?
Q:.

In which file is the command-chain configuration located?

A:.

The command-chain configration file, command-chain.xml, is located in /WEB-INF/resources in the web application file.

Q:.

What is the actions mapping used for?

A:.

This mapping decupples the development of JSP's from the configuration of command-chains. It allows GUI-developers to use an abstract name for a requested action, which the administrator/deployer mapp to a command-chain. Changing the execution of an action is as simple as definig a new command-chain and chainging the mapping.

Q:.

Which commands can I use?

A:.

SCAM has identified a set of frequently used commands. If not any of theese commands suit your needs, you are free to add your own commands.

Q:.

How do I add my own command?

A:.
  1. Create a class that implements the se.kmr.scam.client.http.Command interface.

  2. Add your command in the command-chain definition file

  3. Make your command available in the classpath.

See more in the section called “Implement the transitions”

Q:.

How do I share objects between my commands?

A:.

A simple method to share objects is through the se.kmr.scam.client.http.util.Context object.

Context provides access to request attributes in different scopes:

  1. request - available in current request

  2. session - available in current session

  3. application - object is shared by all sessions

Note

A name must be unique in the requested scope. An attribute is overwritten if it is already exists.

Tip

Objects shared as request attributes are also available in JSP's.
Q:.

How do I read field valus submitted in a multipart request?

A:.

In a multipart/form-data request is the request body streamed, which is not handled by the normal HTTP-request parser. Thus is field values not available as request parameters in a multipart request.

To transparently provide field values to the middleware are theese values instead made available as request attributes.

For multipart requests is se.kmr.scam.scam.http.filter.MultipartEncodeFilter responsible for making field values available as attributes. Make sure this filter is included in web.xml.

Tip

se.kmr.scam.client.http.util.Context.getAttribute(String, HttpServletRequest) provides access to an object associated with the given name, no matter if it is defined as a request attributes or as a request parameters.