I think the only way you will solve this is by downloading the source and putting some logging statnements in there. It's easy enough to use the struts source by putting the org/apache/struts/action/RequestProcessor.java in your own source directory and recompiling and deploying. I don't think you need the whole lot.

Here's my base action class for what its worth
Adam

Sashi Ravipati wrote:
I check the first thing u asked and it is same i.e
org.apache.struts.taglib.html.Constants.CANCEL_PROPERTY ==
org.apache.struts.taglib.html.CANCEL


and regarding the processPopulate(), I am not sure how I can do this.

I just downloaded the Struts 1.1 final again and tested but the result
is the same.


Could u send me the Code u have in your action class. I will try to see
if I missed some thing.

Thanks



[EMAIL PROTECTED] 07/09/03 11:54AM >>>

Via logging is basically how I solved it - by figuring out where in struts I was going wrong.


What it means now is that RequestProcessor is not setting that attribute

- you don't need to set it by hand, struts should.

It's just one little if clause. According to your logging, request.getParameter("org.apache.struts.taglib.html.CANCEL") has a value, right? The parameter is not null?

If the parameter is not null but the attribute is null, that means that you have either not got the same struts code as me (1.1 final) or your RequestProcessor is not executing the processPopulate() method.

I would check 2 things:

that org.apache.struts.taglib.html.Constants.CANCEL_PROPERTY == "org.apache.struts.taglib.html.CANCEL" (i.e. that the parameter name / cancel button name in your HTML is correct)

and that RequestProcessor.processPopulate() is executing. This method also puts the data into the action form, so you could use that as a check unless you can grab the source code and put some logging in there.

As you can tell I'm intrigued.
Adam

Sashi Ravipati wrote:

request.getAttribute(Globals.CANCEL_KEY) is returning null, so can I

set


it to not null and where Should I do this..

Can u explain how u solved ur problem..

Thanks



[EMAIL PROTECTED] 07/09/03 11:22AM >>>

I've solved my problem. Now you've checked the parameter, check to see


if the request.attribute is set with
request.getAttribute(Globals.CANCEL_KEY);

For some reason in the RequestProcessor it sets this attribute to true


when the request.parameter is present. Check it out. This is the one that the Action.isCancelled() checks. It has to be not null.


Adam


Sashi Ravipati wrote:


it says - Cancel

I don't know what I am missing which is making this tag not work..

Thanks






[EMAIL PROTECTED] 07/09/03 09:50AM >>>

Try logging what is in this cancel parameter (org.apache.struts.taglib.html.CANCEL) in the same place where you are


calling isCancelled()

Actually I've just realised I'm suffering the same problem. I'll try

it



myself. Let me know what you find as well!

Adam

Sashi Ravipati wrote:



HTML is as shown below

<input type="submit" name="org.apache.struts.taglib.html.CANCEL"
value="Cancel" onclick="bCancel=true;">

[EMAIL PROTECTED] 07/09/03 09:21AM >>>

Sashi, what HTML does the tag produce?


Adam

Sashi Ravipati wrote:




I am trying this on Struts 1.1 final. Will this make any

difference..







[EMAIL PROTECTED] 07/08/03 05:11PM >>>

Odd, I can't reproduce that in 1.1-rc1. Unless you're extending something which might override the isCancelled(HttpServletRequest) method, or the html:cancel tag is not contained within an html:form tag, I can't think of anything else.

m

--- Sashi Ravipati <[EMAIL PROTECTED]> wrote:





This is how I have my cancel tag.

<html:cancel>
   <bean:message key="button.cancel"/>
</html:cancel>

[EMAIL PROTECTED] 07/08/03 02:27PM >>>

The complete content of your html:cancel tag is probably key to solving this problem.

m

--- Sashi Ravipati <[EMAIL PROTECTED]> wrote:





isCancelled(request) is always returning false
(Even when cancel button
is clicked)

Need some help...

Thanks







[EMAIL PROTECTED] 07/08/03 09:10AM >>>

I have a <html:cancel> in my jsp page. and in my action I have

if(isCancelled(request)){
return mapping.findForward("index"); }



