public int doStartTag() throws JspException { JspWriter out = pageContext.getOut(); try { out.println("<script language='Javascript'> "); out.println("<!-- "); out.println("function checkFloatKey(key) { // check if the input key is allowed "); if (bNegative) { out.println("if ( key==45 ) { // negative sign '-' is allowed "); out.println(" return true; "); out.println("} "); } out.println(" if ( key>=48 && key<=57 || key==46 ) { // allow input for digit and . "); out.println(" return true; "); out.println(" } "); out.println(" return false; "); out.println("} "); out.println("function checkFloatValue(elm) { // check if the value is a number "); if (bNegative) { out.println("if ( isNaN(elm.value) ) { "); } else { out.println("if ( isNaN(elm.value) || elm.value<0 ) { "); } out.println( " alert('" + MessageResourcesFactory.getMessage( (Locale) pageContext.getSession().getAttribute(org.apache.struts.Globals.LOCALE_KEY), "errors.float", MessageResourcesFactory.getMessage( (Locale) pageContext .getSession() .getAttribute(org.apache.struts.Globals.LOCALE_KEY), "errors.input")) + "');"); out.println(" elm.focus(); "); out.println(" } "); out.println("} "); out.println("//--> "); out.println("</script> "); } catch (Exception e) { throw new JspException(e); } setOnkeypress("return checkFloatKey(window.event.keyCode);"); setOnblur("return checkFloatValue(this);"); return super.doStartTag(); }
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException { MaintDmsRenameForm actionForm = (MaintDmsRenameForm) form; // DmsDocument document = (DmsDocument) actionForm.getFormData(); SessionContainer sessionContainer = this.getSessionContainer(request); Connection conn = this.getConnection(request); DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, conn); String opMode = actionForm.getOpMode(); /* * joan.xiong update code for bug EIP-153 by 2006/09/19 */ // DmsDocument document = // docRetrievalManager.getDocumentByID(TextUtility.parseIntegerObj(actionForm.getID())); DmsDocument document = (DmsDocument) new com.dcivision.dms.dao.DmsDocumentDAObject(sessionContainer, conn) .getDocumentByID( TextUtility.parseIntegerObj(actionForm.getID()), actionForm.getRecordStatus()); /* * joan.xiong update code end */ String path = docRetrievalManager.getLocationPath(TextUtility.parseIntegerObj(actionForm.getParentID())); request.setAttribute("location", path); // Add By Jim Zhou 2007/0110 EIP-1292 if (!"E".equals(document.getRecordStatus())) { MaintDmsDocumentForm documentForm = (MaintDmsDocumentForm) form; // Integer documentID = TextUtility.parseIntegerObj(documentForm.getID()); // DmsDocument document = docRetrievalManager.getDocument(documentID); DocumentValidateManager docValidateManager = new DocumentValidateManager(sessionContainer, conn); StringBuffer message = new StringBuffer(); DmsValidation validation = docValidateManager.validateOperateAction(document, false, "N"); List lstIdMisRight = validation.getLstIdReject(); List lstIdBeLocked = validation.getLstIdlocked(); List lstIdBeDeleted = validation.getLstIdDeleted(); List lstIdBeArchived = validation.getLstIdArchived(); List lstIdRelationship = validation.getLstIdHaveRelationship(); if (!lstIdMisRight.isEmpty() || !lstIdBeLocked.isEmpty() || !lstIdBeDeleted.isEmpty() || !lstIdBeArchived.isEmpty()) { for (int i = 0; i < lstIdMisRight.size(); i++) { // request.getSession().setAttribute(org.apache.struts.Globals.ERROR_KEY,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.no_permission",docRetrievalManager.getLocationPath((Integer)lstIdMisRight.get(i)))); // addMessage(request,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.no_permission",docRetrievalManager.getLocationPath((Integer)lstIdMisRight.get(i)))); message.append( MessageResourcesFactory.getMessage( sessionContainer.getSessionLocale(), "errors.dms.no_permission", docRetrievalManager.getLocationPath((Integer) lstIdMisRight.get(i))) + "\n"); } for (int i = 0; i < lstIdBeLocked.size(); i++) { // request.getSession().setAttribute(org.apache.struts.Globals.ERROR_KEY,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.been_checkout",docRetrievalManager.getLocationPath((Integer)lstIdBeLocked.get(i)))); // addMessage(request,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.been_checkout",docRetrievalManager.getLocationPath((Integer)lstIdBeLocked.get(i)))); message.append( MessageResourcesFactory.getMessage( sessionContainer.getSessionLocale(), "errors.dms.been_checkout", docRetrievalManager.getLocationPath((Integer) lstIdBeLocked.get(i))) + "\n"); } for (int i = 0; i < lstIdBeDeleted.size(); i++) { // request.getSession().setAttribute(org.apache.struts.Globals.ERROR_KEY,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.been_deleted",docRetrievalManager.getLocationPath((Integer)lstIdBeDeleted.get(i)))); // addMessage(request,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.been_deleted",docRetrievalManager.getLocationPath((Integer)lstIdBeDeleted.get(i)))); message.append( MessageResourcesFactory.getMessage( sessionContainer.getSessionLocale(), "errors.dms.been_deleted", docRetrievalManager.getLocationPath((Integer) lstIdBeDeleted.get(i))) + "\n"); } for (int i = 0; i < lstIdBeArchived.size(); i++) { // request.getSession().setAttribute(org.apache.struts.Globals.ERROR_KEY,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.been_archived",docRetrievalManager.getLocationPath((Integer)lstIdBeArchived.get(i)))); // addMessage(request,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.been_archived",docRetrievalManager.getLocationPath((Integer)lstIdBeArchived.get(i)))); message.append( MessageResourcesFactory.getMessage( sessionContainer.getSessionLocale(), "errors.dms.been_archived", docRetrievalManager.getLocationPath((Integer) lstIdBeArchived.get(i))) + "\n"); } actionForm.setRefreshTag("1"); addMessage(request, message.toString()); actionForm.setDocumentName(""); request.getSession().setAttribute(org.apache.struts.Globals.ERROR_KEY, message.toString()); return mapping.findForward(GlobalConstant.NAV_MODE_EDIT); } } // Add End try { if (DmsOperationConstant.RENAME_OPERATION.equals(opMode)) { // Insert operation. log.debug("enter rename"); if (!actionForm.getDocumentName().equals(document.getDocumentName())) { this.renameRecord(mapping, actionForm, request, response); this.commit(request); actionForm.setRefreshTag("1"); addMessage(request, MESSAGE_RECORD_RENAME); actionForm.setDocumentName(""); // // request.getSession().setAttribute(MESSAGE_RECORD_RENAME,MESSAGE_RECORD_RENAME);//joan.xiong add code for bug EIP-172 by 2006/10/12 request .getSession() .setAttribute(org.apache.struts.Globals.MESSAGE_KEY, MESSAGE_RECORD_RENAME); } } } catch (ApplicationException appEx) { this.rollback(request); handleApplicationException(request, appEx); // throw new ApplicationException(ErrorConstant.DB_UPDATE_ERROR); } return mapping.findForward(GlobalConstant.NAV_MODE_EDIT); }
public String getStartContent() { SessionContainer sessionContainer = (SessionContainer) tag.getPageContext().getSession().getAttribute(GlobalConstant.SESSION_CONTAINER_KEY); String contextPath = (String) tag.getPageContext().getServletContext().getAttribute(GlobalConstant.CONTEXT_PATH_KEY); String label = MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), tag.getLabel()); String iconUrl = SourceManage.getImgSrc(tag.getPageContext(), tag.getIcon(), true, false); String link = contextPath + tag.getLink(); Filter filter = FilterFactory.getFilterByName(tag.getPageContext(), tag.getFilterName()); StringBuffer bstr = new StringBuffer(); bstr.append("<DIV ID=\"" + tag.getFilterName() + "\">"); bstr.append("<table width=\"98%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"); bstr.append("<tr>"); bstr.append("<td height=\"45\">"); bstr.append( "<table width=\"100%\" height=\"45\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); bstr.append("<tr>"); bstr.append( "<td width=\"58\" height=\"45\"><img id='icon' src='" + iconUrl + "' border=0/></td>"); bstr.append( "<td height=\"45\" valign=\"bottom\" background=" + SourceManage.getImgSrc(tag.getPageContext(), "LayoutTableTopbg.gif", true, false) + " class=\"maintitle\">"); bstr.append( "<table width=\"100%\" height=\"30\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); bstr.append("<tr>"); bstr.append( "<td class=\"maintitle\"><a href=\"" + link + "\" style=\"color:#FFFFFF;TEXT-DECORATION:none\" >" + label + "</a></td>"); bstr.append("</tr></table>"); bstr.append("</td>"); bstr.append( "<td height=\"45\" valign=\"bottom\" background=" + SourceManage.getImgSrc(tag.getPageContext(), "LayoutTableTopbg.gif", true, false) + " class=\"maintitleright\">"); bstr.append( "<table width=\"100%\" height=\"30\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); bstr.append("<tr>"); bstr.append("<td class=\"maintitleright\">"); bstr.append("<table width=\"100%\"><tr><td> </td>"); bstr.append("<td class=\"maintitleleft\" width=\"200\">"); bstr.append(tag.getSelectFilter(filter)); bstr.append("</td></tr></table></td>"); bstr.append( "<td class=\"maintitleright\"><a href=\"javascript:toggleShowHide('" + tag.getFilterName() + "DATA');\" style=\"color:white;text-decoration:none\"><img id=\"eventArrow\" name=\"eventArrow\" src=\"" + SourceManage.getImgSrc(tag.getPageContext(), "IconHeadingMinimize.gif", true, false) + "\" border=\"0\"></a></td>"); bstr.append("</tr>"); bstr.append("</table>"); bstr.append("</td>"); bstr.append( "<td width=\"9\" height=\"45\"><p><img src=" + SourceManage.getImgSrc(tag.getPageContext(), "LayoutTableRighttop.gif", true, false) + " /></p></td>"); bstr.append("</tr>"); bstr.append("</table>"); bstr.append("</td>"); bstr.append("</tr>"); bstr.append("<tr>"); bstr.append("<td>"); bstr.append("<div id=\"" + tag.getFilterName() + "DATA\" class=\"scrollable\">"); bstr.append( "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#CCCCCC\">"); bstr.append("<tr>"); bstr.append("<td>"); bstr.append("<DIV ID=" + tag.getFilterName() + "BODY>"); bstr.append( "<table border=\"0\" cellspacing=\"1\" cellpadding=\"3\" style=\"table-layout:fixed;width:100%;\">"); // ---------Title start---------------------------------------------------------------- bstr.append("<tbody id=\"TBODY\">"); bstr.append("<tr align=\"center\" bgcolor=\"#F1EFDE\">"); return bstr.toString(); }