FileDocCategorySizeDatePackage
WelcomeAction.javaAPI DocExample3003Thu Jul 08 09:27:10 BST 2004org.apache.struts.webapp.example

WelcomeAction

public final class WelcomeAction extends BaseAction

Confirm required resources are available. If a resource is missing, forward to "failure". Otherwise, forward to "success", where success is usually the "welcome" page.

Since "required resources" includes the application MessageResources the failure page must not use the standard error or message tags. Instead, it display the Strings stored in an ArrayList stored under the request attribute "ERROR".

version
$Revision: 1.1 $ $Date: 2004/03/09 04:36:49 $

Fields Summary
Constructors Summary
Methods Summary
public org.apache.struts.action.ActionForwardexecute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)


        // Setup message array in case there are errors
        ArrayList messages = new ArrayList();

        // Confirm message resources loaded
        MessageResources resources = getResources(request);
        if (resources==null) {
            messages.add(Constants.ERROR_MESSAGES_NOT_LOADED);
        }

        // Confirm database loaded
        UserDatabase userDatabase = getUserDatabase(request);
        if (userDatabase==null) {
            messages.add(Constants.ERROR_DATABASE_NOT_LOADED);
        }

        // If there were errors, forward to our failure page
        if (messages.size()>0) {
            request.setAttribute(Constants.ERROR_KEY,messages);
            return findFailure(mapping);
        }

        // Forward to our success page
        return findSuccess(mapping);