I would try the following two changes (see <---!!!!):

In your performView{} method...
...
     ActionErrors aes = new ActionErrors();
     aes.add(
      aes.GLOBAL_ERROR,
      new ActionError("error.object.notfound", "AddrBook"));
     saveErrors(request, aes);
     if (__log.isErrorEnabled())
     {
      __log.error(" [ AddrBook ] Object not found");
     }
     return  new ActionForward(mapping.getInput());  <---!!!!
    }
...

In your struts-config.xml...

     <action path="/AddrBook/view"
       parameter="VIEW"
         type="com.ilium.eapps.intmsg.controller.AddrBookAction"
         scope="request"
         name="addrBookForm"
     validate="false"
        input="/AddrBook/view.do">     <-- !!!!!
       <forward name="success" path="manager.AddrBook.view" />
       <forward name="cancel" redirect="true" path="/AddrBook/list.do" />
     </action>


This is what I do when I use the validation framework.
See also
http://jakarta.apache.org/struts/userGuide/dev_validator.html

Good luck
Koni


>basebeans wrote:
>> Yes, the ActionErrors() is in the Action class.
>> I attached the following Action class for your references, tq!
>> 
>> 
>> 
>> package com.ilium.eapps.intmsg.controller;
>> 
>> import java.util.*;
>> import org.apache.commons.logging.LogFactory;
>> import org.apache.struts.action.*;
>> import javax.rmi.PortableRemoteObject;
>> import javax.naming.InitialContext;
>> import javax.servlet.http.*;
>> import com.ilium.eapps.syslib.model.*;
>> import com.ilium.eapps.syslib.constants.*;
>> import com.ilium.eapps.syswar.controller.*;
>> import com.ilium.eapps.syswar.util.*;
>> import com.ilium.eapps.intmsg.primKey.*;
>> import com.ilium.eapps.intmsg.model.*;
>> import com.ilium.eapps.intmsg.dao.*;
>> import com.ilium.eapps.intmsg.constants.*;
>> import com.ilium.eapps.intmsg.ejb.sb.*;
>> 
>> public class AddrBookAction extends BaseLoginAction
>> {
>>  SBAddrBookHome homeAddrBook = null;
>>  SBAddrBookRemote remoteAddrBook = null;
>> 
>>  private IAddrBookDAO iAddrBookDAO;
>> 
>>  private org.apache.commons.logging.Log __log =
>>   LogFactory.getFactory().getInstance(this.getClass());
>>  private static int PAGE_LENGTH = 20;
>>  static {
>>   ResourceBundle prop =
>> ResourceBundle.getBundle("resources.application-intmsg");
>> 
>>   try
>>   {
>>    PAGE_LENGTH = Integer.parseInt(prop.getString("list.page.length"));
>>   }
>>   catch (Exception e)
>>   {
>>   }
>>  }
>> 
>>  public boolean getEJB()
>>  {
>>   try
>>   {
>>    InitialContext ctx = new InitialContext();
>>    Object objref = ctx.lookup(INTMSG_IJNDIName.SBAddrBook);
>>    homeAddrBook =
>>     (SBAddrBookHome) PortableRemoteObject.narrow(
>>      objref,
>>      SBAddrBookHome.class);
>> 
>>    remoteAddrBook = homeAddrBook.create();
>>    remoteAddrBook.setDbScheme(scheme);
>> 
>>    return true;
>>   }
>>   catch (javax.naming.NamingException e)
>>   {
>>   }
>>   catch (javax.ejb.CreateException e)
>>   {
>>   }
>>   catch (java.rmi.RemoteException e)
>>   {
>>   }
>> 
>>   return false;
>>  }
>> 
>>  public ActionForward executeAction(
>>   ActionMapping mapping,
>>   ActionForm form,
>>   HttpServletRequest request,
>>   HttpServletResponse response)
>>  {
>>   ActionForward myforward = null;
>>   String myaction = mapping.getParameter();
>> 
>>   UserSession us = (UserSession)
>> request.getSession().getAttribute(IAttrName.USER_SESSION);
>>   scheme = us.getDbScheme();
>> 
>>   if (isCancelled(request))
>>   {
>>    if (__log.isInfoEnabled())
>>    {
>>     __log.info(
>>      " [ AddrBook ] "
>>       + mapping.getAttribute()
>>       + " - action was cancelled");
>>    }
>>    return mapping.findForward("cancel");
>>   }
>>   if (__log.isInfoEnabled())
>>   {
>>    __log.info(" [ AddrBook ] action: " + myaction);
>>   }
>>   if ("".equalsIgnoreCase(myaction))
>>   {
>>    myforward = mapping.findForward(FAILURE);
>>   }
>> 
>>   if (getEJB())
>>   {
>>    if ("VIEW".equalsIgnoreCase(myaction))
>>    {
>>     myforward = performView(mapping, form, request, response);
>>    }
>>    else if ("EDIT".equalsIgnoreCase(myaction))
>>    {
>>     myforward = performEdit(mapping, form, request, response);
>>    }
>>    else if ("ADD".equalsIgnoreCase(myaction))
>>    {
>>     myforward = performAdd(mapping, form, request, response);
>>    }
>>    else if ("SAVE".equalsIgnoreCase(myaction))
>>    {
>>     myforward = performSave(mapping, form, request, response);
>>    }
>>    else if ("REMOVE".equalsIgnoreCase(myaction))
>>    {
>>     myforward = performRemove(mapping, form, request, response);
>>    }
>>    else if ("TRASH".equalsIgnoreCase(myaction))
>>    {
>>     myforward = performTrash(mapping, form, request, response);
>>    }
>>    else if ("LIST".equalsIgnoreCase(myaction))
>>    {
>>     myforward = performList(mapping, form, request, response);
>>    }
>>    else if ("LISTMAILUSR".equalsIgnoreCase(myaction))
>>    {
>>     myforward = performListMailUser(mapping, form, request, response);
>>    }
>>    else
>>    {
>>     myforward = mapping.findForward(FAILURE);
>>    }
>>   }
>>   else
>>   {
>>    myforward = mapping.findForward(IAttrName.FAILURE);
>>   }
>> 
>>   return myforward;
>>  }
>> 
>>  private ActionForward performList(
>>   ActionMapping mapping,
>>   ActionForm actionForm,
>>   HttpServletRequest request,
>>   HttpServletResponse response)
>>  {
>>   try
>>   {
>>    //System.out.println("***************** performList ****************");
>>    int offset;
>>    int length = PAGE_LENGTH;
>>    String pageOffset = request.getParameter("pager.offset");
>>    if (pageOffset == null || pageOffset.equals(""))
>>    {
>>     offset = 0;
>>    }
>>    else
>>    {
>>     offset = Integer.parseInt(pageOffset);
>>    }
>> 
>>    List AddrBookList = null;
>>    String sUrlParam = "";
>>    String sWhereClause = "";
>> 
>>    if (request.getParameter("searchFld") != null
>>     && !request.getParameter("searchFld").equals(""))
>>    {
>>     String condition = request.getParameter("searchFld");
>>     AddrBookList =
>>      remoteAddrBook.getList(
>>       offset,
>>       length,
>>       "%" + condition + "%");
>>     sWhereClause =
>>      "WHERE abid LIKE '%" + condition + "%' ";
>>     sUrlParam = "?searchFld=" + condition;
>>    }
>>    else
>>     AddrBookList = remoteAddrBook.getList(offset, length);
>> 
>>    String[] objKeys = { "AddrBook", "list" };
>>    String objKey = CacheManager.createKey(objKeys);
>>    String url =
>>     request.getContextPath()
>>      + "/intmsg"
>>      + mapping.getPath()
>>      + ".do"
>>      + sUrlParam;
>> 
>>    Integer size = (Integer) SizeCacheManager.getCache(objKey);
>>    if (size == null)
>>    {
>>     size =
>>      new Integer(
>>       remoteAddrBook.getSize(
>>        "ams012_oat_addrbook",
>>        sWhereClause));
>>     SizeCacheManager.putCache(size, objKey, 0); //no cache
>>    }
>>    String pagerHeader =
>>     Pager.generate(offset, size.intValue(), length, url);
>>    request.setAttribute("pagerHeader", pagerHeader);
>> 
>>    request.setAttribute("ADDRBOOKS", AddrBookList);
>>   }
>>   catch (Exception e)
>>   {
>>    generalError(request, e);
>>    return mapping.findForward(FAILURE);
>>   }
>> 
>>   return mapping.findForward(SUCCESS);
>>  }
>> 
>>  private ActionForward performListMailUser(
>>   ActionMapping mapping,
>>   ActionForm actionForm,
>>   HttpServletRequest request,
>>   HttpServletResponse response)
>>  {
>>   try
>>   {
>>    //System.out.println("***************** performList ****************");
>>    int offset;
>>    int length = PAGE_LENGTH;
>>    String pageOffset = request.getParameter("pager.offset");
>>    if (pageOffset == null || pageOffset.equals(""))
>>    {
>>     offset = 0;
>>    }
>>    else
>>    {
>>     offset = Integer.parseInt(pageOffset);
>>    }
>> 
>>    List MailUserList = null;
>>    String sUrlParam = "";
>>    String sWhereClause = "and LG_STS='A' ";
>>    String condition = "";
>> 
>>    if (request.getParameter("searchFld") != null
>>     && !request.getParameter("searchFld").equals(""))
>>    {
>>     condition = request.getParameter("searchFld");
>>     MailUserList =
>>      remoteAddrBook.getListMailUser(
>>       offset,
>>       length,
>>       "%" + condition + "%");
>>     sWhereClause = "and abid LIKE '%" + condition + "%' ";
>>     sUrlParam = "?searchFld=" + condition;
>>    }
>>    else
>>     MailUserList = remoteAddrBook.getListMailUser(offset, length,
>> condition);
>> 
>>    String[] objKeys = { "AddrBook", "list" };
>>    String objKey = CacheManager.createKey(objKeys);
>>    String url =
>>     request.getContextPath()
>>      + "/intmsg"
>>      + mapping.getPath()
>>      + ".do"
>>      + sUrlParam;
>> 
>>    Integer size = (Integer) SizeCacheManager.getCache(objKey);
>>    if (size == null)
>>    {
>>     String sql = "SELECT COUNT(*) "+
>>         "FROM "+scheme+".CTR004_LOGIN_ACCOUNT A, "+scheme+".CTR004_USER_INFO
>> B "+
>>         "WHERE A.USR_ID=B.USR_ID(+) " + sWhereClause;
>> 
>>     size = new Integer(remoteAddrBook.getSizeBySql(sql));
>>     SizeCacheManager.putCache(size, objKey, 0); //no cache
>>    }
>>    String pagerHeader =
>>     Pager.generate(offset, size.intValue(), length, url);
>>    request.setAttribute("pagerHeader", pagerHeader);
>> 

>>    request.setAttribute("MAILUSERS", MailUserList);
>>   }
>>   catch (Exception e)
>>   {
>>    generalError(request, e);
>>    return mapping.findForward(FAILURE);
>>   }
>> 
>>   return mapping.findForward(SUCCESS);
>>  }
>>  private ActionForward performView(
>>   ActionMapping mapping,
>>   ActionForm actionForm,
>>   HttpServletRequest request,
>>   HttpServletResponse response)
>>  {
>>   AddrBookForm form = (AddrBookForm) actionForm;
>>   try
>>   {
>>    String abid = (String) request.getParameter("abId");
>> 
>>    AddrBook addrbook = remoteAddrBook.getRec(abid);
>>    if (addrbook == null)
>>    {
>>     ActionErrors aes = new ActionErrors();
>>     aes.add(
>>      aes.GLOBAL_ERROR,
>>      new ActionError("error.object.notfound", "AddrBook"));
>>     saveErrors(request, aes);
>>     if (__log.isErrorEnabled())
>>     {
>>      __log.error(" [ AddrBook ] Object not found");
>>     }
>>    }
>>    else
>>    {
>>     org.apache.commons.beanutils.BeanUtils.populate(
>>      form,
>>      org.apache.commons.beanutils.BeanUtils.describe(addrbook));
>>    }
>>   }
>>   catch (Exception e)
>>   {
>>    generalError(request, e);
>>    return mapping.findForward(FAILURE);
>>   }
>>   return mapping.findForward(SUCCESS);
>>  }
>> 
>>  private ActionForward performSave(
>>   ActionMapping mapping,
>>   ActionForm actionForm,
>>   HttpServletRequest request,
>>   HttpServletResponse response)
>>  {
>> System.out.println("Action, performSave IN");
>>   AddrBookForm form = (AddrBookForm) actionForm;
>> 
>>   try
>>   {
>>    AddrBook addrbook = new AddrBook();
>>    org.apache.commons.beanutils.BeanUtils.populate(
>>     addrbook,
>>     org.apache.commons.beanutils.BeanUtils.describe(form));
>> 
>>    UserSession usn =
>>     (UserSession) request.getSession().getAttribute(
>>      IAttrName.USER_SESSION);
>> 
>>    int strutsAction = form.getStrutsAction();
>>    if (strutsAction == AddrBookForm.ADD)
>>    {
>>     String abid = (String) remoteAddrBook.getNewKeyId("ADDRBOOKID");
>> 
>>     if (remoteAddrBook.getRec(abid) == null)
>>     {
>>      addrbook.setAbId(abid);
>>      addrbook.setAbCreDt(System.currentTimeMillis());
>>      addrbook.setAbCreWho(usn.getUserId());
>> 
>>      remoteAddrBook.addRec(addrbook);
>>     }
>>     else
>>     {
>>      sqlDuplicateError(request, "AddrBook");
>>      return mapping.findForward(FAILURE);
>>     }
>>    }
>>    else if (strutsAction == AddrBookForm.EDIT)
>>    {
>>     remoteAddrBook.modRec(addrbook);
>>    }
>>   }
>>   catch (Exception e)
>>   {
>>    generalError(request, e);
>>    return mapping.findForward(FAILURE);
>>   }
>>   return mapping.findForward(SUCCESS);
>>  }
>> 
>>  private ActionForward performEdit(
>>   ActionMapping mapping,
>>   ActionForm actionForm,
>>   HttpServletRequest request,
>>   HttpServletResponse response)
>>  {
>>   AddrBookForm form = (AddrBookForm) actionForm;
>>   form.setStrutsAction(AddrBookForm.EDIT);
>>   try
>>   {
>>    String abid = (String) request.getParameter("abId");
>> 
>>    AddrBook addrbook = remoteAddrBook.getRec(abid);
>>    org.apache.commons.beanutils.BeanUtils.populate(
>>     form,
>>     org.apache.commons.beanutils.BeanUtils.describe(addrbook));
>> 
>>   }
>>   catch (Exception e)
>>   {
>>    generalError(request, e);
>>    return mapping.findForward(FAILURE);
>>   }
>>   return mapping.findForward(SUCCESS);
>>  }
>> 
>>  private ActionForward performAdd(
>>   ActionMapping mapping,
>>   ActionForm actionForm,
>>   HttpServletRequest request,
>>   HttpServletResponse response)
>>  {
>>   AddrBookForm form = (AddrBookForm) actionForm;
>>   form.setStrutsAction(AddrBookForm.ADD);
>>   return mapping.findForward(SUCCESS);
>>  }
>>  private ActionForward performRemove(
>>   ActionMapping mapping,
>>   ActionForm actionForm,
>>   HttpServletRequest request,
>>   HttpServletResponse response)
>>  {
>>   return performView(mapping, actionForm, request, response);
>>  }
>> 
>>  private ActionForward performTrash(
>>   ActionMapping mapping,
>>   ActionForm actionForm,
>>   HttpServletRequest request,
>>   HttpServletResponse response)
>>  {
>>   AddrBookForm form = (AddrBookForm) actionForm;
>>   try
>>   {
>>    String abid = (String) request.getParameter("abId");
>>    PKAddrBook pkAddrBook = new PKAddrBook(abid, scheme);
>>    remoteAddrBook.delRec(pkAddrBook);
>>   }
>>   catch (Exception e)
>>   {
>>    generalError(request, e);
>>    return mapping.findForward(FAILURE);
>>   }
>>   return mapping.findForward(SUCCESS);
>>  }
>> 
>> }
>> 
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> 
>> 
>
>-- 
>visit us at:
>  http://www.rothweb.ch
>  http://www.rothconsulting.com
>  Jump and the earth will rise to meet you!
>


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

Reply via email to