// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
package test;

import java.util.*;

import javax.servlet.http.*;

import org.ajaxtags.helpers.*;
import org.ajaxtags.servlets.*;

public class GetModelNamesXml extends BaseAjaxServlet {
    public String getXmlContent(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String model = request.getParameter("model");
        List lst = new ArrayList();
        if("Fiesta".startsWith(model)) lst.add(new Car("Ford", "Fiesta"));
        if("Focus".startsWith(model)) lst.add(new Car("Ford", "Focus"));
        if("Mondeo".startsWith(model)) lst.add(new Car("Ford", "Mondeo"));
        if("Golf".startsWith(model)) lst.add(new Car("VW", "Golf"));
        if("Passat".startsWith(model)) lst.add(new Car("VW", "Passat"));
        if("Polo".startsWith(model)) lst.add(new Car("VW", "Polo"));
        AjaxXmlBuilder bld = new AjaxXmlBuilder();
        bld.addItems(lst, "model", "make");
        return bld.toString();
    }
}