But it is not working. What am I doing wrong here.

I






am using Struts 1.1
final

Thanks



__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com



---------------------------------------------------------------------






To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]




__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

package org.blacksail;

//BlackSail
import org.blacksail.realm.BlackSailUser;

//Java imports
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;
import javax.servlet.jsp.PageContext;
import java.util.Locale;
import java.util.ArrayList;
import java.util.HashMap;
import javax.sql.DataSource;
import java.sql.Connection;
import java.util.logging.Logger;

//Struts & Apache / Jakarta imports
import org.apache.struts.Globals;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;

/**
 * Base class for all Action classes. Takes care of the user
 * and the mapping for all Action subclasses, i.e. does all the stuff that
 * all the Actions must do execute() calls executeActual() which is
 * overridden by subclass.
 */
public class BaseAction extends Action
{
    /**
     * references the Logger instance
     */
    protected Logger logger;
    protected Logger logFlow;

    /**
     * Set up logger if not done by subclass
    **/
    public BaseAction()
    {
        logger = Logger.getLogger("org.blacksail.BaseAction");
        logFlow = Logger.getLogger("flow");
    }


    /**
     * Process the specified HTTP request, and create the corresponding HTTP
     * response (or forward to another web component that will create it).
     *
     * Return an <code>ActionForward</code> instance describing where and how
     * control should be forwarded, or <code>null</code> if the response has
     * already been completed.
     *
     * This has to exist since it is called by the Action servlet. It's the first
     * code executed in the processing of every struts action.
     *
     * It sorts out all the things that all actions need to take care of:
     * <ul>
     * <li>initial map name for ActionForward & getting it from mapping afterwards
     * <li>when cancel is pressed
     * <li>user object & if logged in
     * <li>locale
     * <li>message object
     * <li>errors object & saving it back to request afterwards
     * <li>page caching blocker
     * </ul>
     * and then calls the subclass method executeXXXX() if all goes well
     *
     * @param mapping   The object containing all the ActionForwards
     * @param form      The formbean where all the data for & from the HTML is
     * @param request   Somewhat important
     * @param response  For cookies I guess
     *
     * @return          The actionForward from getForwardObject() represented by 
mapName
     */
    public ActionForward execute(
        ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response)
    {
        String methodName = "execute()";
        HttpSession session = request.getSession();
        Locale locale = getLocale(request);
        MessageResources messages = getResources(request);
        
        //initialize the Errors collection
        ActionErrors errors = (ActionErrors) request.getAttribute(Globals.ERROR_KEY);
        if (errors == null)
            errors = new ActionErrors();

        BlackSailUser user = (BlackSailUser) 
session.getAttribute(BlackSailConstants.USER);
        ConnMan connMan = new ConnMan();
        Connection conn = null;

        String initialMapName = null;
        // Set finalMapName to ERROR so that any exceptions lead to the Error action 
forward
        String finalMapName = BlackSailConstants.ERROR;

        // Sort out the initialMapName in order of importance
        // Precedence 1: has another Action set it in request.Attributes?
        initialMapName = (String) request.getAttribute(BlackSailConstants.TOKEN);

        // Precedence 2: user clicked cancel && no other Action has dealt with it yet
        if (initialMapName == null && super.isCancelled(request))
        {
            logFlow.finer("action was cancelled....");
            initialMapName = BlackSailConstants.FINISHED;    //forward for this case
        }

        //Precedence 3: from struts-config.xml
        if (initialMapName == null)
        {
            initialMapName = mapping.getParameter();
        }

        // Precedence 4: HTTP request.parameters
        if (initialMapName == null)
        {
            initialMapName = request.getParameter(BlackSailConstants.TOKEN);
        }

        //This is taken care of by struts
        // make sure our page expires so that the Back-button on browser isn't used
        //response.setDateHeader("Expires", 0);
        //response.setHeader("Pragma", "no-cache");
        //response.setHeader("Cache-Control", "no-cache");

        logFlow.finer(" starting " + mapping.getPath() +
                    " with map: " + initialMapName);

        try
        {
            //get a connection for this Action
            conn = connMan.getConnection("java:comp/env/jdbc/LinkLibDB");
            logFlow.finest(mapping.getPath() + " got connection");
            
            //before executeXXXX(), get the relatedListss for the page
            this.executeRelatedLists(initialMapName, mapping, form,
                                 request, response, user, locale, messages, errors, 
conn);
            logFlow.finest(mapping.getPath() + " ... done executeRelatedLists()");
            
            //now do whatever processing is required
            if (BlackSailConstants.LIST.equals(initialMapName))
            {
                logFlow.finest(mapping.getPath() + " running executeList()...");
                finalMapName = BlackSailConstants.LIST;
                finalMapName = this.executeList(
                    mapping, form, request, response, user, locale, messages, errors, 
conn);
            }
            else
            if (BlackSailConstants.XML.equals(initialMapName))
            {
                logFlow.finest(mapping.getPath() + " running executeXmlList()...");
                finalMapName = this.executeXmlList(
                    mapping, form, request, response, user, locale, messages, errors, 
conn);
            }
            else
            if (BlackSailConstants.DISPLAY.equals(initialMapName))
            {
                logFlow.finest(mapping.getPath() + " running executeDisplay()...");
                finalMapName = this.executeDisplay(
                    mapping, form, request, response, user, locale, messages, errors, 
conn);
            }
            else
            if (BlackSailConstants.BLANK.equals(initialMapName))
            {
                logFlow.finest(mapping.getPath() + " running executeBlank()...");
                finalMapName = this.executeBlank(
                    mapping, form, request, response, user, locale, messages, errors, 
conn);
            }
            else
            if (BlackSailConstants.INSERT.equals(initialMapName))
            {
                logFlow.finest(mapping.getPath() + " running executeInsert()...");
                finalMapName = BlackSailConstants.BLANK;
                finalMapName = this.executeInsert(
                    mapping, form, request, response, user, locale, messages, errors, 
conn);
            }
            else
            if (BlackSailConstants.SAVE.equals(initialMapName))
            {
                logFlow.finest(mapping.getPath() + " running executeSave()...");
                finalMapName = BlackSailConstants.LIST;
                finalMapName = this.executeSave(
                    mapping, form, request, response, user, locale, messages, errors, 
conn);
            }
            else
            if (BlackSailConstants.DELETE.equals(initialMapName))
            {
                logFlow.finest(mapping.getPath() + " running executeDelete()...");
                finalMapName = BlackSailConstants.LIST;
                finalMapName = this.executeDelete(
                    mapping, form, request, response, user, locale, messages, errors, 
conn);
            }
            else
            if (BlackSailConstants.FINISHED.equals(initialMapName))
            {
                finalMapName = BlackSailConstants.FINISHED;
            }
            else
            {
                logFlow.finest(mapping.getPath() + " running executeGeneral()...");
                finalMapName = this.executeGeneral(
                    initialMapName,
                    mapping, form, request, response, user, locale, messages, errors, 
conn);
            }
        }
        catch (Exception e)
        {
            String msg = Utils.getExceptionMsgs(e);
            errors.add(ActionErrors.GLOBAL_ERROR,
                        new BaseActionError("errors.blank.1line", msg));
            connMan.rollback(conn);
            logger.severe(msg);
            request.setAttribute(BlackSailConstants.ANY_EXCEPTION, msg);
        }
        finally
        {
            connMan.closeConnection(conn);
        }

        logFlow.finer(" finished " + mapping.getPath() +
                       " with map: " + initialMapName +
                       " -> " + finalMapName);

        // Save errors back to request
        request.setAttribute(Globals.ERROR_KEY, errors);

        return getForwardObject(finalMapName, mapping, errors);
    }

