Skip to content
Snippets Groups Projects
Commit 937c1439 authored by srosse's avatar srosse
Browse files

OO-1483: concat instead of StringBuilder, optimize label text renderer, don't...

OO-1483: concat instead of StringBuilder, optimize label text renderer, don't check number generated id to secure it in javascript varaibles
parent ba22c6f5
No related branches found
No related tags found
No related merge requests found
...@@ -52,8 +52,8 @@ public abstract class AbstractComponent implements Component { ...@@ -52,8 +52,8 @@ public abstract class AbstractComponent implements Component {
private boolean spanReplaceable = false; private boolean spanReplaceable = false;
private String name; private final String name;
private String dispatchID; private final String dispatchID;
private String elementCssClass; private String elementCssClass;
private long timestamp = 1l; private long timestamp = 1l;
...@@ -118,13 +118,11 @@ public abstract class AbstractComponent implements Component { ...@@ -118,13 +118,11 @@ public abstract class AbstractComponent implements Component {
dispatchID = Long.toString(CodeHelper.getRAMUniqueID()); dispatchID = Long.toString(CodeHelper.getRAMUniqueID());
staticCmp = false; staticCmp = false;
} else { } else {
dispatchID = id; // OO-98: dispatchID will get used in generated js-code. thus, make sure it
// is valid as variable name.
dispatchID = secureJSVarName(id);
staticCmp = true; staticCmp = true;
} }
// OO-98: dispatchID will get used in generated js-code. thus, make sure it
// is valid as variable name.
dispatchID = secureJSVarName(dispatchID);
this.name = name; this.name = name;
this.translator = translator; this.translator = translator;
......
...@@ -79,20 +79,19 @@ public class SimpleLabelText extends FormBaseComponentImpl { ...@@ -79,20 +79,19 @@ public class SimpleLabelText extends FormBaseComponentImpl {
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator,
RenderResult renderResult, String[] args) { RenderResult renderResult, String[] args) {
SimpleLabelText stc = (SimpleLabelText) source; SimpleLabelText stc = (SimpleLabelText) source;
String css = "control-label "; sb.append("<label class='control-label ");
String target = null; String target = null;
if (args != null && args.length > 0) { if (args != null && args.length > 0) {
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
String arg = args[i]; String arg = args[i];
if (arg.startsWith("col-")) { if (arg.startsWith("col-")) {
css += arg; sb.append(arg);
} else { } else {
target = arg; target = arg;
} }
} }
} }
sb.append("' id='o_c").append(source.getDispatchID()).append("'");
sb.append("<label class='").append(css).append("' id='o_c").append(source.getDispatchID()).append("'");
// add the reference to form element for which this label stands. this is important for screen readers // add the reference to form element for which this label stands. this is important for screen readers
if (target != null) { if (target != null) {
sb.append(" for=\""); sb.append(" for=\"");
......
...@@ -362,7 +362,7 @@ public class MultipleSelectionElementImpl extends FormItemImpl implements Multip ...@@ -362,7 +362,7 @@ public class MultipleSelectionElementImpl extends FormItemImpl implements Multip
*/ */
@Override @Override
public String getFormDispatchId() { public String getFormDispatchId() {
return DISPPREFIX + getComponent().getDispatchID(); return DISPPREFIX.concat(getComponent().getDispatchID());
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment