use of org.apache.ofbiz.widget.renderer.MenuStringRenderer in project ofbiz-framework by apache.
the class MacroScreenViewHandler method loadRenderers.
private ScreenStringRenderer loadRenderers(HttpServletRequest request, HttpServletResponse response, Map<String, Object> context, Writer writer) throws TemplateException, IOException {
VisualTheme visualTheme = UtilHttp.getVisualTheme(request);
ModelTheme modelTheme = visualTheme.getModelTheme();
String screenMacroLibraryPath = modelTheme.getScreenRendererLocation(getName());
String formMacroLibraryPath = modelTheme.getFormRendererLocation(getName());
String treeMacroLibraryPath = modelTheme.getTreeRendererLocation(getName());
String menuMacroLibraryPath = modelTheme.getMenuRendererLocation(getName());
ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(modelTheme.getType(getName()), screenMacroLibraryPath);
if (UtilValidate.isNotEmpty(formMacroLibraryPath)) {
FormStringRenderer formStringRenderer = new MacroFormRenderer(formMacroLibraryPath, request, response);
context.put("formStringRenderer", formStringRenderer);
}
if (UtilValidate.isNotEmpty(treeMacroLibraryPath)) {
TreeStringRenderer treeStringRenderer = new MacroTreeRenderer(treeMacroLibraryPath, writer);
context.put("treeStringRenderer", treeStringRenderer);
}
if (UtilValidate.isNotEmpty(menuMacroLibraryPath)) {
MenuStringRenderer menuStringRenderer = new MacroMenuRenderer(menuMacroLibraryPath, request, response);
context.put("menuStringRenderer", menuStringRenderer);
}
return screenStringRenderer;
}
use of org.apache.ofbiz.widget.renderer.MenuStringRenderer in project ofbiz-framework by apache.
the class MacroScreenRenderer method renderScreenletBegin.
public void renderScreenletBegin(Appendable writer, Map<String, Object> context, boolean collapsed, ModelScreenWidget.Screenlet screenlet) throws IOException {
HttpServletRequest request = (HttpServletRequest) context.get("request");
HttpServletResponse response = (HttpServletResponse) context.get("response");
VisualTheme visualTheme = UtilHttp.getVisualTheme(request);
ModelTheme modelTheme = visualTheme.getModelTheme();
boolean javaScriptEnabled = UtilHttp.isJavaScriptEnabled(request);
ModelScreenWidget.Menu tabMenu = screenlet.getTabMenu();
if (tabMenu != null) {
tabMenu.renderWidgetString(writer, context, this);
}
String title = screenlet.getTitle(context);
boolean collapsible = screenlet.collapsible();
ModelScreenWidget.Menu navMenu = screenlet.getNavigationMenu();
ModelScreenWidget.Form navForm = screenlet.getNavigationForm();
String expandToolTip = "";
String collapseToolTip = "";
String fullUrlString = "";
String menuString = "";
boolean showMore = false;
if (UtilValidate.isNotEmpty(title) || navMenu != null || navForm != null || collapsible) {
showMore = true;
if (collapsible) {
this.getNextElementId();
Map<String, Object> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap"));
Map<String, Object> paramMap = UtilGenerics.checkMap(context.get("requestParameters"));
Map<String, Object> requestParameters = new HashMap<>(paramMap);
if (uiLabelMap != null) {
expandToolTip = (String) uiLabelMap.get("CommonExpand");
collapseToolTip = (String) uiLabelMap.get("CommonCollapse");
}
if (!javaScriptEnabled) {
requestParameters.put(screenlet.getPreferenceKey(context) + "_collapsed", collapsed ? "false" : "true");
String queryString = UtilHttp.urlEncodeArgs(requestParameters);
fullUrlString = request.getRequestURI() + "?" + queryString;
}
}
StringWriter sb = new StringWriter();
if (navMenu != null) {
MenuStringRenderer savedRenderer = (MenuStringRenderer) context.get("menuStringRenderer");
MenuStringRenderer renderer;
try {
renderer = new MacroMenuRenderer(modelTheme.getMenuRendererLocation("screen"), request, response);
context.put("menuStringRenderer", renderer);
navMenu.renderWidgetString(sb, context, this);
context.put("menuStringRenderer", savedRenderer);
} catch (TemplateException e) {
Debug.logError(e, module);
}
} else if (navForm != null) {
renderScreenletPaginateMenu(sb, context, navForm);
}
menuString = sb.toString();
}
Map<String, Object> parameters = new HashMap<>();
parameters.put("title", title);
parameters.put("collapsible", collapsible);
parameters.put("saveCollapsed", screenlet.saveCollapsed());
if (UtilValidate.isNotEmpty(screenlet.getId(context))) {
parameters.put("id", screenlet.getId(context));
parameters.put("collapsibleAreaId", screenlet.getId(context) + "_col");
} else {
parameters.put("id", "screenlet_" + screenLetsIdCounter);
parameters.put("collapsibleAreaId", "screenlet_" + screenLetsIdCounter + "_col");
screenLetsIdCounter++;
}
parameters.put("expandToolTip", expandToolTip);
parameters.put("collapseToolTip", collapseToolTip);
parameters.put("fullUrlString", fullUrlString);
parameters.put("padded", screenlet.padded());
parameters.put("menuString", menuString);
parameters.put("showMore", showMore);
parameters.put("collapsed", collapsed);
parameters.put("javaScriptEnabled", javaScriptEnabled);
executeMacro(writer, "renderScreenletBegin", parameters);
}
Aggregations