当前位置: 代码迷 >> Web前端 >> 三级联
  详细解决方案

三级联

热度:84   发布时间:2012-09-01 09:33:03.0
3级联
//引入js文件
<script
src="<%=request.getContextPath()%>/js/getchildren.js" type="text/javascript" charset="utf-8"></script>

ACTION
@SuppressWarnings("unchecked")
    public ActionForward getProductNodeByAjax(ActionMapping mapping,
        ActionForm form, HttpServletRequest aRequest,
        HttpServletResponse aResponse) throws Exception
    {
        //设置返回的编码
        aResponse.setContentType("text/json; charset=UTF-8");
        //得到session
        HttpSession session = aRequest.getSession();
        // 得到语种
        String nls = (String) session.getAttribute(SupportConstants.CFG_NLS);
        //查询接口
        DDService dDService = DDFactory.getInstance().getCommonDD();
        //取得查询条件
        String productLine = aRequest.getParameter("productLine");
        String productFamily = aRequest.getParameter("productFamily");
        PrintWriter out = null;
        //webservice调用后的json对象
        JSONArray jsonArray = new JSONArray();
        try {
            if (null != productLine
                    && !"".equals(productLine.trim())
                    && (null == productFamily || "".equals(productFamily.trim())))
            {
                //级联出产品族
                ArrayList dList_family =
                    dDService.getItemsListByName("PRODUCT_FAMILY", productLine, nls);

                jsonArray = com.huawei.it.support.poapply.actions.JsonUtil.listToJSONArray(dList_family);
            } else if (null != productLine && !"".equals(productLine.trim())
                    && null != productFamily
                    && !"".equals(productFamily.trim())) {
                //级联出产品
                ArrayList dList_product =
                    dDService.getItemsListByName("PRODUCT", productFamily, nls);
                jsonArray = com.huawei.it.support.poapply.actions.JsonUtil.listToJSONArray(dList_product);
            }
            out = aResponse.getWriter();
            out.print(jsonArray);
            out.flush();
        } catch (Exception e)
        {
            e.printStackTrace();
            throw e;
        } finally {
            if (null != out){
                out.close();
            }
        }
        return null;
    }
  相关解决方案