Dear Geir and all,
I'm using velocity integrated with struts and i have a trouble regarding
action mapping :
  
    look at my attched files 

The form submission from product.vm to its action configured in .xml did n't
occurr, i do n't what's wrong

Any help will be appreciated.

Regards,
M. Amin
Title: Test
description
categorie
long description
supplier
producer
Title: Test
description $productForm.description
categorie $productForm.serviceCategorie
long description $productForm.longDescription
supplier $productForm.supplier
producer $productForm.producer
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd";>

<!--
     This is the Struts configuration file for the example application,
     using the proposed new syntax.

     NOTE:  You would only flesh out the details in the "form-bean"
     declarations if you had a generator tool that used them to create
     the corresponding Java classes for you.  Otherwise, you would
     need only the "form-bean" element itself, with the corresponding
     "name" and "type" attributes.
-->


<struts-config>


  <!-- ========== Data Source Configuration =============================== -->
 <data-sources>
    <data-source
       autoCommit="false"
      description="Example Data Source Configuration"
      driverClass="org.postgresql.Driver"
         maxCount="4"
         minCount="2"
         password=""
              url="jdbc:postgresql://10.0.1.14/webshop"
             user="postgres"
    />
  </data-sources>


  <!-- ========== Form Bean Definitions =================================== -->
  <form-beans>

    <form-bean      name="productForm"
                    type="com.imkenberg.manager.ProductForm"/>

  </form-beans>


  <!-- ========== Global Forward Definitions ============================== -->
  <global-forwards>
   <forward   name="success"              path="/show.vm"/>
  </global-forwards>


  <!-- ========== Action Mapping Definitions ============================== -->
  <action-mappings>

    <action    path="/savePrd"
               type="com.imkenberg.manager.SaveAction"
               name="productForm"
              scope="request"
              input="/product.vm">
     <forward   name="success"              path="/show.vm"/>
    </action>


    <!-- The standard administrative actions available with Struts -->
    <!-- These would be either omitted or protected by security -->
    <!-- in a real application deployment -->
    <action    path="/admin/addFormBean"
               type="org.apache.struts.actions.AddFormBeanAction"/>
    <action    path="/admin/addForward"
               type="org.apache.struts.actions.AddForwardAction"/>
    <action    path="/admin/addMapping"
               type="org.apache.struts.actions.AddMappingAction"/>
    <action    path="/admin/reload"
               type="org.apache.struts.actions.ReloadAction"/>
    <action    path="/admin/removeFormBean"
               type="org.apache.struts.actions.RemoveFormBeanAction"/>
    <action    path="/admin/removeForward"
               type="org.apache.struts.actions.RemoveForwardAction"/>
    <action    path="/admin/removeMapping"
               type="org.apache.struts.actions.RemoveMappingAction"/>


  </action-mappings>

</struts-config>
database org.apache.struts.webapp.example.DatabaseServlet debug 2 1 action org.apache.struts.action.ActionServlet application org.apache.struts.webapp.example.ApplicationResources config /WEB-INF/struts-config.xml debug 2 detail 2 validate true 2 vel org.apache.velocity.struts.VelServlet 4 action *.do vel *.vm index.vm /WEB-INF/app.tld /WEB-INF/app.tld /WEB-INF/struts-bean.tld /WEB-INF/struts-bean.tld /WEB-INF/struts-html.tld /WEB-INF/struts-html.tld /WEB-INF/struts-logic.tld /WEB-INF/struts-logic.tld
package com.imkenberg.manager;

import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import com.imkenberg.bo.*;
import com.imkenberg.CurrentDB;

/**
 * Title:
 * Description:
 * Copyright:    Copyright (c) 2001
 * Company:
 * @author
 * @version 1.0
 */

public class ProductForm extends ActionForm {

  private String description;
  private String serviceCategorie;
  private String longDescription;
  private String supplier;
  private String producer;

  public ProductForm() {
  }

  public void setDescription(String description){
   this.description = description;
  }

  public void setServiceCategorie(String serviceCategorie){
   this.serviceCategorie = serviceCategorie;
  }

  public void setLongDescription(String longDescription){
   this.longDescription = longDescription;
  }

  public void setSupplier(String supplier){
   this.supplier = supplier;
  }

  public void setProducer(String producer){
   this.producer = producer;
  }

  public String getDescription(){
   return this.description;
  }

  public String getServiceCategorie(){
   return this.serviceCategorie;
  }

  public String getLongDescription(){
   return this.getLongDescription();
  }

  public String getSupplier(){
   return this.supplier;
  }

  public String getProducer(){
   return this.producer;
  }

}
package com.imkenberg.manager;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Locale;
import java.util.Hashtable;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
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.action.ActionServlet;
import org.apache.struts.util.MessageResources;
import org.apache.struts.util.PropertyUtils;

import com.imkenberg.bo.*;
import com.imkenberg.CurrentDB;

/**
 * Title:
 * Description:
 * Copyright:    Copyright (c) 2001
 * Company:
 * @author
 * @version 1.0
 */

public class SaveAction extends Action {

  public SaveAction() {
  }

  public ActionForward perform(ActionMapping mapping,
				 ActionForm form,
				 HttpServletRequest request,
				 HttpServletResponse response)
	throws IOException, ServletException {

	// Extract attributes and parameters we will need
	Locale locale = getLocale(request);
	MessageResources messages = getResources();
	HttpSession session = request.getSession();

        return (mapping.findForward("success"));

  }


}

Reply via email to