/*
 * NewStrutsAction.java
 *
 * Created on May 23, 2007, 1:36 PM
 */

package com.myapp.struts;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

import org.json.*;

/**
 *
 * @author cmott
 * @version
 */

public class NewStrutsAction extends Action {
    
    /* forward name="success" path="" */
    private final static String SUCCESS = "success";

    private String[] countries =
        new String[] {
            "Japan", "Thailand", "Uganda", "Ukraine", 
            "United States of America"
        };
   
    private String[] countryCodes =
        new String[] {
            "JP", "TH", "UG", "UR", "USA"
        };

    
    public JSONArray getCountryService() {
	JSONArray countriesData = new JSONArray();
        JSONArray countryData = new JSONArray();
        for (int loop=0; loop < countries.length; loop++){
		countryData.put(countries[loop]);
		countryData.put(countryCodes[loop]);
		countriesData.put(countryData);
		countryData = new JSONArray();
	}
        
	return countriesData;
}
    
    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return
     */
    public ActionForward execute(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        
        return mapping.findForward(SUCCESS);
        
    }
}
