Skip to content
Snippets Groups Projects
Commit 40f2c4b5 authored by srosse's avatar srosse
Browse files

OO-144: make possible to check only the visible length of string without...

OO-144: make possible to check only the visible length of string without subtle encoding issues (which are only databse relevant)
parent 3e88a651
No related branches found
No related tags found
No related merge requests found
...@@ -145,4 +145,11 @@ public interface TextElement extends FormItem{ ...@@ -145,4 +145,11 @@ public interface TextElement extends FormItem{
*/ */
public void setMaxLength(int maxLength); public void setMaxLength(int maxLength);
/**
* Check the visible length of the text (can be used for datas saved in XML file
* but not for DB)
* @param checkVisibleLength
*/
public void setCheckVisibleLength(boolean checkVisibleLength);
} }
\ No newline at end of file
...@@ -75,6 +75,7 @@ public abstract class AbstractTextElement extends FormItemImpl implements TextEl ...@@ -75,6 +75,7 @@ public abstract class AbstractTextElement extends FormItemImpl implements TextEl
private int notLongerLength; private int notLongerLength;
protected int displaySize; protected int displaySize;
protected int maxlength = -1; //default no maxlength restriction protected int maxlength = -1; //default no maxlength restriction
protected boolean checkVisibleLength = false;
private String notLongerThanErrorKey; private String notLongerThanErrorKey;
private String checkForOtherValue; private String checkForOtherValue;
private String otherValueErrorKey; private String otherValueErrorKey;
...@@ -204,7 +205,10 @@ public abstract class AbstractTextElement extends FormItemImpl implements TextEl ...@@ -204,7 +205,10 @@ public abstract class AbstractTextElement extends FormItemImpl implements TextEl
this.maxlength = maxLength; this.maxlength = maxLength;
} }
public void setCheckVisibleLength(boolean checkVisibleLength) {
this.checkVisibleLength = checkVisibleLength;
}
/** /**
* @param errorKey * @param errorKey
* @return * @return
...@@ -245,7 +249,11 @@ public abstract class AbstractTextElement extends FormItemImpl implements TextEl ...@@ -245,7 +249,11 @@ public abstract class AbstractTextElement extends FormItemImpl implements TextEl
private boolean notLongerThan(){ private boolean notLongerThan(){
boolean lengthError = false; boolean lengthError = false;
try { try {
if (value.length() > notLongerLength || value.getBytes("UTF-8").length > notLongerLength) { if(checkVisibleLength) {
if (value.length() > notLongerLength) {
lengthError = true;
}
} else if (value.length() > notLongerLength || value.getBytes("UTF-8").length > notLongerLength) {
lengthError = true; lengthError = true;
} }
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
......
...@@ -145,6 +145,7 @@ public class NodeConfigFormController extends FormBasicController { ...@@ -145,6 +145,7 @@ public class NodeConfigFormController extends FormBasicController {
// add the short title text input element // add the short title text input element
shortTitle = uifactory.addTextElement("nodeConfigForm.menutitle", "nodeConfigForm.menutitle", SHORT_TITLE_MAX_LENGTH, (menuTitle == null ? "": menuTitle), formLayout); shortTitle = uifactory.addTextElement("nodeConfigForm.menutitle", "nodeConfigForm.menutitle", SHORT_TITLE_MAX_LENGTH, (menuTitle == null ? "": menuTitle), formLayout);
shortTitle.setMandatory(true); shortTitle.setMandatory(true);
shortTitle.setCheckVisibleLength(true);
// add the title input text element // add the title input text element
title = uifactory.addTextElement("nodeConfigForm.displaytitle", "nodeConfigForm.displaytitle", 255, (displayTitle==null? "": displayTitle), formLayout); title = uifactory.addTextElement("nodeConfigForm.displaytitle", "nodeConfigForm.displaytitle", 255, (displayTitle==null? "": displayTitle), formLayout);
......
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