    /**
     * This looks up the ActionForward from the mapping Name
     * (defined in struts-config.xml. If it can't find it, it's an error
     * of huge proportions because the programmer hasn't set it and
     * so the control is just sent to "display" with a big error msg.
     *
     * This also saves the errors back to the request.
     *
     * @param pFinalMapName The string title of the mapping name as it appears in 
struts-config.xml
     * @param mapping The struts-config.xml instantiation
     * @param pErrors  Contains any ActionError objects
     */
    private ActionForward getForwardObject(
        String finalMapName,
        ActionMapping mapping,
        ActionErrors errors)
    {
        String methodName = "getForwardObject()";

        // Get actionForward from mapping specified by finalMapName
        ActionForward lActionForward =  mapping.findForward(finalMapName);
        if (lActionForward == null)
        {
            errors.add(ActionErrors.GLOBAL_ERROR,
                       new BaseActionError("error.blank.2lines",
                       this.getClass().getName() + "." + methodName,
                       "finalMapName == " + finalMapName + "; ActionForward == null"));
            lActionForward = mapping.findForward(BlackSailConstants.ERROR);
        }

        return lActionForward;
    }

    /**
     * This is called to remove the form bean from the request or session
     *
     * @param mapping The ActionMapping as passed to the Action subclass perform()
     * @param request The request object to remove the form bean from
     * @param session The session object to remove the form bean from when it's not in 
the request
     */
    protected void deleteFormBean(
        ActionMapping mapping,
        HttpServletRequest request,
        HttpSession session)
    {
        // Remove the obsolete form bean if not needed
        if (mapping.getAttribute() != null)
        {
            if (mapping.getScope().equals("request"))
                request.removeAttribute(mapping.getAttribute());
            else
                session.removeAttribute(mapping.getAttribute());
        }
    }

    /**
     * This should be overridden by the subclass
     *
     * @param mapping   mapping object with config for formbean, ActionForward etc
     * @param form      the formbean already initialised with data from the request
     * @param request   contains parameters, session, attributes etc
     * @param response  haven't used it yet
     * @param user      the bean for the logged-in user
     * @param locale    the user's locale
     * @param messages  the message resources objects where all text strings come from
     * @param errors    contains any ActionError objects for display
     * @param conn      live DB connection
     *
     * @exception Exception  any exceptions coming from the business objects
     *
     * @return newMapName string title of the mapping name as it appears in 
struts-config.xml
     */
    public String executeList(
        ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response,
        BlackSailUser user,
        Locale locale,
        MessageResources messages,
        ActionErrors errors,
        Connection conn)
    throws Exception
    {
        String methodName = "executeList()";
        String msg = methodName + " has not been implemented yet!";
        throw new Exception(msg);
    }

    /**
     * This should be overridden by the subclass
     *
     * @param mapping   mapping object with config for formbean, ActionForward etc
     * @param form      the formbean already initialised with data from the request
     * @param request   contains parameters, session, attributes etc
     * @param response  haven't used it yet
     * @param user      the bean for the logged-in user
     * @param locale    the user's locale
     * @param messages  the message resources objects where all text strings come from
     * @param errors    contains any ActionError objects for display
     * @param conn      live DB connection
     *
     * @exception Exception  any exceptions coming from the business objects
     *
     * @return newMapName string title of the mapping name as it appears in 
struts-config.xml
     */
    public String executeXmlList(
        ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response,
        BlackSailUser user,
        Locale locale,
        MessageResources messages,
        ActionErrors errors,
        Connection conn)
    throws Exception
    {
        String methodName = "executeXmlList()";
        String msg = methodName + " has not been implemented yet!";
        throw new Exception(msg);
    }

    /**
     * This should be overridden by the subclass
     *
     * @param mapping   mapping object with config for formbean, ActionForward etc
     * @param form      the formbean already initialised with data from the request
     * @param request   contains parameters, session, attributes etc
     * @param response  haven't used it yet
     * @param user      the bean for the logged-in user
     * @param locale    the user's locale
     * @param messages  the message resources objects where all text strings come from
     * @param errors    contains any ActionError objects for display
     * @param conn      live DB connection
     *
     * @exception Exception  any exceptions coming from the business objects
     *
     * @return newMapName string title of the mapping name as it appears in 
struts-config.xml
     */
    public String executeDisplay(
        ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response,
        BlackSailUser user,
        Locale locale,
        MessageResources messages,
        ActionErrors errors,
        Connection conn)
    throws Exception
    {
        String methodName = "executeDisplay()";
        String msg = methodName + " has not been implemented yet!";
        throw new Exception(msg);
    }

