📄 layoutevents.java
字号:
serviceIn.put("contentIdTo", newId);
serviceIn.put("fromDate", UtilDateTime.nowTimestamp());
serviceIn.put("thruDate", null);
try {
results = dispatcher.runSync("persistContentAndAssoc", serviceIn);
} catch(GenericServiceException e) {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
return "error";
}
beenThere.put(contentIdFrom, view);
}
}
GenericValue view = delegator.makeValue("ContentDataResourceView", null);
view.set("contentId", newId);
view.set("drDataResourceId", newDataResourceId);
Debug.logVerbose("in cloneLayout, view:" + view, "");
ContentManagementWorker.setCurrentEntityMap(request, view);
request.setAttribute("contentId", view.get("contentId"));
request.setAttribute("drDataResourceId", view.get("drDataResourceId"));
return "success";
}
public static String createLayoutSubContent(HttpServletRequest request, HttpServletResponse response) {
try {
LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");
HttpSession session = request.getSession();
Map paramMap = UtilHttp.getParameterMap(request);
String contentIdTo = (String)paramMap.get("contentIdTo");
String mapKey = (String)paramMap.get("mapKey");
if (Debug.verboseOn()) {
Debug.logVerbose("in createSubContent, contentIdTo:" + contentIdTo, module);
Debug.logVerbose("in createSubContent, mapKey:" + mapKey, module);
}
Map context = new HashMap();
List errorMessages = null;
Locale loc = (Locale)request.getSession().getServletContext().getAttribute("locale");
if (loc == null)
loc = Locale.getDefault();
GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");
context.put("userLogin", userLogin);
String rootDir = request.getSession().getServletContext().getRealPath("/");
context.put("rootDir", rootDir);
try {
SimpleMapProcessor.runSimpleMapProcessor(
"org/ofbiz/content/ContentManagementMapProcessors.xml", "contentIn",
paramMap, context, errorMessages, loc);
SimpleMapProcessor.runSimpleMapProcessor(
"org/ofbiz/content/ContentManagementMapProcessors.xml", "dataResourceIn",
paramMap, context, errorMessages, loc);
SimpleMapProcessor.runSimpleMapProcessor(
"org/ofbiz/content/ContentManagementMapProcessors.xml", "contentAssocIn",
paramMap, context, errorMessages, loc);
} catch(MiniLangException e) {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
return "error";
}
context.put("dataResourceName", context.get("contentName"));
String contentPurposeTypeId = (String)paramMap.get("contentPurposeTypeId");
if (UtilValidate.isNotEmpty(contentPurposeTypeId))
context.put("contentPurposeList", UtilMisc.toList(contentPurposeTypeId));
context.put("contentIdTo", paramMap.get("contentIdTo"));
context.put("mapKey", paramMap.get("mapKey"));
context.put("textData", paramMap.get("textData"));
context.put("contentAssocTypeId", "SUB_CONTENT");
if (Debug.verboseOn()) Debug.logVerbose("in createSubContent, context:" + context, module);
Map result = dispatcher.runSync("persistContentAndAssoc", context);
boolean isError = ModelService.RESPOND_ERROR.equals(result.get(ModelService.RESPONSE_MESSAGE));
if (isError) {
request.setAttribute("_ERROR_MESSAGE_", result.get(ModelService.ERROR_MESSAGE));
return "error";
}
if (Debug.verboseOn()) Debug.logVerbose("in createLayoutFile, result:" + result, module);
String contentId = (String)result.get("contentId");
String dataResourceId = (String)result.get("dataResourceId");
request.setAttribute("contentId", contentId);
request.setAttribute("drDataResourceId", dataResourceId);
request.setAttribute("currentEntityName", "SubContentDataResourceId");
Map context2 = new HashMap();
context2.put("activeContentId", contentId);
//context2.put("dataResourceId", dataResourceId);
context2.put("contentAssocTypeId", "SUB_CONTENT");
context2.put("fromDate", result.get("fromDate"));
context2.put("contentIdTo", contentIdTo);
context2.put("mapKey", mapKey);
//Debug.logVerbose("in replaceSubContent, context2:" + context2, module);
Map result2 = dispatcher.runSync("deactivateAssocs", context2);
} catch( GenericServiceException e) {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
return "error";
}
return "success";
}
public static String updateLayoutSubContent(HttpServletRequest request, HttpServletResponse response) {
try {
LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");
HttpSession session = request.getSession();
Map paramMap = UtilHttp.getParameterMap(request);
String contentIdTo = (String)paramMap.get("contentIdTo");
String mapKey = (String)paramMap.get("mapKey");
Map context = new HashMap();
List errorMessages = null;
Locale loc = (Locale)request.getSession().getServletContext().getAttribute("locale");
if (loc == null)
loc = Locale.getDefault();
context.put("locale", loc);
GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");
context.put("userLogin", userLogin);
String rootDir = request.getSession().getServletContext().getRealPath("/");
context.put("rootDir", rootDir);
try {
SimpleMapProcessor.runSimpleMapProcessor(
"org/ofbiz/content/ContentManagementMapProcessors.xml", "contentIn",
paramMap, context, errorMessages, loc);
SimpleMapProcessor.runSimpleMapProcessor(
"org/ofbiz/content/ContentManagementMapProcessors.xml", "dataResourceIn",
paramMap, context, errorMessages, loc);
SimpleMapProcessor.runSimpleMapProcessor(
"org/ofbiz/content/ContentManagementMapProcessors.xml", "contentAssocIn",
paramMap, context, errorMessages, loc);
} catch(MiniLangException e) {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
return "error";
}
context.put("dataResourceName", context.get("contentName"));
String contentPurposeTypeId = (String)paramMap.get("contentPurposeTypeId");
if (UtilValidate.isNotEmpty(contentPurposeTypeId))
context.put("contentPurposeList", UtilMisc.toList(contentPurposeTypeId));
context.put("contentIdTo", paramMap.get("contentIdTo"));
context.put("textData", paramMap.get("textData"));
context.put("contentAssocTypeId", null);
Map result = dispatcher.runSync("persistContentAndAssoc", context);
boolean isError = ModelService.RESPOND_ERROR.equals(result.get(ModelService.RESPONSE_MESSAGE));
if (isError) {
request.setAttribute("_ERROR_MESSAGE_", result.get(ModelService.ERROR_MESSAGE));
return "error";
}
String contentId = (String)result.get("contentId");
String dataResourceId = (String)result.get("dataResourceId");
request.setAttribute("contentId", contentId);
request.setAttribute("drDataResourceId", dataResourceId);
request.setAttribute("currentEntityName", "SubContentDataResourceId");
/*
Map context2 = new HashMap();
context2.put("activeContentId", contentId);
//context2.put("dataResourceId", dataResourceId);
context2.put("contentAssocTypeId", "SUB_CONTENT");
context2.put("fromDate", result.get("fromDate"));
context2.put("contentIdTo", contentIdTo);
context2.put("mapKey", mapKey);
//Debug.logVerbose("in replaceSubContent, context2:" + context2, module);
Map result2 = dispatcher.runSync("deactivateAssocs", context2);
*/
} catch( GenericServiceException e) {
request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
return "error";
}
return "success";
}
public static String copyToClip(HttpServletRequest request, HttpServletResponse response) {
GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator");
Map paramMap = UtilHttp.getParameterMap(request);
String entityName = (String)paramMap.get("entityName");
if (UtilValidate.isEmpty(entityName) ) {
request.setAttribute("_ERROR_MESSAGE_", "'entityName' is empty.");
return "error";
}
GenericValue v = delegator.makeValue(entityName, null);
GenericPK passedPK = v.getPrimaryKey();
Collection keyColl = passedPK.getAllKeys();
Iterator keyIt = keyColl.iterator();
while (keyIt.hasNext()) {
String attrName = (String)keyIt.next();
String attrVal = (String)request.getAttribute(attrName);
if (attrVal == null) {
attrVal = (String)paramMap.get(attrName);
}
Debug.logVerbose("in copyToClip, attrName:" + attrName,"");
Debug.logVerbose("in copyToClip, attrVal:" + attrVal,"");
if (UtilValidate.isNotEmpty(attrVal)) {
passedPK.put(attrName,attrVal);
} else {
request.setAttribute("_ERROR_MESSAGE_", attrName + " is empty.");
return "error";
}
}
ContentManagementWorker.mruAdd(request, passedPK);
return "success";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -