Here is my MenuAction.java

package actions;

import org.apache.struts.action.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Arrays.*;
import java.io.*;
import forms.*;
import beans.InfoBean;
import logic.DB;

public class MenuAction extends Action {
   public ActionForward execute(ActionMapping mapping, ActionForm form,
                               HttpServletRequest request,
                               HttpServletResponse response)
                               throws IOException, ServletException
   {
       String action;
HttpSession session;
       DB data = new DB();
InfoBean sorted [] = new InfoBean [data.getInformation().size()]; try
       {
           session = request.getSession();
action = request.getParameter("action");
           if(action.equals("enterInfo"))
           {
               return (mapping.findForward("enter"));
           }
           else if(action.equals("default"))
           {
               sorted = data.createSortedArray("ascending", "first");
               data.removeInsert(sorted);
               data.createContext(sorted);
               return (mapping.findForward("default"));
           }
           else
           {
               return  (mapping.findForward("sort"));
           }
       }
       catch (Exception e)
       {
           e.printStackTrace();
       }
       return (mapping.findForward("menu"));
   }
}


I am also including part of the webpage source file incase the problem is in there and its a html error.

<form name="menu" action=$link.setAction("Menu") method="get">
          <input type="hidden" name="action" value="menu">
           <table width="200" cellspacing="0" cellpadding="0">
               <tr>
                   <td>
                       <label><input type="radio" name="displayMenu" value="enterInfo" 
onchange="menu.action.value='enterInfo'"  >$text.get("menuEnter")</label>
                   </td>
               </tr>
               <tr>
                   <td>
                       <label><input type="radio" name="displayMenu" value="default" 
onchange="menu.action.value='default'">$text.get("menuDefault")</label>
                   </td>
               </tr>
               <tr>
                   <td>
                       <label><input type="radio" name="displayMenu" value="sort" 
onchange="menu.action.value='sort'">$text.get("menuSort")</label>
                   </td>
               </tr>
           </table>
           <input type="submit" name="Submit" value=$text.get("menuSubmit") >
           </form>

The $text variable is a varable that is defined in the velocity tools package. The variables are defined in a properties file I defined. When displayed on the web the $text variable is exchanged with the mapping in the properties file.

-Paul

Frank W. Zammetti wrote:

On Mon, June 13, 2005 12:54 am, Paul Goepfert said:
Well I just created a test jsp file to see if I got to the page.  I
didn't.  I just want to  be sure about one thing.  I am soppose to have
multiple actions in my struts config? One for each  page? Right?

How your app is configured is completely up to you... there are no rules
per se (there's some commonly-accepted pattersn though).  You might have
10 Actions for a single page (reasonable in some cases), or one Action for
10 pages (probably not a good idea generally), or one per page (most
common I'd say), or something else I haven't thought of.

I'm guessing, based on the config you posted, that you are submitting a
form to /Menu when any of a number of menu items are clicked?  Then in the
Action you are determine which was clicked and forwarding to the
appropriate Velocity template?  If so, that's a reasonable approach...
some would say you should probably use a DispatchAction, but it's more a
matter of what you prefer than what is right or wrong.

Now... why you aren't seeing the JSP... I think you want to solve that
before anything else... The first thing to do is be sure what forward is
being returned... As a matter of fact, how about posting your Action's
code?  I assume it isn't too big... There might be something obvious that
I or someone else can point out right away... You either have something
configured wrong, or the Action's code is wrong... Are you sure the Action
is being reached at all?  If so then most of your configuration it
obviously correct, the only remaining point could be the forward
declarations.  Nothing stands out as wrong to me though, so seeing the
code might help.

Frank

-Paul

Frank W. Zammetti wrote:

Ok... I probably can't be of too much help then... I've never used
Velocity.

One thing to try though... change your forwards to go to a test JSP...
if you get to it, then the problem is in the Velocity side of things
(or the forward to the Velocity templates).  At least you'll narrow
down your focus a bit.

Frank

Paul Goepfert wrote:

I am forwarding to a web page.  The .vm file extension is mapped to
org.apache.velocity.tools.view.servlet.VelocityViewServlet.  I am
using Apache Velocity for my Web page design.  Should I be forwarding
to Actions?

My intention is to go to a Velocity page rather then an html or JSP.

-Paul
Frank W. Zammetti wrote:

What are you forwarding to in this mapping Paul?  Is .vm the
extension your application uses to map to ActionServlet, in which
case you are forwarding to Actions?  Or is it something else?

Most commonly, the forwards go to JSPs (although not necessarily).

You are correct in your thinking with regard to what Martin said...
there are no special meaning forward names that I am aware of, you
can name your forwards whatever you wish.  Success and Failure are
two very common names however.

Is your intention to go to a JSP when you return a given forward
from your Action?  If so, I suspect that is what is wrong... change
the paths  on the forwards... if your intention is something else,
please explain so we can try and help :)

Frank

Paul Goepfert wrote:

Ok, here is the problem.  When I load up my web app the page loads
fine.  When I try to advance to another web page in my web app all
I get is a blank screen.  For every page I have a form.java and an
action.java file so I can move through the web app.  Here is part
of my struts-config file that handles the actions.

<action path="/Menu"
               type="actions.MenuAction"
               name="menuForm"
               scope="request">
         <forward name="enterInfo"
                  path="/info.vm" />
         <forward name="default"
                  path="/results.vm" />
         <forward name="sort"
                  path="/sort.vm" />
</action>

In the form.java files I have getters and setters for the
information I pass through the address bar.  In the action.java
files I  have method calls to my logic for the program as well as
forwards for the next page I wannt to go to.

If anyone can help me out that would be great.  If more information
is needed let me know.

-Paul

---------------------------------------------------------------------
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]

Reply via email to