Administrator
|
Hi Mridul,
Did you notice we have a compilation issue with this commit? https://ci.apache.org/builders/ofbiz-trunk https://ci.apache.org/builders/ofbiz-trunk/builds/1607/steps/shell/logs/stdio Thanks Jacques Le 15/10/2016 à 15:19, [hidden email] a écrit : > Author: mridulpathak > Date: Sat Oct 15 13:19:35 2016 > New Revision: 1765058 > > URL: http://svn.apache.org/viewvc?rev=1765058&view=rev > Log: > Improved: In form widgets of list type empty header row should not render if list to render in file is empty. > (OFBIZ-7598) > > Thanks: Suraj Khurana for contribution. > > Modified: > ofbiz/trunk/framework/widget/dtd/widget-form.xsd > ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java > ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java > ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java > ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java > ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl > > Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=1765058&r1=1765057&r2=1765058&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) > +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Sat Oct 15 13:19:35 2016 > @@ -86,6 +86,7 @@ under the License. > <xs:attribute name="style" type="xs:string" /> > <xs:attribute name="focus-field-name" type="xs:string" /> > <xs:attribute name="title" type="xs:string" /> > + <xs:attribute name="empty-form-data-message" type="xs:string" /> > <xs:attribute name="tooltip" type="xs:string" /> > <xs:attribute name="list-name" type="xs:string"> > <xs:annotation> > @@ -327,6 +328,7 @@ under the License. > <xs:attribute name="style" type="xs:string" /> > <xs:attribute name="focus-field-name" type="xs:string" /> > <xs:attribute name="title" type="xs:string" /> > + <xs:attribute name="empty-form-data-message" type="xs:string" /> > <xs:attribute name="tooltip" type="xs:string" /> > <xs:attribute name="list-name" type="xs:string"> > <xs:annotation> > > Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java?rev=1765058&r1=1765057&r2=1765058&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java (original) > +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java Sat Oct 15 13:19:35 2016 > @@ -147,7 +147,7 @@ public abstract class ModelForm extends > private final String formWidgetAreaStyle; > private final boolean groupColumns; > private final String headerRowStyle; > - private final boolean hideHeader; > + private boolean hideHeader; > private final String itemIndexSeparator; > private final List<String> lastOrderFields; > private final String listEntryName; > @@ -184,6 +184,7 @@ public abstract class ModelForm extends > private final String targetType; > private final FlexibleStringExpander targetWindowExdr; > private final String title; > + private final String emptyFormDataMessage; > private final String tooltip; > private final String type; > private final boolean useRowSubmit; > @@ -241,6 +242,13 @@ public abstract class ModelForm extends > title = parentModel.title; > } > this.title = title; > + String emptyFormDataMessage = formElement.getAttribute("empty-form-data-message"); > + if (emptyFormDataMessage.isEmpty() && parentModel != null) { > + emptyFormDataMessage = parentModel.emptyFormDataMessage; > + } else if (emptyFormDataMessage.isEmpty()) { > + emptyFormDataMessage = "No records found"; > + } > + this.emptyFormDataMessage = emptyFormDataMessage; > String tooltip = formElement.getAttribute("tooltip"); > if (tooltip.isEmpty() && parentModel != null) { > tooltip = parentModel.tooltip; > @@ -1015,6 +1023,10 @@ public abstract class ModelForm extends > public boolean getHideHeader() { > return this.hideHeader; > } > + public boolean setHideHeader(Boolean hideHeader) { > + this.hideHeader = hideHeader; > + return hideHeader; > + } > > public String getItemIndexSeparator() { > if (UtilValidate.isNotEmpty(this.itemIndexSeparator)) { > @@ -1384,6 +1396,10 @@ public abstract class ModelForm extends > return this.title; > } > > + public String getEmptyFormDataMessage() { > + return this.emptyFormDataMessage; > + } > + > public String getTooltip() { > return this.tooltip; > } > > Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java Sat Oct 15 13:19:35 2016 > @@ -48,6 +48,7 @@ import org.apache.ofbiz.widget.model.*; > import org.apache.ofbiz.widget.model.ModelForm.FieldGroup; > import org.apache.ofbiz.widget.model.ModelForm.FieldGroupBase; > import org.apache.ofbiz.widget.model.ModelFormField; > +import org.apache.ofbiz.widget.model.ModelFormField.DisplayField; > > /** > * A form rendering engine. > @@ -925,9 +926,12 @@ public class FormRenderer { > formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); > > int numOfColumns = 0; > + this.checkFormDataAndSetHeader(context); > // ===== render header row ===== > if (!modelForm.getHideHeader()) { > numOfColumns = this.renderHeaderRow(writer, context); > + } else { > + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); > } > > // ===== render the item rows ===== > @@ -951,9 +955,12 @@ public class FormRenderer { > formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); > > int numOfColumns = 0; > + this.checkFormDataAndSetHeader(context); > // ===== render header row ===== > if (!modelForm.getHideHeader()) { > numOfColumns = this.renderHeaderRow(writer, context); > + } else { > + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); > } > > // ===== render the item rows ===== > @@ -967,6 +974,32 @@ public class FormRenderer { > > } > > + private void checkFormDataAndSetHeader(Map<String, Object> context) { > + String lookupName = modelForm.getListName(); > + Object obj = context.get(lookupName); > + if (obj == null) { > + if (Debug.verboseOn()) > + Debug.logVerbose("No object for list or iterator name [" + lookupName + "] found, so not rendering rows.", module); > + return; > + } > + // if list is empty, do not render rows > + Iterator<?> iter = null; > + if (obj instanceof Iterator<?>) { > + iter = (Iterator<?>) obj; > + } else if (obj instanceof List<?>) { > + iter = ((List<?>) obj).listIterator(); > + } > + int itemIndex = -1; > + Object item = null; > + while ((item = safeNext(iter)) != null) { > + itemIndex++; > + break; > + } > + if (itemIndex < 0) { > + modelForm.setHideHeader(true); > + } > + } > + > private void renderSingleFormString(Appendable writer, Map<String, Object> context, > int positions) throws IOException { > List<ModelFormField> tempFieldList = new LinkedList<ModelFormField>(); > > Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java Sat Oct 15 13:19:35 2016 > @@ -99,4 +99,5 @@ public interface FormStringRenderer { > public void renderContainerFindField(Appendable writer, Map<String, Object> context, ModelFormField.ContainerField containerField) throws IOException; > public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; > public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; > + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; > } > > Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java Sat Oct 15 13:19:35 2016 > @@ -1538,7 +1538,16 @@ public final class MacroFormRenderer imp > renderEndingBoundaryComment(writer, "Grid Widget - Grid Element", modelForm); > } > } > - > + > + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { > + StringWriter sr = new StringWriter(); > + sr.append("<@renderEmptyFormDataMessage"); > + sr.append(" message=\""); > + sr.append(modelForm.getEmptyFormDataMessage()); > + sr.append("\" />"); > + executeMacro(writer, sr.toString()); > + } > + > public void renderFormatHeaderOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { > StringWriter sr = new StringWriter(); > sr.append("<@renderFormatHeaderOpen "); > > Modified: ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl?rev=1765058&r1=1765057&r2=1765058&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl (original) > +++ ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl Sat Oct 15 13:19:35 2016 > @@ -326,6 +326,10 @@ under the License. > </label><#t/> > </#macro> > > +<#macro renderEmptyFormDataMessage message> > + <h3><#if message?has_content>${message}</#if></h3> > +</#macro> > + > <#macro renderSingleFormFieldTitle></#macro> > > <#macro renderFormOpen linkUrl formType targetWindow containerId containerStyle autocomplete name viewIndexField viewSizeField viewIndex viewSize useRowSubmit> > > > |
Hi Jacques,
I have fixed the compilation error at r1765080. Thanks for reporting. -- Thanks & Regards --- Arun Patidar Manager,Enterprise Software Development HotWax Mediawww.hotwaxsystems.com On Sat, Oct 15, 2016 at 7:55 PM, Jacques Le Roux < [hidden email]> wrote: > Hi Mridul, > > Did you notice we have a compilation issue with this commit? > > https://ci.apache.org/builders/ofbiz-trunk > > https://ci.apache.org/builders/ofbiz-trunk/builds/1607/ > steps/shell/logs/stdio > > Thanks > > Jacques > > > > Le 15/10/2016 à 15:19, [hidden email] a écrit : > >> Author: mridulpathak >> Date: Sat Oct 15 13:19:35 2016 >> New Revision: 1765058 >> >> URL: http://svn.apache.org/viewvc?rev=1765058&view=rev >> Log: >> Improved: In form widgets of list type empty header row should not render >> if list to render in file is empty. >> (OFBIZ-7598) >> >> Thanks: Suraj Khurana for contribution. >> >> Modified: >> ofbiz/trunk/framework/widget/dtd/widget-form.xsd >> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz >> /widget/model/ModelForm.java >> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz >> /widget/renderer/FormRenderer.java >> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz >> /widget/renderer/FormStringRenderer.java >> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz >> /widget/renderer/macro/MacroFormRenderer.java >> ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl >> >> Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd >> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dt >> d/widget-form.xsd?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================ >> ================== >> --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) >> +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Sat Oct 15 13:19:35 >> 2016 >> @@ -86,6 +86,7 @@ under the License. >> <xs:attribute name="style" type="xs:string" /> >> <xs:attribute name="focus-field-name" type="xs:string" /> >> <xs:attribute name="title" type="xs:string" /> >> + <xs:attribute name="empty-form-data-message" >> type="xs:string" /> >> <xs:attribute name="tooltip" type="xs:string" /> >> <xs:attribute name="list-name" type="xs:string"> >> <xs:annotation> >> @@ -327,6 +328,7 @@ under the License. >> <xs:attribute name="style" type="xs:string" /> >> <xs:attribute name="focus-field-name" type="xs:string" /> >> <xs:attribute name="title" type="xs:string" /> >> + <xs:attribute name="empty-form-data-message" >> type="xs:string" /> >> <xs:attribute name="tooltip" type="xs:string" /> >> <xs:attribute name="list-name" type="xs:string"> >> <xs:annotation> >> >> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/ >> widget/model/ModelForm.java >> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/sr >> c/main/java/org/apache/ofbiz/widget/model/ModelForm.java? >> rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================ >> ================== >> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java >> (original) >> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java >> Sat Oct 15 13:19:35 2016 >> @@ -147,7 +147,7 @@ public abstract class ModelForm extends >> private final String formWidgetAreaStyle; >> private final boolean groupColumns; >> private final String headerRowStyle; >> - private final boolean hideHeader; >> + private boolean hideHeader; >> private final String itemIndexSeparator; >> private final List<String> lastOrderFields; >> private final String listEntryName; >> @@ -184,6 +184,7 @@ public abstract class ModelForm extends >> private final String targetType; >> private final FlexibleStringExpander targetWindowExdr; >> private final String title; >> + private final String emptyFormDataMessage; >> private final String tooltip; >> private final String type; >> private final boolean useRowSubmit; >> @@ -241,6 +242,13 @@ public abstract class ModelForm extends >> title = parentModel.title; >> } >> this.title = title; >> + String emptyFormDataMessage = formElement.getAttribute("empt >> y-form-data-message"); >> + if (emptyFormDataMessage.isEmpty() && parentModel != null) { >> + emptyFormDataMessage = parentModel.emptyFormDataMessage; >> + } else if (emptyFormDataMessage.isEmpty()) { >> + emptyFormDataMessage = "No records found"; >> + } >> + this.emptyFormDataMessage = emptyFormDataMessage; >> String tooltip = formElement.getAttribute("tooltip"); >> if (tooltip.isEmpty() && parentModel != null) { >> tooltip = parentModel.tooltip; >> @@ -1015,6 +1023,10 @@ public abstract class ModelForm extends >> public boolean getHideHeader() { >> return this.hideHeader; >> } >> + public boolean setHideHeader(Boolean hideHeader) { >> + this.hideHeader = hideHeader; >> + return hideHeader; >> + } >> public String getItemIndexSeparator() { >> if (UtilValidate.isNotEmpty(this.itemIndexSeparator)) { >> @@ -1384,6 +1396,10 @@ public abstract class ModelForm extends >> return this.title; >> } >> + public String getEmptyFormDataMessage() { >> + return this.emptyFormDataMessage; >> + } >> + >> public String getTooltip() { >> return this.tooltip; >> } >> >> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/ >> widget/renderer/FormRenderer.java >> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/sr >> c/main/java/org/apache/ofbiz/widget/renderer/FormRenderer. >> java?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================ >> ================== >> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/ >> widget/renderer/FormRenderer.java (original) >> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/ >> widget/renderer/FormRenderer.java Sat Oct 15 13:19:35 2016 >> @@ -48,6 +48,7 @@ import org.apache.ofbiz.widget.model.*; >> import org.apache.ofbiz.widget.model.ModelForm.FieldGroup; >> import org.apache.ofbiz.widget.model.ModelForm.FieldGroupBase; >> import org.apache.ofbiz.widget.model.ModelFormField; >> +import org.apache.ofbiz.widget.model.ModelFormField.DisplayField; >> /** >> * A form rendering engine. >> @@ -925,9 +926,12 @@ public class FormRenderer { >> formStringRenderer.renderFormatListWrapperOpen(writer, >> context, modelForm); >> int numOfColumns = 0; >> + this.checkFormDataAndSetHeader(context); >> // ===== render header row ===== >> if (!modelForm.getHideHeader()) { >> numOfColumns = this.renderHeaderRow(writer, context); >> + } else { >> + formStringRenderer.renderEmptyFormDataMessage(writer, >> context, modelForm); >> } >> // ===== render the item rows ===== >> @@ -951,9 +955,12 @@ public class FormRenderer { >> formStringRenderer.renderFormatListWrapperOpen(writer, >> context, modelForm); >> int numOfColumns = 0; >> + this.checkFormDataAndSetHeader(context); >> // ===== render header row ===== >> if (!modelForm.getHideHeader()) { >> numOfColumns = this.renderHeaderRow(writer, context); >> + } else { >> + formStringRenderer.renderEmptyFormDataMessage(writer, >> context, modelForm); >> } >> // ===== render the item rows ===== >> @@ -967,6 +974,32 @@ public class FormRenderer { >> } >> + private void checkFormDataAndSetHeader(Map<String, Object> >> context) { >> + String lookupName = modelForm.getListName(); >> + Object obj = context.get(lookupName); >> + if (obj == null) { >> + if (Debug.verboseOn()) >> + Debug.logVerbose("No object for list or iterator name [" >> + lookupName + "] found, so not rendering rows.", module); >> + return; >> + } >> + // if list is empty, do not render rows >> + Iterator<?> iter = null; >> + if (obj instanceof Iterator<?>) { >> + iter = (Iterator<?>) obj; >> + } else if (obj instanceof List<?>) { >> + iter = ((List<?>) obj).listIterator(); >> + } >> + int itemIndex = -1; >> + Object item = null; >> + while ((item = safeNext(iter)) != null) { >> + itemIndex++; >> + break; >> + } >> + if (itemIndex < 0) { >> + modelForm.setHideHeader(true); >> + } >> + } >> + >> private void renderSingleFormString(Appendable writer, Map<String, >> Object> context, >> int positions) throws IOException { >> List<ModelFormField> tempFieldList = new >> LinkedList<ModelFormField>(); >> >> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/ >> widget/renderer/FormStringRenderer.java >> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/sr >> c/main/java/org/apache/ofbiz/widget/renderer/FormStringRend >> erer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================ >> ================== >> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/ >> widget/renderer/FormStringRenderer.java (original) >> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/ >> widget/renderer/FormStringRenderer.java Sat Oct 15 13:19:35 2016 >> @@ -99,4 +99,5 @@ public interface FormStringRenderer { >> public void renderContainerFindField(Appendable writer, >> Map<String, Object> context, ModelFormField.ContainerField containerField) >> throws IOException; >> public void renderFieldGroupOpen(Appendable writer, Map<String, >> Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; >> public void renderFieldGroupClose(Appendable writer, Map<String, >> Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; >> + public void renderEmptyFormDataMessage(Appendable writer, >> Map<String, Object> context, ModelForm modelForm) throws IOException; >> } >> >> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/ >> widget/renderer/macro/MacroFormRenderer.java >> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/sr >> c/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFor >> mRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================ >> ================== >> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/ >> widget/renderer/macro/MacroFormRenderer.java (original) >> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/ >> widget/renderer/macro/MacroFormRenderer.java Sat Oct 15 13:19:35 2016 >> @@ -1538,7 +1538,16 @@ public final class MacroFormRenderer imp >> renderEndingBoundaryComment(writer, "Grid Widget - Grid >> Element", modelForm); >> } >> } >> - >> + >> + public void renderEmptyFormDataMessage(Appendable writer, >> Map<String, Object> context, ModelForm modelForm) throws IOException { >> + StringWriter sr = new StringWriter(); >> + sr.append("<@renderEmptyFormDataMessage"); >> + sr.append(" message=\""); >> + sr.append(modelForm.getEmptyFormDataMessage()); >> + sr.append("\" />"); >> + executeMacro(writer, sr.toString()); >> + } >> + >> public void renderFormatHeaderOpen(Appendable writer, Map<String, >> Object> context, ModelForm modelForm) throws IOException { >> StringWriter sr = new StringWriter(); >> sr.append("<@renderFormatHeaderOpen "); >> >> Modified: ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl >> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/te >> mplates/HtmlFormMacroLibrary.ftl?rev=1765058&r1=1765057&r2= >> 1765058&view=diff >> ============================================================ >> ================== >> --- ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl >> (original) >> +++ ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl Sat >> Oct 15 13:19:35 2016 >> @@ -326,6 +326,10 @@ under the License. >> </label><#t/> >> </#macro> >> +<#macro renderEmptyFormDataMessage message> >> + <h3><#if message?has_content>${message}</#if></h3> >> +</#macro> >> + >> <#macro renderSingleFormFieldTitle></#macro> >> <#macro renderFormOpen linkUrl formType targetWindow containerId >> containerStyle autocomplete name viewIndexField viewSizeField viewIndex >> viewSize useRowSubmit> >> >> >> >> > |
Administrator
|
Thanks Arun
Jacques Le 15/10/2016 à 16:53, Arun Patidar a écrit : > Hi Jacques, > > I have fixed the compilation error at r1765080. Thanks for reporting. > |
Administrator
|
In reply to this post by Jacques Le Roux
Hi Mridul,
After Arun fixed a compilation issue at r1765080, I found that this introduced a regression. Please see https://issues.apache.org/jira/browse/OFBIZ-8505 I think it's better to revert and test this more. Thanks Jacques Le 15/10/2016 à 16:25, Jacques Le Roux a écrit : > Hi Mridul, > > Did you notice we have a compilation issue with this commit? > > https://ci.apache.org/builders/ofbiz-trunk > > https://ci.apache.org/builders/ofbiz-trunk/builds/1607/steps/shell/logs/stdio > > Thanks > > Jacques > > > Le 15/10/2016 à 15:19, [hidden email] a écrit : >> Author: mridulpathak >> Date: Sat Oct 15 13:19:35 2016 >> New Revision: 1765058 >> >> URL: http://svn.apache.org/viewvc?rev=1765058&view=rev >> Log: >> Improved: In form widgets of list type empty header row should not render if list to render in file is empty. >> (OFBIZ-7598) >> >> Thanks: Suraj Khurana for contribution. >> >> Modified: >> ofbiz/trunk/framework/widget/dtd/widget-form.xsd >> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java >> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java >> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java >> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java >> ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl >> >> Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd >> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================================== >> --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) >> +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Sat Oct 15 13:19:35 2016 >> @@ -86,6 +86,7 @@ under the License. >> <xs:attribute name="style" type="xs:string" /> >> <xs:attribute name="focus-field-name" type="xs:string" /> >> <xs:attribute name="title" type="xs:string" /> >> + <xs:attribute name="empty-form-data-message" type="xs:string" /> >> <xs:attribute name="tooltip" type="xs:string" /> >> <xs:attribute name="list-name" type="xs:string"> >> <xs:annotation> >> @@ -327,6 +328,7 @@ under the License. >> <xs:attribute name="style" type="xs:string" /> >> <xs:attribute name="focus-field-name" type="xs:string" /> >> <xs:attribute name="title" type="xs:string" /> >> + <xs:attribute name="empty-form-data-message" type="xs:string" /> >> <xs:attribute name="tooltip" type="xs:string" /> >> <xs:attribute name="list-name" type="xs:string"> >> <xs:annotation> >> >> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================================== >> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java (original) >> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java Sat Oct 15 13:19:35 2016 >> @@ -147,7 +147,7 @@ public abstract class ModelForm extends >> private final String formWidgetAreaStyle; >> private final boolean groupColumns; >> private final String headerRowStyle; >> - private final boolean hideHeader; >> + private boolean hideHeader; >> private final String itemIndexSeparator; >> private final List<String> lastOrderFields; >> private final String listEntryName; >> @@ -184,6 +184,7 @@ public abstract class ModelForm extends >> private final String targetType; >> private final FlexibleStringExpander targetWindowExdr; >> private final String title; >> + private final String emptyFormDataMessage; >> private final String tooltip; >> private final String type; >> private final boolean useRowSubmit; >> @@ -241,6 +242,13 @@ public abstract class ModelForm extends >> title = parentModel.title; >> } >> this.title = title; >> + String emptyFormDataMessage = formElement.getAttribute("empty-form-data-message"); >> + if (emptyFormDataMessage.isEmpty() && parentModel != null) { >> + emptyFormDataMessage = parentModel.emptyFormDataMessage; >> + } else if (emptyFormDataMessage.isEmpty()) { >> + emptyFormDataMessage = "No records found"; >> + } >> + this.emptyFormDataMessage = emptyFormDataMessage; >> String tooltip = formElement.getAttribute("tooltip"); >> if (tooltip.isEmpty() && parentModel != null) { >> tooltip = parentModel.tooltip; >> @@ -1015,6 +1023,10 @@ public abstract class ModelForm extends >> public boolean getHideHeader() { >> return this.hideHeader; >> } >> + public boolean setHideHeader(Boolean hideHeader) { >> + this.hideHeader = hideHeader; >> + return hideHeader; >> + } >> public String getItemIndexSeparator() { >> if (UtilValidate.isNotEmpty(this.itemIndexSeparator)) { >> @@ -1384,6 +1396,10 @@ public abstract class ModelForm extends >> return this.title; >> } >> + public String getEmptyFormDataMessage() { >> + return this.emptyFormDataMessage; >> + } >> + >> public String getTooltip() { >> return this.tooltip; >> } >> >> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================================== >> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java (original) >> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java Sat Oct 15 13:19:35 2016 >> @@ -48,6 +48,7 @@ import org.apache.ofbiz.widget.model.*; >> import org.apache.ofbiz.widget.model.ModelForm.FieldGroup; >> import org.apache.ofbiz.widget.model.ModelForm.FieldGroupBase; >> import org.apache.ofbiz.widget.model.ModelFormField; >> +import org.apache.ofbiz.widget.model.ModelFormField.DisplayField; >> /** >> * A form rendering engine. >> @@ -925,9 +926,12 @@ public class FormRenderer { >> formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); >> int numOfColumns = 0; >> + this.checkFormDataAndSetHeader(context); >> // ===== render header row ===== >> if (!modelForm.getHideHeader()) { >> numOfColumns = this.renderHeaderRow(writer, context); >> + } else { >> + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); >> } >> // ===== render the item rows ===== >> @@ -951,9 +955,12 @@ public class FormRenderer { >> formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); >> int numOfColumns = 0; >> + this.checkFormDataAndSetHeader(context); >> // ===== render header row ===== >> if (!modelForm.getHideHeader()) { >> numOfColumns = this.renderHeaderRow(writer, context); >> + } else { >> + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); >> } >> // ===== render the item rows ===== >> @@ -967,6 +974,32 @@ public class FormRenderer { >> } >> + private void checkFormDataAndSetHeader(Map<String, Object> context) { >> + String lookupName = modelForm.getListName(); >> + Object obj = context.get(lookupName); >> + if (obj == null) { >> + if (Debug.verboseOn()) >> + Debug.logVerbose("No object for list or iterator name [" + lookupName + "] found, so not rendering rows.", module); >> + return; >> + } >> + // if list is empty, do not render rows >> + Iterator<?> iter = null; >> + if (obj instanceof Iterator<?>) { >> + iter = (Iterator<?>) obj; >> + } else if (obj instanceof List<?>) { >> + iter = ((List<?>) obj).listIterator(); >> + } >> + int itemIndex = -1; >> + Object item = null; >> + while ((item = safeNext(iter)) != null) { >> + itemIndex++; >> + break; >> + } >> + if (itemIndex < 0) { >> + modelForm.setHideHeader(true); >> + } >> + } >> + >> private void renderSingleFormString(Appendable writer, Map<String, Object> context, >> int positions) throws IOException { >> List<ModelFormField> tempFieldList = new LinkedList<ModelFormField>(); >> >> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================================== >> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java (original) >> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java Sat Oct 15 13:19:35 2016 >> @@ -99,4 +99,5 @@ public interface FormStringRenderer { >> public void renderContainerFindField(Appendable writer, Map<String, Object> context, ModelFormField.ContainerField containerField) throws >> IOException; >> public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; >> public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; >> + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; >> } >> >> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================================== >> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java (original) >> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java Sat Oct 15 13:19:35 2016 >> @@ -1538,7 +1538,16 @@ public final class MacroFormRenderer imp >> renderEndingBoundaryComment(writer, "Grid Widget - Grid Element", modelForm); >> } >> } >> - >> + >> + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { >> + StringWriter sr = new StringWriter(); >> + sr.append("<@renderEmptyFormDataMessage"); >> + sr.append(" message=\""); >> + sr.append(modelForm.getEmptyFormDataMessage()); >> + sr.append("\" />"); >> + executeMacro(writer, sr.toString()); >> + } >> + >> public void renderFormatHeaderOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { >> StringWriter sr = new StringWriter(); >> sr.append("<@renderFormatHeaderOpen "); >> >> Modified: ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl >> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================================== >> --- ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl (original) >> +++ ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl Sat Oct 15 13:19:35 2016 >> @@ -326,6 +326,10 @@ under the License. >> </label><#t/> >> </#macro> >> +<#macro renderEmptyFormDataMessage message> >> + <h3><#if message?has_content>${message}</#if></h3> >> +</#macro> >> + >> <#macro renderSingleFormFieldTitle></#macro> >> <#macro renderFormOpen linkUrl formType targetWindow containerId containerStyle autocomplete name viewIndexField viewSizeField viewIndex >> viewSize useRowSubmit> >> >> >> > > |
Hi Jacques,
I’ll do some tests and see if it could be fixed quickly, else revert it for now. -- Thanks & Regards, Mridul Pathak > On Oct 17, 2016, at 6:43 PM, Jacques Le Roux <[hidden email]> wrote: > > Hi Mridul, > > After Arun fixed a compilation issue at r1765080, I found that this introduced a regression. Please see https://issues.apache.org/jira/browse/OFBIZ-8505 > > I think it's better to revert and test this more. > > Thanks > > Jacques > > > Le 15/10/2016 à 16:25, Jacques Le Roux a écrit : >> Hi Mridul, >> >> Did you notice we have a compilation issue with this commit? >> >> https://ci.apache.org/builders/ofbiz-trunk >> >> https://ci.apache.org/builders/ofbiz-trunk/builds/1607/steps/shell/logs/stdio >> >> Thanks >> >> Jacques >> >> >> Le 15/10/2016 à 15:19, [hidden email] a écrit : >>> Author: mridulpathak >>> Date: Sat Oct 15 13:19:35 2016 >>> New Revision: 1765058 >>> >>> URL: http://svn.apache.org/viewvc?rev=1765058&view=rev >>> Log: >>> Improved: In form widgets of list type empty header row should not render if list to render in file is empty. >>> (OFBIZ-7598) >>> >>> Thanks: Suraj Khurana for contribution. >>> >>> Modified: >>> ofbiz/trunk/framework/widget/dtd/widget-form.xsd >>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java >>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java >>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java >>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java >>> ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl >>> >>> Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=1765058&r1=1765057&r2=1765058&view=diff >>> ============================================================================== >>> --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) >>> +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Sat Oct 15 13:19:35 2016 >>> @@ -86,6 +86,7 @@ under the License. >>> <xs:attribute name="style" type="xs:string" /> >>> <xs:attribute name="focus-field-name" type="xs:string" /> >>> <xs:attribute name="title" type="xs:string" /> >>> + <xs:attribute name="empty-form-data-message" type="xs:string" /> >>> <xs:attribute name="tooltip" type="xs:string" /> >>> <xs:attribute name="list-name" type="xs:string"> >>> <xs:annotation> >>> @@ -327,6 +328,7 @@ under the License. >>> <xs:attribute name="style" type="xs:string" /> >>> <xs:attribute name="focus-field-name" type="xs:string" /> >>> <xs:attribute name="title" type="xs:string" /> >>> + <xs:attribute name="empty-form-data-message" type="xs:string" /> >>> <xs:attribute name="tooltip" type="xs:string" /> >>> <xs:attribute name="list-name" type="xs:string"> >>> <xs:annotation> >>> >>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>> ============================================================================== >>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java (original) >>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java Sat Oct 15 13:19:35 2016 >>> @@ -147,7 +147,7 @@ public abstract class ModelForm extends >>> private final String formWidgetAreaStyle; >>> private final boolean groupColumns; >>> private final String headerRowStyle; >>> - private final boolean hideHeader; >>> + private boolean hideHeader; >>> private final String itemIndexSeparator; >>> private final List<String> lastOrderFields; >>> private final String listEntryName; >>> @@ -184,6 +184,7 @@ public abstract class ModelForm extends >>> private final String targetType; >>> private final FlexibleStringExpander targetWindowExdr; >>> private final String title; >>> + private final String emptyFormDataMessage; >>> private final String tooltip; >>> private final String type; >>> private final boolean useRowSubmit; >>> @@ -241,6 +242,13 @@ public abstract class ModelForm extends >>> title = parentModel.title; >>> } >>> this.title = title; >>> + String emptyFormDataMessage = formElement.getAttribute("empty-form-data-message"); >>> + if (emptyFormDataMessage.isEmpty() && parentModel != null) { >>> + emptyFormDataMessage = parentModel.emptyFormDataMessage; >>> + } else if (emptyFormDataMessage.isEmpty()) { >>> + emptyFormDataMessage = "No records found"; >>> + } >>> + this.emptyFormDataMessage = emptyFormDataMessage; >>> String tooltip = formElement.getAttribute("tooltip"); >>> if (tooltip.isEmpty() && parentModel != null) { >>> tooltip = parentModel.tooltip; >>> @@ -1015,6 +1023,10 @@ public abstract class ModelForm extends >>> public boolean getHideHeader() { >>> return this.hideHeader; >>> } >>> + public boolean setHideHeader(Boolean hideHeader) { >>> + this.hideHeader = hideHeader; >>> + return hideHeader; >>> + } >>> public String getItemIndexSeparator() { >>> if (UtilValidate.isNotEmpty(this.itemIndexSeparator)) { >>> @@ -1384,6 +1396,10 @@ public abstract class ModelForm extends >>> return this.title; >>> } >>> + public String getEmptyFormDataMessage() { >>> + return this.emptyFormDataMessage; >>> + } >>> + >>> public String getTooltip() { >>> return this.tooltip; >>> } >>> >>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>> ============================================================================== >>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java (original) >>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java Sat Oct 15 13:19:35 2016 >>> @@ -48,6 +48,7 @@ import org.apache.ofbiz.widget.model.*; >>> import org.apache.ofbiz.widget.model.ModelForm.FieldGroup; >>> import org.apache.ofbiz.widget.model.ModelForm.FieldGroupBase; >>> import org.apache.ofbiz.widget.model.ModelFormField; >>> +import org.apache.ofbiz.widget.model.ModelFormField.DisplayField; >>> /** >>> * A form rendering engine. >>> @@ -925,9 +926,12 @@ public class FormRenderer { >>> formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); >>> int numOfColumns = 0; >>> + this.checkFormDataAndSetHeader(context); >>> // ===== render header row ===== >>> if (!modelForm.getHideHeader()) { >>> numOfColumns = this.renderHeaderRow(writer, context); >>> + } else { >>> + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); >>> } >>> // ===== render the item rows ===== >>> @@ -951,9 +955,12 @@ public class FormRenderer { >>> formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); >>> int numOfColumns = 0; >>> + this.checkFormDataAndSetHeader(context); >>> // ===== render header row ===== >>> if (!modelForm.getHideHeader()) { >>> numOfColumns = this.renderHeaderRow(writer, context); >>> + } else { >>> + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); >>> } >>> // ===== render the item rows ===== >>> @@ -967,6 +974,32 @@ public class FormRenderer { >>> } >>> + private void checkFormDataAndSetHeader(Map<String, Object> context) { >>> + String lookupName = modelForm.getListName(); >>> + Object obj = context.get(lookupName); >>> + if (obj == null) { >>> + if (Debug.verboseOn()) >>> + Debug.logVerbose("No object for list or iterator name [" + lookupName + "] found, so not rendering rows.", module); >>> + return; >>> + } >>> + // if list is empty, do not render rows >>> + Iterator<?> iter = null; >>> + if (obj instanceof Iterator<?>) { >>> + iter = (Iterator<?>) obj; >>> + } else if (obj instanceof List<?>) { >>> + iter = ((List<?>) obj).listIterator(); >>> + } >>> + int itemIndex = -1; >>> + Object item = null; >>> + while ((item = safeNext(iter)) != null) { >>> + itemIndex++; >>> + break; >>> + } >>> + if (itemIndex < 0) { >>> + modelForm.setHideHeader(true); >>> + } >>> + } >>> + >>> private void renderSingleFormString(Appendable writer, Map<String, Object> context, >>> int positions) throws IOException { >>> List<ModelFormField> tempFieldList = new LinkedList<ModelFormField>(); >>> >>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>> ============================================================================== >>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java (original) >>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java Sat Oct 15 13:19:35 2016 >>> @@ -99,4 +99,5 @@ public interface FormStringRenderer { >>> public void renderContainerFindField(Appendable writer, Map<String, Object> context, ModelFormField.ContainerField containerField) throws IOException; >>> public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; >>> public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; >>> + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; >>> } >>> >>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>> ============================================================================== >>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java (original) >>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java Sat Oct 15 13:19:35 2016 >>> @@ -1538,7 +1538,16 @@ public final class MacroFormRenderer imp >>> renderEndingBoundaryComment(writer, "Grid Widget - Grid Element", modelForm); >>> } >>> } >>> - >>> + >>> + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { >>> + StringWriter sr = new StringWriter(); >>> + sr.append("<@renderEmptyFormDataMessage"); >>> + sr.append(" message=\""); >>> + sr.append(modelForm.getEmptyFormDataMessage()); >>> + sr.append("\" />"); >>> + executeMacro(writer, sr.toString()); >>> + } >>> + >>> public void renderFormatHeaderOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { >>> StringWriter sr = new StringWriter(); >>> sr.append("<@renderFormatHeaderOpen "); >>> >>> Modified: ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl?rev=1765058&r1=1765057&r2=1765058&view=diff >>> ============================================================================== >>> --- ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl (original) >>> +++ ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl Sat Oct 15 13:19:35 2016 >>> @@ -326,6 +326,10 @@ under the License. >>> </label><#t/> >>> </#macro> >>> +<#macro renderEmptyFormDataMessage message> >>> + <h3><#if message?has_content>${message}</#if></h3> >>> +</#macro> >>> + >>> <#macro renderSingleFormFieldTitle></#macro> >>> <#macro renderFormOpen linkUrl formType targetWindow containerId containerStyle autocomplete name viewIndexField viewSizeField viewIndex viewSize useRowSubmit> >>> >>> >>> >> >> > |
Administrator
|
Thanks Mridul,
I think trunk (bleeding edge) can live with that for few days, then yes I'll revert if not fixed. Jacques Le 18/10/2016 à 10:16, Mridul Pathak a écrit : > Hi Jacques, > > I’ll do some tests and see if it could be fixed quickly, else revert it for now. > > -- > Thanks & Regards, > Mridul Pathak > > >> On Oct 17, 2016, at 6:43 PM, Jacques Le Roux <[hidden email]> wrote: >> >> Hi Mridul, >> >> After Arun fixed a compilation issue at r1765080, I found that this introduced a regression. Please see https://issues.apache.org/jira/browse/OFBIZ-8505 >> >> I think it's better to revert and test this more. >> >> Thanks >> >> Jacques >> >> >> Le 15/10/2016 à 16:25, Jacques Le Roux a écrit : >>> Hi Mridul, >>> >>> Did you notice we have a compilation issue with this commit? >>> >>> https://ci.apache.org/builders/ofbiz-trunk >>> >>> https://ci.apache.org/builders/ofbiz-trunk/builds/1607/steps/shell/logs/stdio >>> >>> Thanks >>> >>> Jacques >>> >>> >>> Le 15/10/2016 à 15:19, [hidden email] a écrit : >>>> Author: mridulpathak >>>> Date: Sat Oct 15 13:19:35 2016 >>>> New Revision: 1765058 >>>> >>>> URL: http://svn.apache.org/viewvc?rev=1765058&view=rev >>>> Log: >>>> Improved: In form widgets of list type empty header row should not render if list to render in file is empty. >>>> (OFBIZ-7598) >>>> >>>> Thanks: Suraj Khurana for contribution. >>>> >>>> Modified: >>>> ofbiz/trunk/framework/widget/dtd/widget-form.xsd >>>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java >>>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java >>>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java >>>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java >>>> ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl >>>> >>>> Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd >>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=1765058&r1=1765057&r2=1765058&view=diff >>>> ============================================================================== >>>> --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) >>>> +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Sat Oct 15 13:19:35 2016 >>>> @@ -86,6 +86,7 @@ under the License. >>>> <xs:attribute name="style" type="xs:string" /> >>>> <xs:attribute name="focus-field-name" type="xs:string" /> >>>> <xs:attribute name="title" type="xs:string" /> >>>> + <xs:attribute name="empty-form-data-message" type="xs:string" /> >>>> <xs:attribute name="tooltip" type="xs:string" /> >>>> <xs:attribute name="list-name" type="xs:string"> >>>> <xs:annotation> >>>> @@ -327,6 +328,7 @@ under the License. >>>> <xs:attribute name="style" type="xs:string" /> >>>> <xs:attribute name="focus-field-name" type="xs:string" /> >>>> <xs:attribute name="title" type="xs:string" /> >>>> + <xs:attribute name="empty-form-data-message" type="xs:string" /> >>>> <xs:attribute name="tooltip" type="xs:string" /> >>>> <xs:attribute name="list-name" type="xs:string"> >>>> <xs:annotation> >>>> >>>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java >>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>>> ============================================================================== >>>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java (original) >>>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java Sat Oct 15 13:19:35 2016 >>>> @@ -147,7 +147,7 @@ public abstract class ModelForm extends >>>> private final String formWidgetAreaStyle; >>>> private final boolean groupColumns; >>>> private final String headerRowStyle; >>>> - private final boolean hideHeader; >>>> + private boolean hideHeader; >>>> private final String itemIndexSeparator; >>>> private final List<String> lastOrderFields; >>>> private final String listEntryName; >>>> @@ -184,6 +184,7 @@ public abstract class ModelForm extends >>>> private final String targetType; >>>> private final FlexibleStringExpander targetWindowExdr; >>>> private final String title; >>>> + private final String emptyFormDataMessage; >>>> private final String tooltip; >>>> private final String type; >>>> private final boolean useRowSubmit; >>>> @@ -241,6 +242,13 @@ public abstract class ModelForm extends >>>> title = parentModel.title; >>>> } >>>> this.title = title; >>>> + String emptyFormDataMessage = formElement.getAttribute("empty-form-data-message"); >>>> + if (emptyFormDataMessage.isEmpty() && parentModel != null) { >>>> + emptyFormDataMessage = parentModel.emptyFormDataMessage; >>>> + } else if (emptyFormDataMessage.isEmpty()) { >>>> + emptyFormDataMessage = "No records found"; >>>> + } >>>> + this.emptyFormDataMessage = emptyFormDataMessage; >>>> String tooltip = formElement.getAttribute("tooltip"); >>>> if (tooltip.isEmpty() && parentModel != null) { >>>> tooltip = parentModel.tooltip; >>>> @@ -1015,6 +1023,10 @@ public abstract class ModelForm extends >>>> public boolean getHideHeader() { >>>> return this.hideHeader; >>>> } >>>> + public boolean setHideHeader(Boolean hideHeader) { >>>> + this.hideHeader = hideHeader; >>>> + return hideHeader; >>>> + } >>>> public String getItemIndexSeparator() { >>>> if (UtilValidate.isNotEmpty(this.itemIndexSeparator)) { >>>> @@ -1384,6 +1396,10 @@ public abstract class ModelForm extends >>>> return this.title; >>>> } >>>> + public String getEmptyFormDataMessage() { >>>> + return this.emptyFormDataMessage; >>>> + } >>>> + >>>> public String getTooltip() { >>>> return this.tooltip; >>>> } >>>> >>>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java >>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>>> ============================================================================== >>>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java (original) >>>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java Sat Oct 15 13:19:35 2016 >>>> @@ -48,6 +48,7 @@ import org.apache.ofbiz.widget.model.*; >>>> import org.apache.ofbiz.widget.model.ModelForm.FieldGroup; >>>> import org.apache.ofbiz.widget.model.ModelForm.FieldGroupBase; >>>> import org.apache.ofbiz.widget.model.ModelFormField; >>>> +import org.apache.ofbiz.widget.model.ModelFormField.DisplayField; >>>> /** >>>> * A form rendering engine. >>>> @@ -925,9 +926,12 @@ public class FormRenderer { >>>> formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); >>>> int numOfColumns = 0; >>>> + this.checkFormDataAndSetHeader(context); >>>> // ===== render header row ===== >>>> if (!modelForm.getHideHeader()) { >>>> numOfColumns = this.renderHeaderRow(writer, context); >>>> + } else { >>>> + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); >>>> } >>>> // ===== render the item rows ===== >>>> @@ -951,9 +955,12 @@ public class FormRenderer { >>>> formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); >>>> int numOfColumns = 0; >>>> + this.checkFormDataAndSetHeader(context); >>>> // ===== render header row ===== >>>> if (!modelForm.getHideHeader()) { >>>> numOfColumns = this.renderHeaderRow(writer, context); >>>> + } else { >>>> + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); >>>> } >>>> // ===== render the item rows ===== >>>> @@ -967,6 +974,32 @@ public class FormRenderer { >>>> } >>>> + private void checkFormDataAndSetHeader(Map<String, Object> context) { >>>> + String lookupName = modelForm.getListName(); >>>> + Object obj = context.get(lookupName); >>>> + if (obj == null) { >>>> + if (Debug.verboseOn()) >>>> + Debug.logVerbose("No object for list or iterator name [" + lookupName + "] found, so not rendering rows.", module); >>>> + return; >>>> + } >>>> + // if list is empty, do not render rows >>>> + Iterator<?> iter = null; >>>> + if (obj instanceof Iterator<?>) { >>>> + iter = (Iterator<?>) obj; >>>> + } else if (obj instanceof List<?>) { >>>> + iter = ((List<?>) obj).listIterator(); >>>> + } >>>> + int itemIndex = -1; >>>> + Object item = null; >>>> + while ((item = safeNext(iter)) != null) { >>>> + itemIndex++; >>>> + break; >>>> + } >>>> + if (itemIndex < 0) { >>>> + modelForm.setHideHeader(true); >>>> + } >>>> + } >>>> + >>>> private void renderSingleFormString(Appendable writer, Map<String, Object> context, >>>> int positions) throws IOException { >>>> List<ModelFormField> tempFieldList = new LinkedList<ModelFormField>(); >>>> >>>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java >>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>>> ============================================================================== >>>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java (original) >>>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java Sat Oct 15 13:19:35 2016 >>>> @@ -99,4 +99,5 @@ public interface FormStringRenderer { >>>> public void renderContainerFindField(Appendable writer, Map<String, Object> context, ModelFormField.ContainerField containerField) throws IOException; >>>> public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; >>>> public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; >>>> + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; >>>> } >>>> >>>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java >>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>>> ============================================================================== >>>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java (original) >>>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java Sat Oct 15 13:19:35 2016 >>>> @@ -1538,7 +1538,16 @@ public final class MacroFormRenderer imp >>>> renderEndingBoundaryComment(writer, "Grid Widget - Grid Element", modelForm); >>>> } >>>> } >>>> - >>>> + >>>> + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { >>>> + StringWriter sr = new StringWriter(); >>>> + sr.append("<@renderEmptyFormDataMessage"); >>>> + sr.append(" message=\""); >>>> + sr.append(modelForm.getEmptyFormDataMessage()); >>>> + sr.append("\" />"); >>>> + executeMacro(writer, sr.toString()); >>>> + } >>>> + >>>> public void renderFormatHeaderOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { >>>> StringWriter sr = new StringWriter(); >>>> sr.append("<@renderFormatHeaderOpen "); >>>> >>>> Modified: ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl >>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl?rev=1765058&r1=1765057&r2=1765058&view=diff >>>> ============================================================================== >>>> --- ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl (original) >>>> +++ ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl Sat Oct 15 13:19:35 2016 >>>> @@ -326,6 +326,10 @@ under the License. >>>> </label><#t/> >>>> </#macro> >>>> +<#macro renderEmptyFormDataMessage message> >>>> + <h3><#if message?has_content>${message}</#if></h3> >>>> +</#macro> >>>> + >>>> <#macro renderSingleFormFieldTitle></#macro> >>>> <#macro renderFormOpen linkUrl formType targetWindow containerId containerStyle autocomplete name viewIndexField viewSizeField viewIndex viewSize useRowSubmit> >>>> >>>> >>>> >>> > > |
In reply to this post by Jacques Le Roux
Hi Mridul,
I like the idea on this commit but I see two problems. * The modification on ModelForm break the threadsafe set by adrian. If I understand what he did, the boolean hideHeader should be rest final, and you don't update the ModelForm during the treatment. To improve it, insteade of *if (!modelForm.getHideHeader()) {* use more *if (!modelForm.getHideHeader() && !elementOnList) {* . After this isn't a good solution to use getHideHeader() to display the message "no element found" because if I create a form without header to display and only the list, :) I'm going to blame you ! * The message isn't call a flexibleStringExpander so you can't use translation and the default label need to use a common label. Nicolas Le 15/10/2016 à 15:19, [hidden email] a écrit : > Author: mridulpathak > Date: Sat Oct 15 13:19:35 2016 > New Revision: 1765058 > > URL: http://svn.apache.org/viewvc?rev=1765058&view=rev > Log: > Improved: In form widgets of list type empty header row should not render if list to render in file is empty. > (OFBIZ-7598) > > Thanks: Suraj Khurana for contribution. > > Modified: > ofbiz/trunk/framework/widget/dtd/widget-form.xsd > ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java > ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java > ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java > ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java > ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl > > Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=1765058&r1=1765057&r2=1765058&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) > +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Sat Oct 15 13:19:35 2016 > @@ -86,6 +86,7 @@ under the License. > <xs:attribute name="style" type="xs:string" /> > <xs:attribute name="focus-field-name" type="xs:string" /> > <xs:attribute name="title" type="xs:string" /> > + <xs:attribute name="empty-form-data-message" type="xs:string" /> > <xs:attribute name="tooltip" type="xs:string" /> > <xs:attribute name="list-name" type="xs:string"> > <xs:annotation> > @@ -327,6 +328,7 @@ under the License. > <xs:attribute name="style" type="xs:string" /> > <xs:attribute name="focus-field-name" type="xs:string" /> > <xs:attribute name="title" type="xs:string" /> > + <xs:attribute name="empty-form-data-message" type="xs:string" /> > <xs:attribute name="tooltip" type="xs:string" /> > <xs:attribute name="list-name" type="xs:string"> > <xs:annotation> > > Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java?rev=1765058&r1=1765057&r2=1765058&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java (original) > +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java Sat Oct 15 13:19:35 2016 > @@ -147,7 +147,7 @@ public abstract class ModelForm extends > private final String formWidgetAreaStyle; > private final boolean groupColumns; > private final String headerRowStyle; > - private final boolean hideHeader; > + private boolean hideHeader; > private final String itemIndexSeparator; > private final List<String> lastOrderFields; > private final String listEntryName; > @@ -184,6 +184,7 @@ public abstract class ModelForm extends > private final String targetType; > private final FlexibleStringExpander targetWindowExdr; > private final String title; > + private final String emptyFormDataMessage; > private final String tooltip; > private final String type; > private final boolean useRowSubmit; > @@ -241,6 +242,13 @@ public abstract class ModelForm extends > title = parentModel.title; > } > this.title = title; > + String emptyFormDataMessage = formElement.getAttribute("empty-form-data-message"); > + if (emptyFormDataMessage.isEmpty() && parentModel != null) { > + emptyFormDataMessage = parentModel.emptyFormDataMessage; > + } else if (emptyFormDataMessage.isEmpty()) { > + emptyFormDataMessage = "No records found"; > + } > + this.emptyFormDataMessage = emptyFormDataMessage; > String tooltip = formElement.getAttribute("tooltip"); > if (tooltip.isEmpty() && parentModel != null) { > tooltip = parentModel.tooltip; > @@ -1015,6 +1023,10 @@ public abstract class ModelForm extends > public boolean getHideHeader() { > return this.hideHeader; > } > + public boolean setHideHeader(Boolean hideHeader) { > + this.hideHeader = hideHeader; > + return hideHeader; > + } > > public String getItemIndexSeparator() { > if (UtilValidate.isNotEmpty(this.itemIndexSeparator)) { > @@ -1384,6 +1396,10 @@ public abstract class ModelForm extends > return this.title; > } > > + public String getEmptyFormDataMessage() { > + return this.emptyFormDataMessage; > + } > + > public String getTooltip() { > return this.tooltip; > } > > Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java Sat Oct 15 13:19:35 2016 > @@ -48,6 +48,7 @@ import org.apache.ofbiz.widget.model.*; > import org.apache.ofbiz.widget.model.ModelForm.FieldGroup; > import org.apache.ofbiz.widget.model.ModelForm.FieldGroupBase; > import org.apache.ofbiz.widget.model.ModelFormField; > +import org.apache.ofbiz.widget.model.ModelFormField.DisplayField; > > /** > * A form rendering engine. > @@ -925,9 +926,12 @@ public class FormRenderer { > formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); > > int numOfColumns = 0; > + this.checkFormDataAndSetHeader(context); > // ===== render header row ===== > if (!modelForm.getHideHeader()) { > numOfColumns = this.renderHeaderRow(writer, context); > + } else { > + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); > } > > // ===== render the item rows ===== > @@ -951,9 +955,12 @@ public class FormRenderer { > formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); > > int numOfColumns = 0; > + this.checkFormDataAndSetHeader(context); > // ===== render header row ===== > if (!modelForm.getHideHeader()) { > numOfColumns = this.renderHeaderRow(writer, context); > + } else { > + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); > } > > // ===== render the item rows ===== > @@ -967,6 +974,32 @@ public class FormRenderer { > > } > > + private void checkFormDataAndSetHeader(Map<String, Object> context) { > + String lookupName = modelForm.getListName(); > + Object obj = context.get(lookupName); > + if (obj == null) { > + if (Debug.verboseOn()) > + Debug.logVerbose("No object for list or iterator name [" + lookupName + "] found, so not rendering rows.", module); > + return; > + } > + // if list is empty, do not render rows > + Iterator<?> iter = null; > + if (obj instanceof Iterator<?>) { > + iter = (Iterator<?>) obj; > + } else if (obj instanceof List<?>) { > + iter = ((List<?>) obj).listIterator(); > + } > + int itemIndex = -1; > + Object item = null; > + while ((item = safeNext(iter)) != null) { > + itemIndex++; > + break; > + } > + if (itemIndex < 0) { > + modelForm.setHideHeader(true); > + } > + } > + > private void renderSingleFormString(Appendable writer, Map<String, Object> context, > int positions) throws IOException { > List<ModelFormField> tempFieldList = new LinkedList<ModelFormField>(); > > Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java Sat Oct 15 13:19:35 2016 > @@ -99,4 +99,5 @@ public interface FormStringRenderer { > public void renderContainerFindField(Appendable writer, Map<String, Object> context, ModelFormField.ContainerField containerField) throws IOException; > public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; > public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; > + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; > } > > Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java Sat Oct 15 13:19:35 2016 > @@ -1538,7 +1538,16 @@ public final class MacroFormRenderer imp > renderEndingBoundaryComment(writer, "Grid Widget - Grid Element", modelForm); > } > } > - > + > + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { > + StringWriter sr = new StringWriter(); > + sr.append("<@renderEmptyFormDataMessage"); > + sr.append(" message=\""); > + sr.append(modelForm.getEmptyFormDataMessage()); > + sr.append("\" />"); > + executeMacro(writer, sr.toString()); > + } > + > public void renderFormatHeaderOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { > StringWriter sr = new StringWriter(); > sr.append("<@renderFormatHeaderOpen "); > > Modified: ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl?rev=1765058&r1=1765057&r2=1765058&view=diff > ============================================================================== > --- ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl (original) > +++ ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl Sat Oct 15 13:19:35 2016 > @@ -326,6 +326,10 @@ under the License. > </label><#t/> > </#macro> > > +<#macro renderEmptyFormDataMessage message> > + <h3><#if message?has_content>${message}</#if></h3> > +</#macro> > + > <#macro renderSingleFormFieldTitle></#macro> > > <#macro renderFormOpen linkUrl formType targetWindow containerId containerStyle autocomplete name viewIndexField viewSizeField viewIndex viewSize useRowSubmit> > > > |
Hi Nicolas,
Thanks for your input. I’ll work on a better approach to implement this feature. -- Thanks & Regards, Mridul Pathak > On Oct 18, 2016, at 5:31 PM, Nicolas Malin <[hidden email]> wrote: > > Hi Mridul, > > I like the idea on this commit but I see two problems. > > * The modification on ModelForm break the threadsafe set by adrian. If I understand what he did, the boolean hideHeader should be rest final, and you don't update the ModelForm during the treatment. To improve it, insteade of *if (!modelForm.getHideHeader()) {* use more *if (!modelForm.getHideHeader() && !elementOnList) {* . After this isn't a good solution to use getHideHeader() to display the message "no element found" because if I create a form without header to display and only the list, :) I'm going to blame you ! > > * The message isn't call a flexibleStringExpander so you can't use translation and the default label need to use a common label. > > Nicolas > > Le 15/10/2016 à 15:19, [hidden email] a écrit : >> Author: mridulpathak >> Date: Sat Oct 15 13:19:35 2016 >> New Revision: 1765058 >> >> URL: http://svn.apache.org/viewvc?rev=1765058&view=rev >> Log: >> Improved: In form widgets of list type empty header row should not render if list to render in file is empty. >> (OFBIZ-7598) >> >> Thanks: Suraj Khurana for contribution. >> >> Modified: >> ofbiz/trunk/framework/widget/dtd/widget-form.xsd >> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java >> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java >> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java >> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java >> ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl >> >> Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd >> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================================== >> --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) >> +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Sat Oct 15 13:19:35 2016 >> @@ -86,6 +86,7 @@ under the License. >> <xs:attribute name="style" type="xs:string" /> >> <xs:attribute name="focus-field-name" type="xs:string" /> >> <xs:attribute name="title" type="xs:string" /> >> + <xs:attribute name="empty-form-data-message" type="xs:string" /> >> <xs:attribute name="tooltip" type="xs:string" /> >> <xs:attribute name="list-name" type="xs:string"> >> <xs:annotation> >> @@ -327,6 +328,7 @@ under the License. >> <xs:attribute name="style" type="xs:string" /> >> <xs:attribute name="focus-field-name" type="xs:string" /> >> <xs:attribute name="title" type="xs:string" /> >> + <xs:attribute name="empty-form-data-message" type="xs:string" /> >> <xs:attribute name="tooltip" type="xs:string" /> >> <xs:attribute name="list-name" type="xs:string"> >> <xs:annotation> >> >> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java >> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================================== >> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java (original) >> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java Sat Oct 15 13:19:35 2016 >> @@ -147,7 +147,7 @@ public abstract class ModelForm extends >> private final String formWidgetAreaStyle; >> private final boolean groupColumns; >> private final String headerRowStyle; >> - private final boolean hideHeader; >> + private boolean hideHeader; >> private final String itemIndexSeparator; >> private final List<String> lastOrderFields; >> private final String listEntryName; >> @@ -184,6 +184,7 @@ public abstract class ModelForm extends >> private final String targetType; >> private final FlexibleStringExpander targetWindowExdr; >> private final String title; >> + private final String emptyFormDataMessage; >> private final String tooltip; >> private final String type; >> private final boolean useRowSubmit; >> @@ -241,6 +242,13 @@ public abstract class ModelForm extends >> title = parentModel.title; >> } >> this.title = title; >> + String emptyFormDataMessage = formElement.getAttribute("empty-form-data-message"); >> + if (emptyFormDataMessage.isEmpty() && parentModel != null) { >> + emptyFormDataMessage = parentModel.emptyFormDataMessage; >> + } else if (emptyFormDataMessage.isEmpty()) { >> + emptyFormDataMessage = "No records found"; >> + } >> + this.emptyFormDataMessage = emptyFormDataMessage; >> String tooltip = formElement.getAttribute("tooltip"); >> if (tooltip.isEmpty() && parentModel != null) { >> tooltip = parentModel.tooltip; >> @@ -1015,6 +1023,10 @@ public abstract class ModelForm extends >> public boolean getHideHeader() { >> return this.hideHeader; >> } >> + public boolean setHideHeader(Boolean hideHeader) { >> + this.hideHeader = hideHeader; >> + return hideHeader; >> + } >> public String getItemIndexSeparator() { >> if (UtilValidate.isNotEmpty(this.itemIndexSeparator)) { >> @@ -1384,6 +1396,10 @@ public abstract class ModelForm extends >> return this.title; >> } >> + public String getEmptyFormDataMessage() { >> + return this.emptyFormDataMessage; >> + } >> + >> public String getTooltip() { >> return this.tooltip; >> } >> >> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java >> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================================== >> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java (original) >> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java Sat Oct 15 13:19:35 2016 >> @@ -48,6 +48,7 @@ import org.apache.ofbiz.widget.model.*; >> import org.apache.ofbiz.widget.model.ModelForm.FieldGroup; >> import org.apache.ofbiz.widget.model.ModelForm.FieldGroupBase; >> import org.apache.ofbiz.widget.model.ModelFormField; >> +import org.apache.ofbiz.widget.model.ModelFormField.DisplayField; >> /** >> * A form rendering engine. >> @@ -925,9 +926,12 @@ public class FormRenderer { >> formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); >> int numOfColumns = 0; >> + this.checkFormDataAndSetHeader(context); >> // ===== render header row ===== >> if (!modelForm.getHideHeader()) { >> numOfColumns = this.renderHeaderRow(writer, context); >> + } else { >> + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); >> } >> // ===== render the item rows ===== >> @@ -951,9 +955,12 @@ public class FormRenderer { >> formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); >> int numOfColumns = 0; >> + this.checkFormDataAndSetHeader(context); >> // ===== render header row ===== >> if (!modelForm.getHideHeader()) { >> numOfColumns = this.renderHeaderRow(writer, context); >> + } else { >> + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); >> } >> // ===== render the item rows ===== >> @@ -967,6 +974,32 @@ public class FormRenderer { >> } >> + private void checkFormDataAndSetHeader(Map<String, Object> context) { >> + String lookupName = modelForm.getListName(); >> + Object obj = context.get(lookupName); >> + if (obj == null) { >> + if (Debug.verboseOn()) >> + Debug.logVerbose("No object for list or iterator name [" + lookupName + "] found, so not rendering rows.", module); >> + return; >> + } >> + // if list is empty, do not render rows >> + Iterator<?> iter = null; >> + if (obj instanceof Iterator<?>) { >> + iter = (Iterator<?>) obj; >> + } else if (obj instanceof List<?>) { >> + iter = ((List<?>) obj).listIterator(); >> + } >> + int itemIndex = -1; >> + Object item = null; >> + while ((item = safeNext(iter)) != null) { >> + itemIndex++; >> + break; >> + } >> + if (itemIndex < 0) { >> + modelForm.setHideHeader(true); >> + } >> + } >> + >> private void renderSingleFormString(Appendable writer, Map<String, Object> context, >> int positions) throws IOException { >> List<ModelFormField> tempFieldList = new LinkedList<ModelFormField>(); >> >> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java >> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================================== >> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java (original) >> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java Sat Oct 15 13:19:35 2016 >> @@ -99,4 +99,5 @@ public interface FormStringRenderer { >> public void renderContainerFindField(Appendable writer, Map<String, Object> context, ModelFormField.ContainerField containerField) throws IOException; >> public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; >> public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; >> + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; >> } >> >> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java >> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================================== >> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java (original) >> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java Sat Oct 15 13:19:35 2016 >> @@ -1538,7 +1538,16 @@ public final class MacroFormRenderer imp >> renderEndingBoundaryComment(writer, "Grid Widget - Grid Element", modelForm); >> } >> } >> - >> + >> + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { >> + StringWriter sr = new StringWriter(); >> + sr.append("<@renderEmptyFormDataMessage"); >> + sr.append(" message=\""); >> + sr.append(modelForm.getEmptyFormDataMessage()); >> + sr.append("\" />"); >> + executeMacro(writer, sr.toString()); >> + } >> + >> public void renderFormatHeaderOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { >> StringWriter sr = new StringWriter(); >> sr.append("<@renderFormatHeaderOpen "); >> >> Modified: ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl >> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl?rev=1765058&r1=1765057&r2=1765058&view=diff >> ============================================================================== >> --- ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl (original) >> +++ ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl Sat Oct 15 13:19:35 2016 >> @@ -326,6 +326,10 @@ under the License. >> </label><#t/> >> </#macro> >> +<#macro renderEmptyFormDataMessage message> >> + <h3><#if message?has_content>${message}</#if></h3> >> +</#macro> >> + >> <#macro renderSingleFormFieldTitle></#macro> >> <#macro renderFormOpen linkUrl formType targetWindow containerId containerStyle autocomplete name viewIndexField viewSizeField viewIndex viewSize useRowSubmit> >> >> >> > |
Thanks Mridul,
I know that is difficult to restart a work already done with another approach. Don't hesitate to ask help if you are hampered by something Nicolas Le 19/10/2016 à 14:08, Mridul Pathak a écrit : > Hi Nicolas, > > Thanks for your input. I’ll work on a better approach to implement this feature. > > -- > Thanks & Regards, > Mridul Pathak > > >> On Oct 18, 2016, at 5:31 PM, Nicolas Malin <[hidden email]> wrote: >> >> Hi Mridul, >> >> I like the idea on this commit but I see two problems. >> >> * The modification on ModelForm break the threadsafe set by adrian. If I understand what he did, the boolean hideHeader should be rest final, and you don't update the ModelForm during the treatment. To improve it, insteade of *if (!modelForm.getHideHeader()) {* use more *if (!modelForm.getHideHeader() && !elementOnList) {* . After this isn't a good solution to use getHideHeader() to display the message "no element found" because if I create a form without header to display and only the list, :) I'm going to blame you ! >> >> * The message isn't call a flexibleStringExpander so you can't use translation and the default label need to use a common label. >> >> Nicolas >> >> Le 15/10/2016 à 15:19, [hidden email] a écrit : >>> Author: mridulpathak >>> Date: Sat Oct 15 13:19:35 2016 >>> New Revision: 1765058 >>> >>> URL: http://svn.apache.org/viewvc?rev=1765058&view=rev >>> Log: >>> Improved: In form widgets of list type empty header row should not render if list to render in file is empty. >>> (OFBIZ-7598) >>> >>> Thanks: Suraj Khurana for contribution. >>> >>> Modified: >>> ofbiz/trunk/framework/widget/dtd/widget-form.xsd >>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java >>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java >>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java >>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java >>> ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl >>> >>> Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=1765058&r1=1765057&r2=1765058&view=diff >>> ============================================================================== >>> --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) >>> +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Sat Oct 15 13:19:35 2016 >>> @@ -86,6 +86,7 @@ under the License. >>> <xs:attribute name="style" type="xs:string" /> >>> <xs:attribute name="focus-field-name" type="xs:string" /> >>> <xs:attribute name="title" type="xs:string" /> >>> + <xs:attribute name="empty-form-data-message" type="xs:string" /> >>> <xs:attribute name="tooltip" type="xs:string" /> >>> <xs:attribute name="list-name" type="xs:string"> >>> <xs:annotation> >>> @@ -327,6 +328,7 @@ under the License. >>> <xs:attribute name="style" type="xs:string" /> >>> <xs:attribute name="focus-field-name" type="xs:string" /> >>> <xs:attribute name="title" type="xs:string" /> >>> + <xs:attribute name="empty-form-data-message" type="xs:string" /> >>> <xs:attribute name="tooltip" type="xs:string" /> >>> <xs:attribute name="list-name" type="xs:string"> >>> <xs:annotation> >>> >>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>> ============================================================================== >>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java (original) >>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java Sat Oct 15 13:19:35 2016 >>> @@ -147,7 +147,7 @@ public abstract class ModelForm extends >>> private final String formWidgetAreaStyle; >>> private final boolean groupColumns; >>> private final String headerRowStyle; >>> - private final boolean hideHeader; >>> + private boolean hideHeader; >>> private final String itemIndexSeparator; >>> private final List<String> lastOrderFields; >>> private final String listEntryName; >>> @@ -184,6 +184,7 @@ public abstract class ModelForm extends >>> private final String targetType; >>> private final FlexibleStringExpander targetWindowExdr; >>> private final String title; >>> + private final String emptyFormDataMessage; >>> private final String tooltip; >>> private final String type; >>> private final boolean useRowSubmit; >>> @@ -241,6 +242,13 @@ public abstract class ModelForm extends >>> title = parentModel.title; >>> } >>> this.title = title; >>> + String emptyFormDataMessage = formElement.getAttribute("empty-form-data-message"); >>> + if (emptyFormDataMessage.isEmpty() && parentModel != null) { >>> + emptyFormDataMessage = parentModel.emptyFormDataMessage; >>> + } else if (emptyFormDataMessage.isEmpty()) { >>> + emptyFormDataMessage = "No records found"; >>> + } >>> + this.emptyFormDataMessage = emptyFormDataMessage; >>> String tooltip = formElement.getAttribute("tooltip"); >>> if (tooltip.isEmpty() && parentModel != null) { >>> tooltip = parentModel.tooltip; >>> @@ -1015,6 +1023,10 @@ public abstract class ModelForm extends >>> public boolean getHideHeader() { >>> return this.hideHeader; >>> } >>> + public boolean setHideHeader(Boolean hideHeader) { >>> + this.hideHeader = hideHeader; >>> + return hideHeader; >>> + } >>> public String getItemIndexSeparator() { >>> if (UtilValidate.isNotEmpty(this.itemIndexSeparator)) { >>> @@ -1384,6 +1396,10 @@ public abstract class ModelForm extends >>> return this.title; >>> } >>> + public String getEmptyFormDataMessage() { >>> + return this.emptyFormDataMessage; >>> + } >>> + >>> public String getTooltip() { >>> return this.tooltip; >>> } >>> >>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>> ============================================================================== >>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java (original) >>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java Sat Oct 15 13:19:35 2016 >>> @@ -48,6 +48,7 @@ import org.apache.ofbiz.widget.model.*; >>> import org.apache.ofbiz.widget.model.ModelForm.FieldGroup; >>> import org.apache.ofbiz.widget.model.ModelForm.FieldGroupBase; >>> import org.apache.ofbiz.widget.model.ModelFormField; >>> +import org.apache.ofbiz.widget.model.ModelFormField.DisplayField; >>> /** >>> * A form rendering engine. >>> @@ -925,9 +926,12 @@ public class FormRenderer { >>> formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); >>> int numOfColumns = 0; >>> + this.checkFormDataAndSetHeader(context); >>> // ===== render header row ===== >>> if (!modelForm.getHideHeader()) { >>> numOfColumns = this.renderHeaderRow(writer, context); >>> + } else { >>> + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); >>> } >>> // ===== render the item rows ===== >>> @@ -951,9 +955,12 @@ public class FormRenderer { >>> formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); >>> int numOfColumns = 0; >>> + this.checkFormDataAndSetHeader(context); >>> // ===== render header row ===== >>> if (!modelForm.getHideHeader()) { >>> numOfColumns = this.renderHeaderRow(writer, context); >>> + } else { >>> + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); >>> } >>> // ===== render the item rows ===== >>> @@ -967,6 +974,32 @@ public class FormRenderer { >>> } >>> + private void checkFormDataAndSetHeader(Map<String, Object> context) { >>> + String lookupName = modelForm.getListName(); >>> + Object obj = context.get(lookupName); >>> + if (obj == null) { >>> + if (Debug.verboseOn()) >>> + Debug.logVerbose("No object for list or iterator name [" + lookupName + "] found, so not rendering rows.", module); >>> + return; >>> + } >>> + // if list is empty, do not render rows >>> + Iterator<?> iter = null; >>> + if (obj instanceof Iterator<?>) { >>> + iter = (Iterator<?>) obj; >>> + } else if (obj instanceof List<?>) { >>> + iter = ((List<?>) obj).listIterator(); >>> + } >>> + int itemIndex = -1; >>> + Object item = null; >>> + while ((item = safeNext(iter)) != null) { >>> + itemIndex++; >>> + break; >>> + } >>> + if (itemIndex < 0) { >>> + modelForm.setHideHeader(true); >>> + } >>> + } >>> + >>> private void renderSingleFormString(Appendable writer, Map<String, Object> context, >>> int positions) throws IOException { >>> List<ModelFormField> tempFieldList = new LinkedList<ModelFormField>(); >>> >>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>> ============================================================================== >>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java (original) >>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java Sat Oct 15 13:19:35 2016 >>> @@ -99,4 +99,5 @@ public interface FormStringRenderer { >>> public void renderContainerFindField(Appendable writer, Map<String, Object> context, ModelFormField.ContainerField containerField) throws IOException; >>> public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; >>> public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; >>> + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; >>> } >>> >>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>> ============================================================================== >>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java (original) >>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java Sat Oct 15 13:19:35 2016 >>> @@ -1538,7 +1538,16 @@ public final class MacroFormRenderer imp >>> renderEndingBoundaryComment(writer, "Grid Widget - Grid Element", modelForm); >>> } >>> } >>> - >>> + >>> + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { >>> + StringWriter sr = new StringWriter(); >>> + sr.append("<@renderEmptyFormDataMessage"); >>> + sr.append(" message=\""); >>> + sr.append(modelForm.getEmptyFormDataMessage()); >>> + sr.append("\" />"); >>> + executeMacro(writer, sr.toString()); >>> + } >>> + >>> public void renderFormatHeaderOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { >>> StringWriter sr = new StringWriter(); >>> sr.append("<@renderFormatHeaderOpen "); >>> >>> Modified: ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl?rev=1765058&r1=1765057&r2=1765058&view=diff >>> ============================================================================== >>> --- ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl (original) >>> +++ ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl Sat Oct 15 13:19:35 2016 >>> @@ -326,6 +326,10 @@ under the License. >>> </label><#t/> >>> </#macro> >>> +<#macro renderEmptyFormDataMessage message> >>> + <h3><#if message?has_content>${message}</#if></h3> >>> +</#macro> >>> + >>> <#macro renderSingleFormFieldTitle></#macro> >>> <#macro renderFormOpen linkUrl formType targetWindow containerId containerStyle autocomplete name viewIndexField viewSizeField viewIndex viewSize useRowSubmit> >>> >>> >>> > |
Administrator
|
In reply to this post by Mridul Pathak-4
Hi Mridul, Arun,
I finally reverted both at revision: 1766080 Jacques Le 18/10/2016 à 10:16, Mridul Pathak a écrit : > Hi Jacques, > > I’ll do some tests and see if it could be fixed quickly, else revert it for now. > > -- > Thanks & Regards, > Mridul Pathak > > >> On Oct 17, 2016, at 6:43 PM, Jacques Le Roux <[hidden email]> wrote: >> >> Hi Mridul, >> >> After Arun fixed a compilation issue at r1765080, I found that this introduced a regression. Please see https://issues.apache.org/jira/browse/OFBIZ-8505 >> >> I think it's better to revert and test this more. >> >> Thanks >> >> Jacques >> >> >> Le 15/10/2016 à 16:25, Jacques Le Roux a écrit : >>> Hi Mridul, >>> >>> Did you notice we have a compilation issue with this commit? >>> >>> https://ci.apache.org/builders/ofbiz-trunk >>> >>> https://ci.apache.org/builders/ofbiz-trunk/builds/1607/steps/shell/logs/stdio >>> >>> Thanks >>> >>> Jacques >>> >>> >>> Le 15/10/2016 à 15:19, [hidden email] a écrit : >>>> Author: mridulpathak >>>> Date: Sat Oct 15 13:19:35 2016 >>>> New Revision: 1765058 >>>> >>>> URL: http://svn.apache.org/viewvc?rev=1765058&view=rev >>>> Log: >>>> Improved: In form widgets of list type empty header row should not render if list to render in file is empty. >>>> (OFBIZ-7598) >>>> >>>> Thanks: Suraj Khurana for contribution. >>>> >>>> Modified: >>>> ofbiz/trunk/framework/widget/dtd/widget-form.xsd >>>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java >>>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java >>>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java >>>> ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java >>>> ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl >>>> >>>> Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd >>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=1765058&r1=1765057&r2=1765058&view=diff >>>> ============================================================================== >>>> --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) >>>> +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Sat Oct 15 13:19:35 2016 >>>> @@ -86,6 +86,7 @@ under the License. >>>> <xs:attribute name="style" type="xs:string" /> >>>> <xs:attribute name="focus-field-name" type="xs:string" /> >>>> <xs:attribute name="title" type="xs:string" /> >>>> + <xs:attribute name="empty-form-data-message" type="xs:string" /> >>>> <xs:attribute name="tooltip" type="xs:string" /> >>>> <xs:attribute name="list-name" type="xs:string"> >>>> <xs:annotation> >>>> @@ -327,6 +328,7 @@ under the License. >>>> <xs:attribute name="style" type="xs:string" /> >>>> <xs:attribute name="focus-field-name" type="xs:string" /> >>>> <xs:attribute name="title" type="xs:string" /> >>>> + <xs:attribute name="empty-form-data-message" type="xs:string" /> >>>> <xs:attribute name="tooltip" type="xs:string" /> >>>> <xs:attribute name="list-name" type="xs:string"> >>>> <xs:annotation> >>>> >>>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java >>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>>> ============================================================================== >>>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java (original) >>>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java Sat Oct 15 13:19:35 2016 >>>> @@ -147,7 +147,7 @@ public abstract class ModelForm extends >>>> private final String formWidgetAreaStyle; >>>> private final boolean groupColumns; >>>> private final String headerRowStyle; >>>> - private final boolean hideHeader; >>>> + private boolean hideHeader; >>>> private final String itemIndexSeparator; >>>> private final List<String> lastOrderFields; >>>> private final String listEntryName; >>>> @@ -184,6 +184,7 @@ public abstract class ModelForm extends >>>> private final String targetType; >>>> private final FlexibleStringExpander targetWindowExdr; >>>> private final String title; >>>> + private final String emptyFormDataMessage; >>>> private final String tooltip; >>>> private final String type; >>>> private final boolean useRowSubmit; >>>> @@ -241,6 +242,13 @@ public abstract class ModelForm extends >>>> title = parentModel.title; >>>> } >>>> this.title = title; >>>> + String emptyFormDataMessage = formElement.getAttribute("empty-form-data-message"); >>>> + if (emptyFormDataMessage.isEmpty() && parentModel != null) { >>>> + emptyFormDataMessage = parentModel.emptyFormDataMessage; >>>> + } else if (emptyFormDataMessage.isEmpty()) { >>>> + emptyFormDataMessage = "No records found"; >>>> + } >>>> + this.emptyFormDataMessage = emptyFormDataMessage; >>>> String tooltip = formElement.getAttribute("tooltip"); >>>> if (tooltip.isEmpty() && parentModel != null) { >>>> tooltip = parentModel.tooltip; >>>> @@ -1015,6 +1023,10 @@ public abstract class ModelForm extends >>>> public boolean getHideHeader() { >>>> return this.hideHeader; >>>> } >>>> + public boolean setHideHeader(Boolean hideHeader) { >>>> + this.hideHeader = hideHeader; >>>> + return hideHeader; >>>> + } >>>> public String getItemIndexSeparator() { >>>> if (UtilValidate.isNotEmpty(this.itemIndexSeparator)) { >>>> @@ -1384,6 +1396,10 @@ public abstract class ModelForm extends >>>> return this.title; >>>> } >>>> + public String getEmptyFormDataMessage() { >>>> + return this.emptyFormDataMessage; >>>> + } >>>> + >>>> public String getTooltip() { >>>> return this.tooltip; >>>> } >>>> >>>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java >>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>>> ============================================================================== >>>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java (original) >>>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java Sat Oct 15 13:19:35 2016 >>>> @@ -48,6 +48,7 @@ import org.apache.ofbiz.widget.model.*; >>>> import org.apache.ofbiz.widget.model.ModelForm.FieldGroup; >>>> import org.apache.ofbiz.widget.model.ModelForm.FieldGroupBase; >>>> import org.apache.ofbiz.widget.model.ModelFormField; >>>> +import org.apache.ofbiz.widget.model.ModelFormField.DisplayField; >>>> /** >>>> * A form rendering engine. >>>> @@ -925,9 +926,12 @@ public class FormRenderer { >>>> formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); >>>> int numOfColumns = 0; >>>> + this.checkFormDataAndSetHeader(context); >>>> // ===== render header row ===== >>>> if (!modelForm.getHideHeader()) { >>>> numOfColumns = this.renderHeaderRow(writer, context); >>>> + } else { >>>> + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); >>>> } >>>> // ===== render the item rows ===== >>>> @@ -951,9 +955,12 @@ public class FormRenderer { >>>> formStringRenderer.renderFormatListWrapperOpen(writer, context, modelForm); >>>> int numOfColumns = 0; >>>> + this.checkFormDataAndSetHeader(context); >>>> // ===== render header row ===== >>>> if (!modelForm.getHideHeader()) { >>>> numOfColumns = this.renderHeaderRow(writer, context); >>>> + } else { >>>> + formStringRenderer.renderEmptyFormDataMessage(writer, context, modelForm); >>>> } >>>> // ===== render the item rows ===== >>>> @@ -967,6 +974,32 @@ public class FormRenderer { >>>> } >>>> + private void checkFormDataAndSetHeader(Map<String, Object> context) { >>>> + String lookupName = modelForm.getListName(); >>>> + Object obj = context.get(lookupName); >>>> + if (obj == null) { >>>> + if (Debug.verboseOn()) >>>> + Debug.logVerbose("No object for list or iterator name [" + lookupName + "] found, so not rendering rows.", module); >>>> + return; >>>> + } >>>> + // if list is empty, do not render rows >>>> + Iterator<?> iter = null; >>>> + if (obj instanceof Iterator<?>) { >>>> + iter = (Iterator<?>) obj; >>>> + } else if (obj instanceof List<?>) { >>>> + iter = ((List<?>) obj).listIterator(); >>>> + } >>>> + int itemIndex = -1; >>>> + Object item = null; >>>> + while ((item = safeNext(iter)) != null) { >>>> + itemIndex++; >>>> + break; >>>> + } >>>> + if (itemIndex < 0) { >>>> + modelForm.setHideHeader(true); >>>> + } >>>> + } >>>> + >>>> private void renderSingleFormString(Appendable writer, Map<String, Object> context, >>>> int positions) throws IOException { >>>> List<ModelFormField> tempFieldList = new LinkedList<ModelFormField>(); >>>> >>>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java >>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>>> ============================================================================== >>>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java (original) >>>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java Sat Oct 15 13:19:35 2016 >>>> @@ -99,4 +99,5 @@ public interface FormStringRenderer { >>>> public void renderContainerFindField(Appendable writer, Map<String, Object> context, ModelFormField.ContainerField containerField) throws IOException; >>>> public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; >>>> public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; >>>> + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; >>>> } >>>> >>>> Modified: ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java >>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java?rev=1765058&r1=1765057&r2=1765058&view=diff >>>> ============================================================================== >>>> --- ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java (original) >>>> +++ ofbiz/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java Sat Oct 15 13:19:35 2016 >>>> @@ -1538,7 +1538,16 @@ public final class MacroFormRenderer imp >>>> renderEndingBoundaryComment(writer, "Grid Widget - Grid Element", modelForm); >>>> } >>>> } >>>> - >>>> + >>>> + public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { >>>> + StringWriter sr = new StringWriter(); >>>> + sr.append("<@renderEmptyFormDataMessage"); >>>> + sr.append(" message=\""); >>>> + sr.append(modelForm.getEmptyFormDataMessage()); >>>> + sr.append("\" />"); >>>> + executeMacro(writer, sr.toString()); >>>> + } >>>> + >>>> public void renderFormatHeaderOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { >>>> StringWriter sr = new StringWriter(); >>>> sr.append("<@renderFormatHeaderOpen "); >>>> >>>> Modified: ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl >>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl?rev=1765058&r1=1765057&r2=1765058&view=diff >>>> ============================================================================== >>>> --- ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl (original) >>>> +++ ofbiz/trunk/framework/widget/templates/HtmlFormMacroLibrary.ftl Sat Oct 15 13:19:35 2016 >>>> @@ -326,6 +326,10 @@ under the License. >>>> </label><#t/> >>>> </#macro> >>>> +<#macro renderEmptyFormDataMessage message> >>>> + <h3><#if message?has_content>${message}</#if></h3> >>>> +</#macro> >>>> + >>>> <#macro renderSingleFormFieldTitle></#macro> >>>> <#macro renderFormOpen linkUrl formType targetWindow containerId containerStyle autocomplete name viewIndexField viewSizeField viewIndex viewSize useRowSubmit> >>>> >>>> >>>> >>> > > |
Free forum by Nabble | Edit this page |