use of org.apache.ofbiz.webapp.control.RequestHandler in project ofbiz-framework by apache.
the class MacroScreenRenderer method renderContainerBegin.
public void renderContainerBegin(Appendable writer, Map<String, Object> context, ModelScreenWidget.Container container) throws IOException {
String containerId = container.getId(context);
String autoUpdateTarget = container.getAutoUpdateTargetExdr(context);
HttpServletRequest request = (HttpServletRequest) context.get("request");
String autoUpdateLink = "";
if (UtilValidate.isNotEmpty(autoUpdateTarget) && UtilHttp.isJavaScriptEnabled(request)) {
if (UtilValidate.isEmpty(containerId)) {
containerId = getNextElementId();
}
HttpServletResponse response = (HttpServletResponse) context.get("response");
ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
autoUpdateLink = rh.makeLink(request, response, autoUpdateTarget);
}
Map<String, Object> parameters = new HashMap<>();
parameters.put("id", containerId);
parameters.put("style", container.getStyle(context));
parameters.put("autoUpdateLink", autoUpdateLink);
parameters.put("autoUpdateInterval", container.getAutoUpdateInterval(context));
executeMacro(writer, "renderContainerBegin", parameters);
}
use of org.apache.ofbiz.webapp.control.RequestHandler in project ofbiz-framework by apache.
the class MacroScreenRenderer method renderContentFrame.
public void renderContentFrame(Appendable writer, Map<String, Object> context, ModelScreenWidget.Content content) throws IOException {
String dataResourceId = content.getDataResourceId(context);
String urlString = "/ViewSimpleContent?dataResourceId=" + dataResourceId;
String fullUrlString = "";
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_");
fullUrlString = rh.makeLink(request, response, urlString, true, false, false);
}
Map<String, Object> parameters = new HashMap<>();
parameters.put("fullUrl", fullUrlString);
parameters.put("width", content.getWidth());
parameters.put("height", content.getHeight());
parameters.put("border", content.getBorder());
executeMacro(writer, "renderContentFrame", parameters);
}
use of org.apache.ofbiz.webapp.control.RequestHandler in project ofbiz-framework by apache.
the class MacroScreenRenderer method renderContentEnd.
public void renderContentEnd(Appendable writer, Map<String, Object> context, ModelScreenWidget.Content content) throws IOException {
String expandedContentId = content.getContentId(context);
String editMode = "Edit";
String editRequest = content.getEditRequest(context);
String enableEditName = content.getEnableEditName(context);
String enableEditValue = (String) context.get(enableEditName);
String urlString = "";
if (editRequest != null && editRequest.toUpperCase(Locale.getDefault()).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;
ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
urlString = rh.makeLink(request, response, editRequest, false, false, false);
}
Map<String, Object> parameters = new HashMap<>();
parameters.put("urlString", urlString);
parameters.put("editMode", editMode);
parameters.put("editContainerStyle", content.getEditContainerStyle(context));
parameters.put("editRequest", editRequest);
parameters.put("enableEditValue", enableEditValue);
executeMacro(writer, "renderContentEnd", parameters);
}
}
use of org.apache.ofbiz.webapp.control.RequestHandler in project ofbiz-framework by apache.
the class MacroScreenRenderer method renderImage.
public void renderImage(Appendable writer, Map<String, Object> context, ModelScreenWidget.ScreenImage image) throws IOException {
if (image == null) {
return;
}
String src = image.getSrc(context);
String urlMode = image.getUrlMode();
boolean fullPath = false;
boolean secure = false;
boolean encode = false;
HttpServletResponse response = (HttpServletResponse) context.get("response");
HttpServletRequest request = (HttpServletRequest) context.get("request");
String urlString = "";
if (urlMode != null && "intra-app".equalsIgnoreCase(urlMode)) {
if (request != null && response != null) {
ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
urlString = rh.makeLink(request, response, src, fullPath, secure, encode);
} else {
urlString = src;
}
} else if (urlMode != null && "content".equalsIgnoreCase(urlMode)) {
if (request != null && response != null) {
StringBuilder newURL = new StringBuilder();
ContentUrlTag.appendContentPrefix(request, newURL);
newURL.append(src);
urlString = newURL.toString();
}
} else {
urlString = src;
}
Map<String, Object> parameters = new HashMap<>();
parameters.put("src", src);
parameters.put("id", image.getId(context));
parameters.put("style", image.getStyle(context));
parameters.put("wid", image.getWidth(context));
parameters.put("hgt", image.getHeight(context));
parameters.put("border", image.getBorder(context));
parameters.put("alt", image.getAlt(context));
parameters.put("urlString", urlString);
executeMacro(writer, "renderImage", parameters);
}
use of org.apache.ofbiz.webapp.control.RequestHandler in project ofbiz-framework by apache.
the class MacroScreenRenderer method renderSubContentEnd.
public void renderSubContentEnd(Appendable writer, Map<String, Object> context, ModelScreenWidget.SubContent content) throws IOException {
String editMode = "Edit";
String editRequest = content.getEditRequest(context);
String enableEditName = content.getEnableEditName(context);
String enableEditValue = (String) context.get(enableEditName);
String expandedContentId = content.getContentId(context);
String expandedMapKey = content.getMapKey(context);
String urlString = "";
if (editRequest != null && !(editRequest.toUpperCase(Locale.getDefault()).indexOf("IMAGE") < 1)) {
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(expandedMapKey)) {
editRequest += "&mapKey=" + expandedMapKey;
}
ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
urlString = rh.makeLink(request, response, editRequest, false, false, false);
}
}
Map<String, Object> parameters = new HashMap<>();
parameters.put("urlString", urlString);
parameters.put("editMode", editMode);
parameters.put("editContainerStyle", content.getEditContainerStyle(context));
parameters.put("editRequest", editRequest);
parameters.put("enableEditValue", enableEditValue == null ? "" : enableEditValue);
executeMacro(writer, "renderSubContentEnd", parameters);
}
Aggregations