📄 htmlscreenrenderer.java
字号:
StringBuffer newURL = new StringBuffer(); ContentUrlTag.appendContentPrefix(request, newURL); newURL.append(src); writer.write(newURL.toString()); } } else { writer.write(src); } writer.write("\""); } writer.write("/>"); appendWhitespace(writer); } public void renderContentBegin(Writer writer, Map context, ModelScreenWidget.Content content) throws IOException { String editRequest = content.getEditRequest(context); String editContainerStyle = content.getEditContainerStyle(context); String enableEditName = content.getEnableEditName(context); String enableEditValue = (String)context.get(enableEditName); if (Debug.verboseOn()) Debug.logVerbose("directEditRequest:" + editRequest, module); if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) { writer.write("<div"); writer.write(" class=\"" + editContainerStyle + "\"> "); appendWhitespace(writer); } } public void renderContentBody(Writer writer, Map context, ModelScreenWidget.Content content) throws IOException { Locale locale = Locale.getDefault(); Boolean nullThruDatesOnly = new Boolean(false); String mimeTypeId = "text/html"; String expandedContentId = content.getContentId(context); String renderedContent = null; GenericDelegator delegator = (GenericDelegator) context.get("delegator"); if (Debug.verboseOn()) Debug.logVerbose("expandedContentId:" + expandedContentId, module); try { if (UtilValidate.isNotEmpty(expandedContentId)) { if (WidgetContentWorker.contentWorker != null) { renderedContent = WidgetContentWorker.contentWorker.renderContentAsTextCacheExt(delegator, expandedContentId, context, null, locale, mimeTypeId); } else { Debug.logError("Not rendering content, not ContentWorker found.", module); } } if (UtilValidate.isEmpty(renderedContent)) { String editRequest = content.getEditRequest(context); if (UtilValidate.isNotEmpty(editRequest)) { if (WidgetContentWorker.contentWorker != null) { WidgetContentWorker.contentWorker.renderContentAsTextCacheExt(delegator, "NOCONTENTFOUND", writer, context, null, locale, mimeTypeId); } else { Debug.logError("Not rendering content, not ContentWorker found.", module); } } } else { if (content.xmlEscape()) { renderedContent = UtilFormatOut.encodeXmlValue(renderedContent); } writer.write(renderedContent); } } catch(GeneralException e) { String errMsg = "Error rendering included content with id [" + expandedContentId + "] : " + e.toString(); Debug.logError(e, errMsg, module); //throw new RuntimeException(errMsg); } catch(IOException e2) { String errMsg = "Error rendering included content with id [" + expandedContentId + "] : " + e2.toString(); Debug.logError(e2, errMsg, module); //throw new RuntimeException(errMsg); } } public void renderContentEnd(Writer writer, Map context, ModelScreenWidget.Content content) throws IOException { //Debug.logInfo("renderContentEnd, context:" + context, module); String expandedContentId = content.getContentId(context); String editMode = "Edit"; String editRequest = content.getEditRequest(context); String editContainerStyle = content.getEditContainerStyle(context); String enableEditName = content.getEnableEditName(context); String enableEditValue = (String)context.get(enableEditName); if (editRequest != null && editRequest.toUpperCase().indexOf("IMAGE") > 0) { editMode += " Image"; } Map params = (Map)context.get("parameters"); //String editRequestWithParams = editRequest + "?contentId=${currentValue.contentId}&drDataResourceId=${currentValue.drDataResourceId}&directEditRequest=${directEditRequest}&indirectEditRequest=${indirectEditRequest}&caContentIdTo=${currentValue.caContentIdTo}&caFromDate=${currentValue.caFromDate}&caContentAssocTypeId=${currentValue.caContentAssocTypeId}"; if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) { String contentId = content.getContentId(context); HttpServletResponse response = (HttpServletResponse) context.get("response"); HttpServletRequest request = (HttpServletRequest) context.get("request"); if (request != null && response != null) { if (editRequest.indexOf("?") < 0) editRequest += "?"; else editRequest += "&"; editRequest += "contentId=" + expandedContentId; ServletContext ctx = (ServletContext) request.getAttribute("servletContext"); RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_"); String urlString = rh.makeLink(request, response, editRequest, false, false, false); String linkString = "<a href=\"" + urlString + "\">" + editMode + "</a>"; writer.write(linkString); } if (UtilValidate.isNotEmpty(editContainerStyle)) { writer.write("</div>"); } appendWhitespace(writer); } } public void renderContentFrame(Writer writer, Map context, ModelScreenWidget.Content content) throws IOException { String dataResourceId = content.getDataResourceId(context); String urlString = "ViewSimpleContent?dataResourceId=" + dataResourceId; String width = content.getWidth(); String widthString=" width=\"" + width + "\""; String height = content.getHeight(); String heightString=" height=\"" + height + "\""; String border = content.getBorder(); String borderString = (UtilValidate.isNotEmpty(border)) ? " border=\"" + border + "\"" : ""; HttpServletRequest request = (HttpServletRequest) context.get("request"); HttpServletResponse response = (HttpServletResponse) context.get("response"); if (request != null && response != null) { ServletContext ctx = (ServletContext) request.getAttribute("servletContext"); RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_"); String fullUrlString = rh.makeLink(request, response, urlString, true, false, false); String linkString = "<iframe src=\"" + fullUrlString + "\" " + widthString + heightString + borderString + " />"; writer.write(linkString); } } public void renderSubContentBegin(Writer writer, Map context, ModelScreenWidget.SubContent content) throws IOException { String editRequest = content.getEditRequest(context); String editContainerStyle = content.getEditContainerStyle(context); String enableEditName = content.getEnableEditName(context); String enableEditValue = (String)context.get(enableEditName); if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) { writer.write("<div"); writer.write(" class=\"" + editContainerStyle + "\"> "); appendWhitespace(writer); } } public void renderSubContentBody(Writer writer, Map context, ModelScreenWidget.SubContent content) throws IOException { Locale locale = Locale.getDefault(); Boolean nullThruDatesOnly = new Boolean(false); String mimeTypeId = "text/html"; String expandedContentId = content.getContentId(context); String expandedAssocName = content.getAssocName(context); String renderedContent = null; GenericDelegator delegator = (GenericDelegator) context.get("delegator"); Timestamp fromDate = UtilDateTime.nowTimestamp(); HttpServletRequest request = (HttpServletRequest) context.get("request"); GenericValue userLogin = null; if (request != null) { HttpSession session = request.getSession(); userLogin = (GenericValue)session.getAttribute("userLogin"); } Debug.logInfo("expandedContentId:" + expandedContentId, module); try { if (WidgetContentWorker.contentWorker != null) { renderedContent = WidgetContentWorker.contentWorker.renderSubContentAsTextCacheExt(delegator, expandedContentId, expandedAssocName, null, context, locale, mimeTypeId, userLogin, fromDate); } else { Debug.logError("Not rendering content, not ContentWorker found.", module); } if (UtilValidate.isEmpty(renderedContent)) { String editRequest = content.getEditRequest(context); if (UtilValidate.isNotEmpty(editRequest)) { if (WidgetContentWorker.contentWorker != null) { WidgetContentWorker.contentWorker.renderContentAsTextCacheExt(delegator, "NOCONTENTFOUND", writer, context, null, locale, mimeTypeId); } else { Debug.logError("Not rendering content, not ContentWorker found.", module); } } } else { if (content.xmlEscape()) { renderedContent = UtilFormatOut.encodeXmlValue(renderedContent); } writer.write(renderedContent); } } catch(GeneralException e) { String errMsg = "Error rendering included content with id [" + expandedContentId + "] : " + e.toString(); Debug.logError(e, errMsg, module); //throw new RuntimeException(errMsg); } catch(IOException e2) { String errMsg = "Error rendering included content with id [" + expandedContentId + "] : " + e2.toString(); Debug.logError(e2, errMsg, module); //throw new RuntimeException(errMsg); } } public void renderSubContentEnd(Writer writer, Map context, ModelScreenWidget.SubContent content) throws IOException { String editMode = "Edit"; String editRequest = content.getEditRequest(context); String editContainerStyle = content.getEditContainerStyle(context); String enableEditName = content.getEnableEditName(context); String enableEditValue = (String)context.get(enableEditName); String expandedContentId = content.getContentId(context); String expandedAssocName = content.getAssocName(context); Map params = (Map)context.get("parameters"); if (editRequest != null && editRequest.toUpperCase().indexOf("IMAGE") > 0) { editMode += " Image"; } if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) { HttpServletResponse response = (HttpServletResponse) context.get("response"); HttpServletRequest request = (HttpServletRequest) context.get("request"); if (request != null && response != null) { if (editRequest.indexOf("?") < 0) editRequest += "?"; else editRequest += "&"; editRequest += "contentId=" + expandedContentId; if (UtilValidate.isNotEmpty(expandedAssocName)) { editRequest += "&assocName=" + expandedAssocName; } HttpSession session = request.getSession(); GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); /* don't know why this is here. might come to me later. -amb GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator"); String contentIdTo = content.getContentId(context); String mapKey = content.getAssocName(context); GenericValue view = null; try { view = ContentWorker.getSubContentCache(delegator, contentIdTo, mapKey, userLogin, null, UtilDateTime.nowTimestamp(), new Boolean(false), null); } catch(GenericEntityException e) { throw new IOException("Originally a GenericEntityException. " + e.getMessage()); } */ ServletContext ctx = (ServletContext) request.getAttribute("servletContext"); RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_"); String urlString = rh.makeLink(request, response, editRequest, false, false, false); String linkString = "<a href=\"" + urlString + "\">" + editMode + "</a>"; writer.write(linkString); } if (UtilValidate.isNotEmpty(editContainerStyle)) { writer.write("</div>"); } appendWhitespace(writer); } } public void appendWhitespace(Writer writer) throws IOException { // appending line ends for now, but this could be replaced with a simple space or something writer.write("\r\n"); //writer.write(' '); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -