package weber_4_0_sample.org.itscool.ajax;

import java.io.IOException;
import org.itscool.commons.document.BeanToXmlDocument;
import org.itscool.weber.action.Action;
import org.itscool.weber.action.ActionBucket;
import org.itscool.weber.controller.Globals;
import org.w3c.dom.Document;

public class AjaxSample3Action extends Action {
    public static final String LINE=System.getProperty("line.separator");
    
    public String doExecute(ActionBucket bucket)throws Exception{
        String kind = (String)this.getParameter("kind");
        
        //僪僉儏儊儞僩僆僽僕僃僋僩偺嶌惉
        BeanToXmlDocument beanToXml = new BeanToXmlDocument("mart");
        
        if(kind.equals("desktop")){
            Computer computer = new Computer();
            computer.setModel("KANO model1");
            computer.setOs("WindowsXP Home");
            computer.setCpu("Celeron2 Gh");
            computer.setMemory("SDRAM 256MB");
            computer.setHdd("40GB 7200rpm");
            computer.setDvd("CD-ROM");
            computer.setDisplay("KANO");
            computer.setPrice("62,000");
            beanToXml.addElement(computer, "computer");
        }else if(kind.equals("server")){
            Computer computer = new Computer();
            computer.setModel("MICHIAKI儌僨儖1");
            computer.setOs("WindowsXP Home");
            computer.setCpu("Celeron2 Gh");
            computer.setMemory("SDRAM 256MB");
            computer.setHdd("400000GB 7200rpm");
            computer.setDvd("CD-ROMROM");
            computer.setDisplay("KANO");
            computer.setPrice("10000,000");
            beanToXml.addElement(computer, "computer");
            computer.setModel("MICHIAKI儌僨儖2");
            beanToXml.addElement(computer, "computer");
            computer.setModel("MICHIAKI儌僨儖3");
            beanToXml.addElement(computer, "computer");
            computer.setModel("MICHIAKI儌僨儖4");
            beanToXml.addElement(computer, "computer");
        }else if(kind.equals("note")){
            Computer computer = new Computer();
            computer.setModel("IBM ThinkPad");
            computer.setOs("WindowsXP Home");
            computer.setCpu("Celeron2 Gh");
            computer.setMemory("SDRAM 512MB");
            computer.setHdd("60GB 7200rpm");
            computer.setDvd("DVD-ROM");
            computer.setDisplay("Torinitron");
            computer.setPrice("1,000");
            beanToXml.addElement(computer, "computer");
        } else if(kind.equals("option")){
            Computer computer = new Computer();
            computer.setModel("廃曈婡婍1");
            computer.setOs("WindowsXP Home");
            computer.setCpu("Celeron2 Gh");
            computer.setMemory("SDRAM 512MB");
            computer.setHdd("60GB 7200rpm");
            computer.setDvd("DVD-ROM");
            computer.setDisplay("Torinitron");
            computer.setPrice("1,000");
            beanToXml.addElement(computer, "computer");
            
            computer.setModel("廃曈婡婍1");
            beanToXml.addElement(computer, "computer");
            computer.setModel("廃曈婡婍2");
            beanToXml.addElement(computer, "computer");
            computer.setModel("廃曈婡婍3");
            beanToXml.addElement(computer, "computer");
            computer.setModel("廃曈婡婍4");
            beanToXml.addElement(computer, "computer");
            computer.setModel("廃曈婡婍5");
            beanToXml.addElement(computer, "computer");
            
        }else if(kind.equals("printer")){
            Computer computer = new Computer();
            computer.setModel("僾儕儞僞1");
            computer.setOs("WindowsXP Home");
            computer.setCpu("Celeron2 Gh");
            computer.setMemory("SDRAM 512MB");
            computer.setHdd("60GB 7200rpm");
            computer.setDvd("DVD-ROM");
            computer.setDisplay("Torinitron");
            computer.setPrice("1,000");
            beanToXml.addElement(computer, "computer");
        }
        bucket.printXml(beanToXml);
        
        return Globals.RET_NOFORWARD;
    }
}