    /**
     * This should be overridden by the subclass
     *
     * @param mapping   mapping object with config for formbean, ActionForward etc
     * @param form      the formbean already initialised with data from the request
     * @param request   contains parameters, session, attributes etc
     * @param response  haven't used it yet
     * @param user      the bean for the logged-in user
     * @param locale    the user's locale
     * @param messages  the message resources objects where all text strings come from
     * @param errors    contains any ActionError objects for display
     * @param conn      live DB connection
     *
     * @exception Exception  any exceptions coming from the business objects
     *
     * @return newMapName string title of the mapping name as it appears in 
struts-config.xml
     */
    public String executeBlank(
        ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response,
        BlackSailUser user,
        Locale locale,
        MessageResources messages,
        ActionErrors errors,
        Connection conn)
    throws Exception
    {
        String methodName = "executeBlank()";
        String msg = methodName + " has not been implemented yet!";
        throw new Exception(msg);
    }

    /**
     * This should be overridden by the subclass
     *
     * @param mapping   mapping object with config for formbean, ActionForward etc
     * @param form      the formbean already initialised with data from the request
     * @param request   contains parameters, session, attributes etc
     * @param response  haven't used it yet
     * @param user      the bean for the logged-in user
     * @param locale    the user's locale
     * @param messages  the message resources objects where all text strings come from
     * @param errors    contains any ActionError objects for display
     * @param conn      live DB connection
     *
     * @exception Exception  any exceptions coming from the business objects
     *
     * @return newMapName string title of the mapping name as it appears in 
struts-config.xml
     */
    public String executeInsert(
        ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response,
        BlackSailUser user,
        Locale locale,
        MessageResources messages,
        ActionErrors errors,
        Connection conn)
    throws Exception
    {
        String methodName = "executeInsert()";
        String msg = methodName + " has not been implemented yet!";
        throw new Exception(msg);
    }

    /**
     * This should be overridden by the subclass
     *
     * @param mapping   mapping object with config for formbean, ActionForward etc
     * @param form      the formbean already initialised with data from the request
     * @param request   contains parameters, session, attributes etc
     * @param response  haven't used it yet
     * @param user      the bean for the logged-in user
     * @param locale    the user's locale
     * @param messages  the message resources objects where all text strings come from
     * @param errors    contains any ActionError objects for display
     * @param conn      live DB connection
     *
     * @exception Exception  any exceptions coming from the business objects
     *
     * @return newMapName string title of the mapping name as it appears in 
struts-config.xml
     */
    public String executeSave(
        ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response,
        BlackSailUser user,
        Locale locale,
        MessageResources messages,
        ActionErrors errors,
        Connection conn)
    throws Exception
    {
        String methodName = "executeSave()";
        String msg = methodName + " has not been implemented yet!";
        throw new Exception(msg);
    }

    /**
     * This should be overridden by the subclass
     *
     * @param mapping   mapping object with config for formbean, ActionForward etc
     * @param form      the formbean already initialised with data from the request
     * @param request   contains parameters, session, attributes etc
     * @param response  haven't used it yet
     * @param user      the bean for the logged-in user
     * @param locale    the user's locale
     * @param messages  the message resources objects where all text strings come from
     * @param errors    contains any ActionError objects for display
     * @param conn      live DB connection
     *
     * @exception Exception  any exceptions coming from the business objects
     *
     * @return newMapName string title of the mapping name as it appears in 
struts-config.xml
     */
    public String executeDelete(
        ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response,
        BlackSailUser user,
        Locale locale,
        MessageResources messages,
        ActionErrors errors,
        Connection conn)
    throws Exception
    {
        String methodName = "executeDelete()";
        String msg = methodName + " has not been implemented yet!";
        throw new Exception(msg);
    }

