>>>>> "David" == David M Karr <[EMAIL PROTECTED]> writes:

    David> Tomcat3.2.3 (with JBoss2.4.1).
    David> I have several architectural and technical issues I'm trying to resolve 
with a
    David> quite simple page arrangement.  I'd appreciate any guidance, both towards
    David> fixing what I have, and producing a more "sane" arrangement, if there's
    David> something basicallywrong with my architecture.

Update:

I realized that my "perform" method was looking for the "forward" in the
servlet, instead of the ActionMapping.  Once I fixed that, the initial display
of the class list worked fine.

Then, I clicked one of the Edit buttons, changed one of the fields, clicked the
Save button, and it displayed the following error:

---------------------
Error: 500
Location: /sgs/class/listClasses.jsp
Internal Servlet Error:

javax.servlet.ServletException: Cannot find bean listClassesForm in scope null
        at 
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:459)
        at 
c_00025ass._0002fclass_0002flistClasses_0002ejsplistClasses_jsp_31._jspService(_0002fclass_0002flistClasses_0002ejsplistClasses_jsp_31.java:459)
   ...
---------------------

I'm not completely certain what the effect of the 'scope="request"' attribute
in the "action" element, but I thought this might be related to this.  So, I
changed it to "session" and redeployed.

Now, after clicking "Save", it didn't get the error, and it redisplayed the
class list page, but without showing the change in content.  It seems like
forwarding to "listClasses" through the forward list didn't execute the
Action's "perform" method, which automatically updates the list of classes.  Is
this expected?  What should be the correct procedure to get the list refreshed?

Note that I also commented out the line in my ActionForm.reset() method which
updates the class list.  I'm now doing that in the "Action.perform()" method,
which I believe is more correct.

For more context, I'll leave the excerpts from my original note showing the
"struts-config.xml" and the Action and Form classes (before I fixed the
"forward" reference and commented out the line in the Form class).

    David> Here's my struts-config.xml, with two choices for the "listClasses" action, 
one
    David> being commented out.

    David> ------------------------------
    David> <?xml version="1.0" encoding="ISO-8859-1" ?>
    David> <!DOCTYPE struts-config PUBLIC
    David>   "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
    David>   "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd";>
    David> <struts-config>
    David>  <form-beans>
    David>   <form-bean name="listClassesForm" 
type="com.intsoft.sgs.web.forms.ListClassesForm"/>
    David>   <form-bean name="editClassForm" 
type="com.intsoft.sgs.web.forms.EditClassForm"/>
    David>   <form-bean name="saveClassForm" 
type="com.intsoft.sgs.web.forms.SaveClassForm"/>
    David>  </form-beans>
    David>  <action-mappings>
    David>   <action path="/class/listClasses" name="listClassesForm"
    David>                       forward="/class/listClasses.jsp"
    David>                       scope="session">
    David>   </action>
    David> <!--
    David>   <action path="/class/listClasses" name="listClassesForm"
    David>                       scope="request"
    David>                       type="com.intsoft.sgs.web.actions.ListClassesAction">
    David>    <forward name="success" path="/class/listClasses.jsp"/>
    David>   </action>
    --> 
    David>   <action path="/class/editClass" name="editClassForm"
    David>                       scope="request"
    David>                       type="com.intsoft.sgs.web.actions.EditClassAction">
    David>    <forward name="success" path="/class/editClass.jsp"/>
    David>   </action>
    David>   <action path="/class/saveClass" name="saveClassForm"
    David>           scope="request"
    David>                       type="com.intsoft.sgs.web.actions.SaveClassAction">
    David>    <forward name="success" path="/class/listClasses.jsp"/>
    David>   </action>
    David>  </action-mappings>
    David> </struts-config>
    David> ------------------------------
    David> ---------------
    David> public final class ListClassesAction extends Action
    David> {
    David>     public ActionForward perform(ActionMapping        mapping,
    David>                                  ActionForm           form,
    David>                                  HttpServletRequest   request,
    David>                                  HttpServletResponse  response)
    David>        throws IOException, ServletException
    David>    {
    David>       System.out.println("In ListClassesAction.perform().");
    David>       System.out.println("form[" + form + "]");
    David>       if (form != null)
    David>       {
    David>          ListClassesForm   listClassesForm   = (ListClassesForm) form;
    David>          System.out.println("Getting all classes.");
    David>          listClassesForm.setAllClasses(ClassDAO.getAllClasses());
    David>          System.out.println("Got all classes.");
    David>       }
      
    David>       ActionForward  actionForward  = servlet.findForward("success");
    David>       System.out.println("actionForward[" + actionForward + "]");
    David>       return (actionForward);
    David> //       return (servlet.findForward("success"));
    David>    }
    David> }
    David> ---------------

    David> ---------------
    David> public final class ListClassesForm extends ActionForm
    David> {
    David>    private  Collection  _allClasses = null;

    David>    public   Collection  getAllClasses() { return (_allClasses); }
   
    David>    public   void  setAllClasses(Collection allClasses)
    David>    { _allClasses = allClasses; }

    David>    public   void  reset(ActionMapping mapping, HttpServletRequest request)
    David>    {
    David>       System.out.println("In ListClassesForm.reset().");
    David>       setAllClasses(ClassDAO.getAllClasses());
    David>    }
    David> }
    David> ---------------


-- 
===================================================================
David M. Karr          ; Best Consulting
[EMAIL PROTECTED]   ; Java/Unix/XML/C++/X ; BrainBench CJ12P (#12004)

Reply via email to