You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by le...@apache.org on 2008/04/24 22:08:04 UTC
svn commit: r651376 - in /ofbiz/trunk/framework/widget: dtd/widget-form.xsd
src/org/ofbiz/widget/form/ModelFormField.java
src/org/ofbiz/widget/html/HtmlFormRenderer.java
Author: lektran
Date: Thu Apr 24 13:07:53 2008
New Revision: 651376
URL: http://svn.apache.org/viewvc?rev=651376&view=rev
Log:
Added the ability to hide the search options of the form widget's text-find widget
Modified:
ofbiz/trunk/framework/widget/dtd/widget-form.xsd
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=651376&r1=651375&r2=651376&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Thu Apr 24 13:07:53 2008
@@ -900,6 +900,16 @@
</xs:restriction>
</xs:simpleType>
</xs:attribute>
+ <xs:attribute name="hide-options" default="false">
+ <xs:simpleType>
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="true"/>
+ <xs:enumeration value="false"/>
+ <xs:enumeration value="ignore-case"/>
+ <xs:enumeration value="options"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
</xs:attributeGroup>
<!-- ================== FIELD SUB-ELEMENTS ==================== -->
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=651376&r1=651375&r2=651376&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Thu Apr 24 13:07:53 2008
@@ -2867,12 +2867,18 @@
public static class TextFindField extends TextField {
protected boolean ignoreCase = true;
+ protected boolean hideIgnoreCase = false;
protected String defaultOption = "like";
+ protected boolean hideOptions = false;
public TextFindField(Element element, ModelFormField modelFormField) {
super(element, modelFormField);
this.ignoreCase = "true".equals(element.getAttribute("ignore-case"));
+ this.hideIgnoreCase = "true".equals(element.getAttribute("hide-options")) ||
+ "ignore-case".equals(element.getAttribute("hide-options")) ? true : false;
this.defaultOption = element.getAttribute("default-option");
+ this.hideOptions = "true".equals(element.getAttribute("hide-options")) ||
+ "options".equals(element.getAttribute("hide-options")) ? true : false;
}
public TextFindField(int fieldSource, ModelFormField modelFormField) {
@@ -2885,6 +2891,14 @@
public String getDefaultOption() {
return this.defaultOption;
+ }
+
+ public boolean getHideIgnoreCase() {
+ return this.hideIgnoreCase;
+ }
+
+ public boolean getHideOptions() {
+ return this.hideOptions;
}
public void renderFieldString(StringBuffer buffer, Map context, FormStringRenderer formStringRenderer) {
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=651376&r1=651375&r2=651376&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Thu Apr 24 13:07:53 2008
@@ -1502,26 +1502,29 @@
public void renderTextFindField(StringBuffer buffer, Map context, TextFindField textFindField) {
ModelFormField modelFormField = textFindField.getModelFormField();
- Locale locale = (Locale)context.get("locale");
- String opEquals = UtilProperties.getMessage("conditional", "equals", locale);
- String opBeginsWith = UtilProperties.getMessage("conditional", "begins_with", locale);
- String opContains = UtilProperties.getMessage("conditional", "contains", locale);
- String opIsEmpty = UtilProperties.getMessage("conditional", "is_empty", locale);
- String ignoreCase = UtilProperties.getMessage("conditional", "ignore_case", locale);
- String opNotEqual = UtilProperties.getMessage("conditional", "not_equal", locale);
-
+
String defaultOption = textFindField.getDefaultOption();
- boolean ignCase = textFindField.getIgnoreCase();
-
- buffer.append(" <select name=\"");
- buffer.append(modelFormField.getParameterName(context));
- buffer.append("_op\" class=\"selectBox\">");
- buffer.append("<option value=\"equals\"" + ("equals".equals(defaultOption)? " selected": "") + ">" + opEquals + "</option>");
- buffer.append("<option value=\"like\"" + ("like".equals(defaultOption)? " selected": "") + ">" + opBeginsWith + "</option>");
- buffer.append("<option value=\"contains\"" + ("contains".equals(defaultOption)? " selected": "") + ">" + opContains + "</option>");
- buffer.append("<option value=\"empty\"" + ("empty".equals(defaultOption)? " selected": "") + ">" + opIsEmpty + "</option>");
- buffer.append("<option value=\"notEqual\"" + ("notEqual".equals(defaultOption)? " selected": "") + ">" + opNotEqual + "</option>");
- buffer.append("</select>");
+ Locale locale = (Locale)context.get("locale");
+ if (!textFindField.getHideOptions()) {
+ String opEquals = UtilProperties.getMessage("conditional", "equals", locale);
+ String opBeginsWith = UtilProperties.getMessage("conditional", "begins_with", locale);
+ String opContains = UtilProperties.getMessage("conditional", "contains", locale);
+ String opIsEmpty = UtilProperties.getMessage("conditional", "is_empty", locale);
+ String opNotEqual = UtilProperties.getMessage("conditional", "not_equal", locale);
+ buffer.append(" <select name=\"");
+ buffer.append(modelFormField.getParameterName(context));
+ buffer.append("_op\" class=\"selectBox\">");
+ buffer.append("<option value=\"equals\"" + ("equals".equals(defaultOption)? " selected": "") + ">" + opEquals + "</option>");
+ buffer.append("<option value=\"like\"" + ("like".equals(defaultOption)? " selected": "") + ">" + opBeginsWith + "</option>");
+ buffer.append("<option value=\"contains\"" + ("contains".equals(defaultOption)? " selected": "") + ">" + opContains + "</option>");
+ buffer.append("<option value=\"empty\"" + ("empty".equals(defaultOption)? " selected": "") + ">" + opIsEmpty + "</option>");
+ buffer.append("<option value=\"notEqual\"" + ("notEqual".equals(defaultOption)? " selected": "") + ">" + opNotEqual + "</option>");
+ buffer.append("</select>");
+ } else {
+ buffer.append(" <input type=\"hidden\" name=\"");
+ buffer.append(modelFormField.getParameterName(context));
+ buffer.append("_op\" value=\"" + defaultOption + "\"/>");
+ }
buffer.append("<input type=\"text\"");
@@ -1561,10 +1564,19 @@
buffer.append("\">");
}
- buffer.append(" <input type=\"checkbox\" name=\"");
- buffer.append(modelFormField.getParameterName(context));
- buffer.append("_ic\" value=\"Y\"" + (ignCase ? " checked=\"checked\"" : "") + "/>");
- buffer.append(ignoreCase);
+ String ignoreCase = UtilProperties.getMessage("conditional", "ignore_case", locale);
+ boolean ignCase = textFindField.getIgnoreCase();
+
+ if (!textFindField.getHideIgnoreCase()) {
+ buffer.append(" <input type=\"checkbox\" name=\"");
+ buffer.append(modelFormField.getParameterName(context));
+ buffer.append("_ic\" value=\"Y\"" + (ignCase ? " checked=\"checked\"" : "") + "/>");
+ buffer.append(ignoreCase);
+ } else {
+ buffer.append( "<input type=\"hidden\" name=\"");
+ buffer.append(modelFormField.getParameterName(context));
+ buffer.append("_ic\" value=\"" + (ignCase ? "Y" : "") + "\"/>");
+ }
if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
buffer.append("</span>");