    /**
     * This should be overridden by the subclass
     *
     * @param mapping   mapping object with config for formbean, ActionForward etc
     * @param form      the formbean already initialised with data from the request
     * @param request   contains parameters, session, attributes etc
     * @param response  haven't used it yet
     * @param user      the bean for the logged-in user
     * @param locale    the user's locale
     * @param messages  the message resources objects where all text strings come from
     * @param errors    contains any ActionError objects for display
     * @param conn      live DB connection
     *
     * @exception Exception  any exceptions coming from the business objects
     *
     * @return newMapName string title of the mapping name as it appears in 
struts-config.xml
     */
    public String executeSearch(
        ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response,
        BlackSailUser user,
        Locale locale,
        MessageResources messages,
        ActionErrors errors,
        Connection conn)
    throws Exception
    {
        String methodName = "executeSearch()";
        String msg = methodName + " has not been implemented yet!";
        throw new Exception(msg);
    }


    /**
     * This should be overridden by the subclass
     *
     * @param mapName   initial map name
     * @param mapping   mapping object with config for formbean, ActionForward etc
     * @param form      the formbean already initialised with data from the request
     * @param request   contains parameters, session, attributes etc
     * @param response  haven't used it yet
     * @param user      the bean for the logged-in user
     * @param locale    the user's locale
     * @param messages  the message resources objects where all text strings come from
     * @param errors    contains any ActionError objects for display
     * @param conn      live DB connection
     *
     * @exception Exception  any exceptions coming from the business objects
     *
     * @return newMapName string title of the mapping name as it appears in 
struts-config.xml
     */
    public String executeGeneral(
        String mapName,
        ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response,
        BlackSailUser user,
        Locale locale,
        MessageResources messages,
        ActionErrors errors,
        Connection conn)
    throws Exception
    {
        String methodName = "executeGeneral()";
        String msg = methodName + " has not been implemented yet!";
        throw new Exception(msg);
    }

    /**
     * This is called before any executeXXXX().
     * Should be overridden by subclasses.
     *
     * @param mapName   initial map name
     * @param mapping   mapping object with config for formbean, ActionForward etc
     * @param form      the formbean already initialised with data from the request
     * @param request   contains parameters, session, attributes etc
     * @param response  haven't used it yet
     * @param user      the bean for the logged-in user
     * @param locale    the user's locale
     * @param messages  the message resources objects where all text strings come from
     * @param errors    contains any ActionError objects for display
     * @param conn      live DB connection
     *
     * @exception Exception  any exceptions coming from the business objects
     *
     * @return newMapName string title of the mapping name as it appears in 
struts-config.xml
     */
    protected void executeRelatedLists(
        String mapName,
        ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response,
        BlackSailUser user,
        Locale locale,
        MessageResources messages,
        ActionErrors errors,
        Connection conn)
    throws Exception
    {
        ;
    }

    //******************** methods for relatedLists handling *********************//
    /**
     * Check if relatedListsName relatedLists in scope. If not, loads relatedLists
     * of type relatedListsType from database and stores it in scope.
     *
     * @param relatedListsType which list for this action 
     * @param contextString Name of the relatedList in some context
     * @param request       HttpSevletRequest for proof and stores of the relatedLists.
     * @param scope         javax.servlet.jsp.PageContext-Constants for the
     *                      scope, in which relatedLists to search and store.
     * @param conn          connection for database access.
     * @param whereParams   Parameters for the sql statement's where clause.
     * @param blankBeanName Name of the blank Bean (e.g. "please select", " " etc.).
     */
    public void provideList(int relatedListsType,
                            String contextString,
                            HttpServletRequest request,
                            int scope,
                            Connection conn,
                            ArrayList whereParams,
                            String blankBeanText)
        throws Exception
    {
        ArrayList result = null;
        HttpSession session = request.getSession();

        // is relatedLists already loaded?
        switch (scope)
        {
            case PageContext.SESSION_SCOPE:
            {
                result = (ArrayList) session.getAttribute(contextString);
                break;
            }
            case PageContext.APPLICATION_SCOPE:
            {
                result = (ArrayList) 
session.getServletContext().getAttribute(contextString);
                break;
            }
        }

        // if not yet loaded, load it from database
        if(result == null)
        {
            //we override getListFromFactory() in the subclass
            result = getListFromFactory(conn, relatedListsType, whereParams, 
blankBeanText);

            switch(scope)
            {
                case PageContext.SESSION_SCOPE:
                {
                    session.setAttribute(contextString, result);
                    break;
                }
                case PageContext.APPLICATION_SCOPE:
                {
                    session.getServletContext().setAttribute(contextString, result);
                    break;
                }
                default:
                {
                    request.setAttribute(contextString, result);
                }
            }
        }
        else
        {
            /* Cant see any more need for this
            RelatedListsValueBean lBlankBean = (RelatedListsValueBean) result.get(0);
            if(lBlankBean.getId().length() == 0)
            {   // relatedLists has blank bean
                if (blankBeanText == null)
                    result.remove(0);
                else
                    lBlankBean.setName(blankBeanText);
            }
            else
            {   // no blank bean in relatedLists
                if (blankBeanText != null)
                {
                    lBlankBean.setId("");
                    lBlankBean.setName(blankBeanText);
                    result.add(0, lBlankBean);
                }
            }
            */
        }
    }


