com.pureinfo.srm.weight.action.QueryWeightConfigAction.java Source code

Java tutorial

Introduction

Here is the source code for com.pureinfo.srm.weight.action.QueryWeightConfigAction.java

Source

/**
 * PureInfo Command-PHASE2
 * @(#)QueryWeightConfigAction.java   1.0 2007-10-23
 * 
 * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. 
 * All rights reserved, see the license file.
 * 
 * www.pureinfo.com.cn
 */

package com.pureinfo.srm.weight.action;

import java.io.IOException;

import org.apache.struts.action.ActionForward;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import com.pureinfo.ark.content.ArkContentHelper;
import com.pureinfo.ark.interaction.ActionBase;
import com.pureinfo.force.exception.PureException;
import com.pureinfo.srm.SRMTypes;
import com.pureinfo.srm.weight.domain.IWeightConfigMgr;

/**
 * <P>
 * Created on 2007-10-23 05:56:00<BR>
 * Last modified on 2007-10-23
 * </P>
 * QueryWeightConfigAction
 * 
 * @author sunjie
 * @version 1.0, 2007-10-23
 * @since Command-PHASE2 1.0
 */
public class QueryWeightConfigAction extends ActionBase {

    /**
     * @see com.pureinfo.ark.interaction.ActionBase#executeAction()
     */
    public ActionForward executeAction() throws PureException {
        int year = request.getRequiredInt("weightYear", "weight year");
        IWeightConfigMgr mgr = (IWeightConfigMgr) ArkContentHelper.getContentMgrOf(SRMTypes.WEIGHTCONFIG);
        boolean bExist = mgr.checkWeightExist(year);
        StringBuffer sbuff = new StringBuffer();
        sbuff.append("<select id=\"id_isViewProbWeight\" name=\"isViewProbWeight\">");
        sbuff.append("<option value=\"1\"></option>");
        if (bExist) {
            sbuff.append("<option value=\"0\"></option>");
        }
        sbuff.append("</select>");

        try {
            Document document = DocumentHelper.createDocument();
            Element element = document.addElement("result");
            element.setText(sbuff.toString());

            response.setCharacterEncoding("utf-8");
            response.setContentType("text/xml");
            response.setHeader("Cache-Control", "no-cache"); // HTTP 1.1
            response.setHeader("Pragma", "no-cache"); // HTTP 1.0

            response.getWriter().write(sbuff.toString());

        } catch (IOException ex1) {
            ex1.printStackTrace(System.err);
        } finally {
            sbuff.setLength(0);
        }

        return null;
    }

    public static String ttt() {

        return "";
    }

}