diff --git a/framework/example/widget/example/ExampleForms.xml b/framework/example/widget/example/ExampleForms.xml
index f2b188ce57..f4d345f17b 100644
--- a/framework/example/widget/example/ExampleForms.xml
+++ b/framework/example/widget/example/ExampleForms.xml
@@ -52,6 +52,8 @@ under the License.
+
+
diff --git a/framework/images/webapp/images/maincss.css b/framework/images/webapp/images/maincss.css
index 49abd07e79..854444fc62 100644
--- a/framework/images/webapp/images/maincss.css
+++ b/framework/images/webapp/images/maincss.css
@@ -1451,6 +1451,26 @@ background: #FFFCCF;
background: #FFF55F;
}
+.basic-table .Validate {
+/*Style use by alt-row-style on list*/
+background: #A0D5F7;
+}
+
+.basic-table .alternate-rowValidate {
+/*Style use by alt-row-style on list*/
+background: #72A8F2;
+}
+
+.basic-table .Warn {
+/*Style use by alt-row-style on list*/
+background: #f55C5C;
+}
+
+.basic-table .alternate-rowWarn {
+/*Style use by alt-row-style on list*/
+background: #FC7455;
+}
+
.basic-table tr .button-col {
/* button column style - for the small
collection of buttons used in lists */
diff --git a/framework/widget/dtd/widget-form.xsd b/framework/widget/dtd/widget-form.xsd
index 636c03c31f..e6dfea2278 100644
--- a/framework/widget/dtd/widget-form.xsd
+++ b/framework/widget/dtd/widget-form.xsd
@@ -32,6 +32,7 @@ under the License.
+
@@ -234,6 +235,20 @@ under the License.
+
+ Active a style on a line if the use-when condition is validate
+
+
+
+
+
+
+ Boolean expression tested for active the style on a line.
+
+
+ If use-when return true, concat this style to existing style of the line.
+
+
diff --git a/framework/widget/src/org/ofbiz/widget/form/ModelForm.java b/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
index d8b1fd7220..01f1e7281d 100644
--- a/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
+++ b/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
@@ -132,6 +132,7 @@ public class ModelForm extends ModelWidget {
protected List autoFieldsServices = FastList.newInstance();
protected List autoFieldsEntities = FastList.newInstance();
protected List sortOrderFields = FastList.newInstance();
+ protected List altRowStyles = FastList.newInstance();
/** This List will contain one copy of each field for each field name in the order
* they were encountered in the service, entity, or form definition; field definitions
@@ -291,6 +292,7 @@ public class ModelForm extends ModelWidget {
this.defaultViewSize = parent.defaultViewSize;
this.onSubmitUpdateAreas = parent.onSubmitUpdateAreas;
this.onPaginateUpdateAreas = parent.onPaginateUpdateAreas;
+ this.altRowStyles = parent.altRowStyles;
//these are done below in a special way...
//this.fieldList = parent.fieldList;
@@ -459,6 +461,12 @@ public class ModelForm extends ModelWidget {
this.rowCountExdr = FlexibleStringExpander.getInstance(formElement.getAttribute("row-count"));
}
+ //alt-row-styles
+ for (Element altRowStyleElement : UtilXml.childElementList(formElement, "alt-row-style")){
+ AltRowStyle altRowStyle = new AltRowStyle(altRowStyleElement);
+ this.altRowStyles.add(altRowStyle);
+ }
+
// alt-target
List altTargetElements = UtilXml.childElementList(formElement, "alt-target");
Iterator altTargetElementIter = altTargetElements.iterator();
@@ -2556,6 +2564,46 @@ public class ModelForm extends ModelWidget {
public List getOnSubmitUpdateAreas() {
return this.onSubmitUpdateAreas;
}
+
+ public static class AltRowStyle {
+ public String useWhen;
+ public String style;
+ public AltRowStyle(Element altRowStyleElement) {
+ this.useWhen = altRowStyleElement.getAttribute("use-when");
+ this.style = altRowStyleElement.getAttribute("style");
+ }
+ }
+
+ /**
+ * iterate through alt-row-styles list to see if should be used, then add style
+ * @return The style for item row
+ */
+ public String getStyleAltRowStyle(Map context) {
+ String styles = "";
+ try {
+ // use the same Interpreter (ie with the same context setup) for all evals
+ Interpreter bsh = this.getBshInterpreter(context);
+ for (AltRowStyle altRowStyle : this.altRowStyles) {
+ Object retVal = bsh.eval(altRowStyle.useWhen);
+ // retVal should be a Boolean, if not something weird is up...
+ if (retVal instanceof Boolean) {
+ Boolean boolVal = (Boolean) retVal;
+ if (boolVal.booleanValue()) {
+ styles += altRowStyle.style;
+ }
+ } else {
+ throw new IllegalArgumentException(
+ "Return value from style condition eval was not a Boolean: " + retVal.getClass().getName() + " [" + retVal + "] of form " + this.name);
+ }
+ }
+ } catch (EvalError e) {
+ String errmsg = "Error evaluating BeanShell style conditions on form " + this.name;
+ Debug.logError(e, errmsg, module);
+ throw new IllegalArgumentException(errmsg);
+ }
+
+ return styles;
+ }
public static class AltTarget {
public String useWhen;
diff --git a/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java b/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
index 199e48eb3d..f6381d6d0d 100644
--- a/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
+++ b/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
@@ -1532,20 +1532,39 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append(" ");