    /**
     * Proof if contextString relatedLists in srcScope. If not, loads an empty
     * relatedLists and stores it in pTargetScope.
     *
     * @param request      HttpSevletRequest for proof and stores of the relatedLists.
     * @param contextString Name of the relatedLists, that use JSPs by creating of
     *                      relatedLists box.
     * @param scope        javax.servlet.jsp.PageContext-Constants for the
     *                      scope, in which relatedLists to search and store.
     */
    public void retrieveEmptyRelatedLists(
        HttpServletRequest request,
        String contextString,
        int scope,
        String blankBeanText)
    {
        ArrayList result = null;
        HttpSession session = request.getSession();

        // is relatedLists already loaded?
        switch (scope)
        {
            case PageContext.SESSION_SCOPE:
            {
                result = (ArrayList) session.getAttribute(contextString);
                break;
            }
            case PageContext.APPLICATION_SCOPE:
            {
                result = (ArrayList) 
session.getServletContext().getAttribute(contextString);
                break;
            }
        }

        // if not yet loaded, load it from database
        if(result == null)
        {
            result = this.getEmptyRelatedLists(blankBeanText);

            switch(scope)
            {
                case PageContext.SESSION_SCOPE:
                {
                    session.setAttribute(contextString, result);
                    break;
                }
                case PageContext.APPLICATION_SCOPE:
                {
                    session.getServletContext().setAttribute(contextString, result);
                    break;
                }
                default:
                {
                    request.setAttribute(contextString, result);
                }
            }
        }
    }

    /**
     * Removes contextString relatedLists in scope.
     *
     * @param request      HttpSevletRequest for searching of the relatedLists
     * @param contextString Name of the relatedLists to remove
     * @param scope        javax.servlet.jsp.PageContext-Constants for the
     *                      scope, in which the relatedLists to remove
     */
    public void removeRelatedLists(
        HttpServletRequest request,
        String contextString,
        int scope)
    {
        switch (scope)
        {
            case PageContext.REQUEST_SCOPE:
                request.removeAttribute(contextString);
                return;
            case PageContext.SESSION_SCOPE:
                request.getSession().removeAttribute(contextString);
                return;
            case PageContext.APPLICATION_SCOPE:
                
request.getSession().getServletContext().removeAttribute(contextString);
                return;
            default: return;
        }
    }

    /**
     * Override this method in the Action subclass
     * (look in another subclass for the description)
     *
     * @param relatedListsType
     * @param whereParams
     * @return an ArrayList of RelatedListsValueBeans
     */
    protected ArrayList getListFromFactory(
            Connection conn,
            int relatedListsType,
            ArrayList whereParams,
            String blankBeanName)
        throws Exception
    {
        throw new Exception("Method getListFromFactory() for Action \"" +
                             this.getClass().getName() + "\" isn't defined.");
    }


    /**
     * Return a relatedLists list with one empty item (id="0", name=pText).
     *
     * @param pText text for item
     * @return      empty relatedLists list.
     */
    protected ArrayList getEmptyRelatedLists(
        String pText)
    {
        ArrayList result = new ArrayList();

        HashMap map = new HashMap();
        map.put("id", "0");
        map.put("name", pText);

        result.add(map);

        return result;
    }


}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to