David,
Do you have any idea why this might have broken all the multi-forms? Si Author: jonesde Date: Thu Mar 8 23:03:06 2007 New Revision: 516317 URL: http://svn.apache.org/viewvc?view=rev&rev=516317 Log: Made check type field more useful with the options thingy underneath it; this may/will break old usage, if it ever was used... 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?view=diff&rev=516317&r1=516316&r2=516317 ============================================================================== --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Thu Mar 8 23:03:06 2007 @@ -409,8 +409,25 @@ </xs:attributeGroup> <!-- ================== FIELD TYPES ==================== --> <xs:element name="check" substitutionGroup="AllFields"> - <xs:complexType/> + <xs:complexType> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element ref="entity-options"/> + <xs:element ref="list-options"/> + <xs:element ref="option"/> + </xs:choice> + <xs:attributeGroup ref="attlist.check"/> + </xs:complexType> </xs:element> + <xs:attributeGroup name="attlist.check"> + <xs:attribute name="all-checked"> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="true"/> + <xs:enumeration value="false"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + </xs:attributeGroup> <xs:element name="date-find" substitutionGroup="AllFields"> <xs:complexType> <xs:attributeGroup ref="attlist.date-find"/> 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?view=diff&rev=516317&r1=516316&r2=516317 ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Thu Mar 8 23:03:06 2007 @@ -2571,8 +2571,9 @@ } } - public static class CheckField extends FieldInfo { + public static class CheckField extends FieldInfoWithOptions { public final static String ROW_SUBMIT_FIELD_NAME = "_rowSubmit"; + protected FlexibleStringExpander allChecked = null; protected CheckField() { super(); @@ -2588,10 +2589,20 @@ public CheckField(Element element, ModelFormField modelFormField) { super(element, modelFormField); + allChecked = new FlexibleStringExpander(element.getAttribute("all-checked")); } public void renderFieldString(StringBuffer buffer, Map context, FormStringRenderer formStringRenderer) { formStringRenderer.renderCheckField(buffer, context, this); + } + + public Boolean isAllChecked(Map context) { + String allCheckedStr = this.allChecked.expandString(context); + if (UtilValidate.isNotEmpty(allCheckedStr)) { + return new Boolean("true".equals(allCheckedStr)); + } else { + return null; + } } } 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?view=diff&rev=516317&r1=516316&r2=516317 ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Thu Mar 8 23:03:06 2007 @@ -684,25 +684,54 @@ * @see org.ofbiz.widget.form.FormStringRenderer#renderCheckField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.CheckField) */ public void renderCheckField(StringBuffer buffer, Map context, CheckField checkField) { - // well, I don't know if this will be very useful... but here it is - ModelFormField modelFormField = checkField.getModelFormField(); - // never used: ModelForm modelForm = modelFormField.getModelForm(); + ModelForm modelForm = modelFormField.getModelForm(); String currentValue = modelFormField.getEntry(context); + Boolean allChecked = checkField.isAllChecked(context); - buffer.append("<input type=\"checkbox\""); + List allOptionValues = checkField.getAllOptionValues(context, modelForm.getDelegator()); + String event = modelFormField.getEvent(); + String action = modelFormField.getAction(context); + + // list out all options according to the option list + Iterator optionValueIter = allOptionValues.iterator(); + while (optionValueIter.hasNext()) { + ModelFormField.OptionValue optionValue = (ModelFormField.OptionValue) optionValueIter.next(); + + buffer.append("<div"); + + appendClassNames(buffer, context, modelFormField); + + buffer.append("><input type=\"checkbox\""); + + // if current value should be selected in the list, select it + if (Boolean.TRUE.equals(allChecked)) { + buffer.append(" checked=\"checked\""); + } else if (Boolean.FALSE.equals(allChecked)) { + // do nothing + } else if (UtilValidate.isNotEmpty(currentValue) && currentValue.equals(optionValue.getKey())) { + buffer.append(" checked=\"checked\""); + } + buffer.append(" name=\""); + buffer.append(modelFormField.getParameterName(context)); + buffer.append('"'); + buffer.append(" value=\""); + buffer.append(optionValue.getKey()); + buffer.append("\""); - appendClassNames(buffer, context, modelFormField); + if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) { + buffer.append(" "); + buffer.append(event); + buffer.append("=\""); + buffer.append(action); + buffer.append('"'); + } + + buffer.append("/>"); - // if current value should be selected in the list, select it - if ("Y".equals(currentValue) || "T".equals(currentValue)) { - buffer.append(" checked=\"checked\""); + buffer.append(optionValue.getDescription()); + buffer.append("</div>"); } - buffer.append(" name=\""); - buffer.append(modelFormField.getParameterName(context)); - buffer.append('"'); - buffer.append(" value=\"Y\"/>"); - // any description by it? this.appendTooltip(buffer, context, modelFormField); |
I don't see any reason why it might have... did it break the multi- forms? -David On Mar 14, 2007, at 11:46 AM, Si Chen wrote: > David, > > Do you have any idea why this might have broken all the multi-forms? > > Si > > From: [hidden email] > Date: March 9, 2007 12:03:06 AM MST > To: [hidden email] > Subject: svn commit: r516317 - in /ofbiz/trunk/framework/widget: > dtd/widget-form.xsd src/org/ofbiz/widget/form/ModelFormField.java > src/org/ofbiz/widget/html/HtmlFormRenderer.java > Reply-To: [hidden email] > > > Author: jonesde > Date: Thu Mar 8 23:03:06 2007 > New Revision: 516317 > > URL: http://svn.apache.org/viewvc?view=rev&rev=516317 > Log: > Made check type field more useful with the options thingy > underneath it; this may/will break old usage, if it ever was used... > > 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?view=diff&rev=516317&r1=516316&r2=516317 > ====================================================================== > ======== > --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) > +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Thu Mar 8 > 23:03:06 2007 > @@ -409,8 +409,25 @@ > </xs:attributeGroup> > <!-- ================== FIELD TYPES ==================== --> > <xs:element name="check" substitutionGroup="AllFields"> > - <xs:complexType/> > + <xs:complexType> > + <xs:choice minOccurs="0" maxOccurs="unbounded"> > + <xs:element ref="entity-options"/> > + <xs:element ref="list-options"/> > + <xs:element ref="option"/> > + </xs:choice> > + <xs:attributeGroup ref="attlist.check"/> > + </xs:complexType> > </xs:element> > + <xs:attributeGroup name="attlist.check"> > + <xs:attribute name="all-checked"> > + <xs:simpleType> > + <xs:restriction base="xs:token"> > + <xs:enumeration value="true"/> > + <xs:enumeration value="false"/> > + </xs:restriction> > + </xs:simpleType> > + </xs:attribute> > + </xs:attributeGroup> > <xs:element name="date-find" substitutionGroup="AllFields"> > <xs:complexType> > <xs:attributeGroup ref="attlist.date-find"/> > > 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? > view=diff&rev=516317&r1=516316&r2=516317 > ====================================================================== > ======== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ > ModelFormField.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ > ModelFormField.java Thu Mar 8 23:03:06 2007 > @@ -2571,8 +2571,9 @@ > } > } > > - public static class CheckField extends FieldInfo { > + public static class CheckField extends FieldInfoWithOptions { > public final static String ROW_SUBMIT_FIELD_NAME = > "_rowSubmit"; > + protected FlexibleStringExpander allChecked = null; > > protected CheckField() { > super(); > @@ -2588,10 +2589,20 @@ > > public CheckField(Element element, ModelFormField > modelFormField) { > super(element, modelFormField); > + allChecked = new FlexibleStringExpander > (element.getAttribute("all-checked")); > } > > public void renderFieldString(StringBuffer buffer, Map > context, FormStringRenderer formStringRenderer) { > formStringRenderer.renderCheckField(buffer, context, > this); > + } > + > + public Boolean isAllChecked(Map context) { > + String allCheckedStr = this.allChecked.expandString > (context); > + if (UtilValidate.isNotEmpty(allCheckedStr)) { > + return new Boolean("true".equals(allCheckedStr)); > + } else { > + return null; > + } > } > } > > > 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? > view=diff&rev=516317&r1=516316&r2=516317 > ====================================================================== > ======== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ > HtmlFormRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ > HtmlFormRenderer.java Thu Mar 8 23:03:06 2007 > @@ -684,25 +684,54 @@ > * @see > org.ofbiz.widget.form.FormStringRenderer#renderCheckField > (java.lang.StringBuffer, java.util.Map, > org.ofbiz.widget.form.ModelFormField.CheckField) > */ > public void renderCheckField(StringBuffer buffer, Map context, > CheckField checkField) { > - // well, I don't know if this will be very useful... but > here it is > - > ModelFormField modelFormField = > checkField.getModelFormField(); > - // never used: ModelForm modelForm = > modelFormField.getModelForm(); > + ModelForm modelForm = modelFormField.getModelForm(); > String currentValue = modelFormField.getEntry(context); > + Boolean allChecked = checkField.isAllChecked(context); > > - buffer.append("<input type=\"checkbox\""); > + List allOptionValues = checkField.getAllOptionValues > (context, modelForm.getDelegator()); > + String event = modelFormField.getEvent(); > + String action = modelFormField.getAction(context); > + > + // list out all options according to the option list > + Iterator optionValueIter = allOptionValues.iterator(); > + while (optionValueIter.hasNext()) { > + ModelFormField.OptionValue optionValue = > (ModelFormField.OptionValue) optionValueIter.next(); > + > + buffer.append("<div"); > + > + appendClassNames(buffer, context, modelFormField); > + > + buffer.append("><input type=\"checkbox\""); > + > + // if current value should be selected in the list, > select it > + if (Boolean.TRUE.equals(allChecked)) { > + buffer.append(" checked=\"checked\""); > + } else if (Boolean.FALSE.equals(allChecked)) { > + // do nothing > + } else if (UtilValidate.isNotEmpty(currentValue) && > currentValue.equals(optionValue.getKey())) { > + buffer.append(" checked=\"checked\""); > + } > + buffer.append(" name=\""); > + buffer.append(modelFormField.getParameterName(context)); > + buffer.append('"'); > + buffer.append(" value=\""); > + buffer.append(optionValue.getKey()); > + buffer.append("\""); > > - appendClassNames(buffer, context, modelFormField); > + if (UtilValidate.isNotEmpty(event) && > UtilValidate.isNotEmpty(action)) { > + buffer.append(" "); > + buffer.append(event); > + buffer.append("=\""); > + buffer.append(action); > + buffer.append('"'); > + } > + > + buffer.append("/>"); > > - // if current value should be selected in the list, select it > - if ("Y".equals(currentValue) || "T".equals(currentValue)) { > - buffer.append(" checked=\"checked\""); > + buffer.append(optionValue.getDescription()); > + buffer.append("</div>"); > } > - buffer.append(" name=\""); > - buffer.append(modelFormField.getParameterName(context)); > - buffer.append('"'); > - buffer.append(" value=\"Y\"/>"); > - // any description by it? > > this.appendTooltip(buffer, context, modelFormField); > > > > > smime.p7s (3K) Download Attachment |
David,
it seems that the checkboxes, necessary to select each row in the multi form list, disappeared. Should we change the form definition in some ways or is there something that we can fix in the framework? Jacopo David E. Jones wrote: > > I don't see any reason why it might have... did it break the multi-forms? > > -David > > |
In reply to this post by David E Jones
David E. Jones wrote:
> > I don't see any reason why it might have... did it break the multi-forms? > > -David Have you seen http://issues.apache.org/jira/browse/OFBIZ-812? Adrian thought it might be that commit. After reverting it the checkboxes do reappear, though the select all at the top is still broken. Si |
The renderCheckField in HtmlFormRenderer is now pulling in a list of option
values from CheckField.getOptionValues, but whatever code creates the _rowSubmit modelFormField (I couldn't find it last night) isn't doing this so nothing is being added to the buffer. You can have a look by adding a breakpoint to renderCheckField. Hope that makes some sense! Regards Scott On 15/03/07, Si Chen <[hidden email]> wrote: > > David E. Jones wrote: > > > > I don't see any reason why it might have... did it break the > multi-forms? > > > > -David > Have you seen http://issues.apache.org/jira/browse/OFBIZ-812? > > Adrian thought it might be that commit. After reverting it the > checkboxes do reappear, though the select all at the top is still broken. > > Si > |
Free forum by Nabble | Edit this page |