OFBIZ-240 - Render a selectAll checkbox for forms of type multi. To activate it, define a field named _rowSubmit of type <check/> and give it a title.

git-svn-id: https://svn.apache.org/repos/asf/incubator/ofbiz/trunk@449813 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Si Chen
2006-09-25 20:59:02 +00:00
parent 9c52fba771
commit 38db2ed389
2 changed files with 18 additions and 1 deletions
@@ -1062,6 +1062,16 @@ public class ModelFormField {
}
}
/**
* Checks if field is a row submit field.
*/
public boolean isRowSubmit() {
if (!"multi".equals(getModelForm().getType())) return false;
if (getFieldInfo().getFieldType() != ModelFormField.FieldInfo.CHECK) return false;
if (!CheckField.ROW_SUBMIT_FIELD_NAME.equals(getName())) return false;
return true;
}
/**
* @return
*/
@@ -2557,6 +2567,8 @@ public class ModelFormField {
}
public static class CheckField extends FieldInfo {
public final static String ROW_SUBMIT_FIELD_NAME = "_rowSubmit";
protected CheckField() {
super();
}
@@ -2190,7 +2190,7 @@ public class HtmlFormRenderer implements FormStringRenderer {
/**
* Renders a link for the column header fields when there is a header-link="" specified in the <field > tag, using
* style from header-link-style=""
* style from header-link-style="". Also renders a selectAll checkbox in multi forms.
* @param buffer
* @param context
* @param modelFormField
@@ -2207,6 +2207,11 @@ public class HtmlFormRenderer implements FormStringRenderer {
targetType="plain";
}
makeHyperlinkString(buffer, modelFormField.getHeaderLinkStyle(), targetType, targetBuffer.toString(), titleText, null);
} else if (modelFormField.isRowSubmit()) {
if (UtilValidate.isNotEmpty(titleText)) buffer.append(titleText).append("<br>");
buffer.append("<input type=\"checkbox\" name=\"selectAll\" value=\"Y\" onclick=\"javascript:toggleAll(this, '");
buffer.append(modelFormField.getModelForm().getName());
buffer.append("');\"/>");
} else {
buffer.append(titleText);
}