Java tutorial
/** * PureInfo Command * @(#)Product3indexDuplicateAction.java 1.0 2007-8-22 * * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. * All rights reserved, see the license file. * * www.pureinfo.com.cn */ package com.pureinfo.srm.product.action; import org.apache.commons.lang.StringUtils; import org.apache.struts.action.ActionForward; import com.pureinfo.ark.content.ArkContentHelper; import com.pureinfo.ark.interaction.list.SearchAction2; import com.pureinfo.force.exception.PureException; import com.pureinfo.srm.SRMWebHelper; import com.pureinfo.srm.product.domain.IProductMgr; import com.pureinfo.srm.product.model.Product; public class Product3indexDuplicateAction extends SearchAction2 { private String productIds[]; private String m_sProduct0Ids; public ActionForward beforeExecution() throws PureException { m_sProduct0Ids = request.getParameter("product0Ids"); if (StringUtils.isNotEmpty(m_sProduct0Ids)) { logger.debug("************************" + m_sProduct0Ids); productIds = m_sProduct0Ids.split(","); // for(int i = 0; i<productIds.length;i++){ // logger.debug("productids["+i+"]"+productIds[i]+"\n"); // } } return super.beforeExecution(); } public ActionForward executeAction() throws PureException { boolean bIsAudit = request.getBoolean("audit"); IProductMgr mgr = (IProductMgr) ArkContentHelper.getContentMgrOf(Product.class); long nTimeNow = System.currentTimeMillis(); // int nCount = mgr.hasComfirmedDuplicateMember(productIds, bIsAudit); if (nCount == 0) {// for (int i = 0; i < productIds.length; i++) { mgr.updateAfterDuplicatedByProductId(productIds[i], bIsAudit, nTimeNow); } } else if (nCount == 1) {// } else if (nCount > 1) {// } return mapping.findForward("success"); } public String getSubmitee() { String sSubmitee = request.getParameter("action"); return sSubmitee; } public String getTitle() { return ""; } public String getHeadTable() throws PureException { StringBuffer sbuff = new StringBuffer(); try { sbuff.append("<tr><TD align=\"right\"> \n"); sbuff.append( SRMWebHelper.renderCountOfPage(request.getInt(SRMWebHelper.COUNT_OF_PAGE, "", 15))); sbuff.append("<input type=\"button\" onclick='changeCountOfPage()' value=\"\">"); sbuff.append("<script language=\"javascript\">\n"); sbuff.append(" function changeCountOfPage() {\n"); sbuff.append(" var objs = document.getElementsByName('").append(SRMWebHelper.COUNT_OF_PAGE) .append("');\n"); sbuff.append(" var obj;"); sbuff.append(" for (var i = 0; i < objs.length; i ++) {"); sbuff.append(" if (objs[i].tagName == 'SELECT') obj = objs[i];"); sbuff.append(" }\n"); sbuff.append(" var nValue = obj.options[obj.selectedIndex].value;\n"); sbuff.append(" if (HideForm.").append(SRMWebHelper.COUNT_OF_PAGE).append("==null) {"); sbuff.append(" var sAction = HideForm.action;\n"); sbuff.append(" if (sAction.indexOf('?')>0) {\n"); sbuff.append(" sAction += '&").append(SRMWebHelper.COUNT_OF_PAGE).append("='+nValue;\n"); sbuff.append(" } else {\n"); sbuff.append(" sAction += '?").append(SRMWebHelper.COUNT_OF_PAGE).append("='+nValue;\n"); sbuff.append(" }\n"); sbuff.append(" HideForm.action=sAction;\n"); sbuff.append(" } else { \n"); sbuff.append(" HideForm.").append(SRMWebHelper.COUNT_OF_PAGE).append(".value=nValue\n"); sbuff.append(" }"); sbuff.append(" HideForm.submit();"); sbuff.append("}"); sbuff.append("</script>"); sbuff.append("</td></tr>"); return sbuff.toString(); } finally { sbuff.setLength(0); } } public String getScenery() { return "3index_list"; } }