use of org.olat.core.gui.control.winmgr.AJAXFlags in project OpenOLAT by OpenOLAT.
the class MenuTreeRenderer method render.
/**
* @see org.olat.core.gui.render.ui.ComponentRenderer#render(org.olat.core.gui.render.Renderer,
* org.olat.core.gui.render.StringOutput, org.olat.core.gui.components.Component,
* org.olat.core.gui.render.URLBuilder, org.olat.core.gui.translator.Translator,
* org.olat.core.gui.render.RenderResult, java.lang.String[])
*/
@Override
public void render(Renderer renderer, StringOutput target, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
MenuTree tree = (MenuTree) source;
if (tree.getMenuTreeItem() != null) {
tree.getMenuTreeItem().clearVisibleNodes();
}
TreeNode root = tree.getTreeModel().getRootNode();
// tree is completely empty
if (root == null)
return;
INode selNode = tree.getSelectedNode();
Collection<String> openNodeIds = tree.getOpenNodeIds();
List<INode> selPath = new ArrayList<>(5);
INode cur = selNode;
if (cur == null && !tree.isUnselectNodes()) {
cur = root;
} else if (cur == null && tree.isUnselectNodes() && openNodeIds.isEmpty()) {
// always open the root
openNodeIds.add(root.getIdent());
}
// selected nodeid of the root node
while (cur != null) {
selPath.add(0, cur);
cur = cur.getParent();
}
List<DndElement> elements = new ArrayList<>();
AJAXFlags flags = renderer.getGlobalSettings().getAjaxFlags();
target.append("\n<div class='o_tree");
// marker classes to differentiate rendering when root node is visible
if (!tree.isRootVisible()) {
target.append(" o_tree_root_hidden");
} else {
target.append(" o_tree_root_visible");
}
if (tree.isInsertToolEnabled()) {
target.append(" o_tree_insert_tool");
}
// add element CSS
if (StringHelper.containsNonWhitespace(tree.getElementCssClass())) {
target.append(" ").append(tree.getElementCssClass());
}
target.append("'><ul class=\"o_tree_l0\">");
if (tree.isRootVisible()) {
renderLevel(renderer, target, 0, root, selPath, openNodeIds, elements, ubu, flags, tree);
} else {
selPath.remove(0);
int chdCnt = root.getChildCount();
for (int i = 0; i < chdCnt; i++) {
TreeNode curChd = (TreeNode) root.getChildAt(i);
renderLevel(renderer, target, 0, curChd, selPath, openNodeIds, elements, ubu, flags, tree);
}
}
target.append("</ul>");
appendDragAndDropScript(elements, tree, target).append("</div>");
}
use of org.olat.core.gui.control.winmgr.AJAXFlags in project OpenOLAT by OpenOLAT.
the class FormWrapperContainerRenderer method render.
/**
* @see org.olat.core.gui.components.ComponentRenderer#render(org.olat.core.gui.render.Renderer,
* org.olat.core.gui.render.StringOutput,
* org.olat.core.gui.components.Component,
* org.olat.core.gui.render.URLBuilder,
* org.olat.core.gui.translator.Translator,
* org.olat.core.gui.render.RenderResult, java.lang.String[])
*/
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
FormWrapperContainer formC = (FormWrapperContainer) source;
ComponentCollection toRender = formC.getFormLayout();
/*
* extract check for render instruction to the form wrapper
*/
boolean hasRenderInstr = (args != null && args.length > 0);
if (toRender != null) {
AJAXFlags flags = renderer.getGlobalSettings().getAjaxFlags();
boolean iframePostEnabled = flags.isIframePostEnabled();
/*
* FORM HEADER
*/
sb.append("<form ");
if (hasRenderInstr) {
// append render instructions if available
// flexi form supports only class
FormJSHelper.appendRenderInstructions(sb, args[0], acceptedInstructions);
}
sb.append(" method=\"post\"");
// transfer and parameter extracing overhead
if (formC.isMultipartEnabled()) {
sb.append(" enctype=\"multipart/form-data\"");
}
sb.append(" id=\"");
sb.append(formC.getFormName());
sb.append("\" name=\"");
sb.append(formC.getFormName());
sb.append("\" action=\"");
ubu.buildURI(sb, new String[] { Form.FORMID }, new String[] { Form.FORMCMD }, iframePostEnabled ? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL);
sb.append("\" ");
// check if ready to accept a new request
if (iframePostEnabled) {
sb.append(" onsubmit=\"return o_XHRSubmit('").append(formC.getFormName()).append("');\" ");
} else {
sb.append(" onsubmit=\"if(o_info.linkbusy) return false; else o_beforeserver(); return true;\" ");
}
sb.append(">");
// hidden input field for dispatch uri
sb.append("<input type=\"hidden\" id=\"").append(formC.getDispatchFieldId()).append("\" name=\"dispatchuri\" value=\"").append(Form.FORM_UNDEFINED).append("\" />").append("<input type=\"hidden\" id=\"").append(formC.getEventFieldId()).append("\" name=\"dispatchevent\" value=\"").append(Form.FORM_UNDEFINED).append("\" />");
/*
* FORM CONTAINER
*/
renderer.render(sb, toRender, args);
/*
* FORM FOOTER
*/
sb.append("</form>");
/*
* FORM SUBMIT on keypress enter
*/
sb.append(FormJSHelper.submitOnKeypressEnter(formC.getFormName()));
}
}
use of org.olat.core.gui.control.winmgr.AJAXFlags in project openolat by klemens.
the class FormWrapperContainerRenderer method render.
/**
* @see org.olat.core.gui.components.ComponentRenderer#render(org.olat.core.gui.render.Renderer,
* org.olat.core.gui.render.StringOutput,
* org.olat.core.gui.components.Component,
* org.olat.core.gui.render.URLBuilder,
* org.olat.core.gui.translator.Translator,
* org.olat.core.gui.render.RenderResult, java.lang.String[])
*/
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
FormWrapperContainer formC = (FormWrapperContainer) source;
ComponentCollection toRender = formC.getFormLayout();
/*
* extract check for render instruction to the form wrapper
*/
boolean hasRenderInstr = (args != null && args.length > 0);
if (toRender != null) {
AJAXFlags flags = renderer.getGlobalSettings().getAjaxFlags();
boolean iframePostEnabled = flags.isIframePostEnabled();
/*
* FORM HEADER
*/
sb.append("<form ");
if (hasRenderInstr) {
// append render instructions if available
// flexi form supports only class
FormJSHelper.appendRenderInstructions(sb, args[0], acceptedInstructions);
}
sb.append(" method=\"post\"");
// transfer and parameter extracing overhead
if (formC.isMultipartEnabled()) {
sb.append(" enctype=\"multipart/form-data\"");
}
sb.append(" id=\"");
sb.append(formC.getFormName());
sb.append("\" name=\"");
sb.append(formC.getFormName());
sb.append("\" action=\"");
ubu.buildURI(sb, new String[] { Form.FORMID }, new String[] { Form.FORMCMD }, iframePostEnabled ? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL);
sb.append("\" ");
// check if ready to accept a new request
if (iframePostEnabled) {
sb.append(" onsubmit=\"return o_XHRSubmit('").append(formC.getFormName()).append("');\" ");
} else {
sb.append(" onsubmit=\"if(o_info.linkbusy) return false; else o_beforeserver(); return true;\" ");
}
sb.append(">");
// hidden input field for dispatch uri
sb.append("<input type=\"hidden\" id=\"").append(formC.getDispatchFieldId()).append("\" name=\"dispatchuri\" value=\"").append(Form.FORM_UNDEFINED).append("\" />").append("<input type=\"hidden\" id=\"").append(formC.getEventFieldId()).append("\" name=\"dispatchevent\" value=\"").append(Form.FORM_UNDEFINED).append("\" />");
/*
* FORM CONTAINER
*/
renderer.render(sb, toRender, args);
/*
* FORM FOOTER
*/
sb.append("</form>");
/*
* FORM SUBMIT on keypress enter
*/
sb.append(FormJSHelper.submitOnKeypressEnter(formC.getFormName()));
}
}
Aggregations