Dev - Requesting Minor Change to HtmlFormRenderer.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dev - Requesting Minor Change to HtmlFormRenderer.java

Mike Baschky
HiDavid,
        I'm submitting a change to HtmlFormRenderer.java for your
consideration. For form widget submit buttons HtmlFormRender
automatically  appends the following javascript:
onClick="javascript:submitFormDisableButton(this)". I would like have
the ability to over ride this behavior if I specify my own 'event' and
'action'. The following code snippet will do just that:

event = modelFormField.getEvent();
action = modelFormField.getAction();
if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
        buffer.append(" ");
        buffer.append(event);
        buffer.append("=\"");
        buffer.append(action);
        buffer.append('"');
} else {
        buffer.append(singleClickAction);
}

This code change is only in HtmlFormRenderer (in two places) and
requires no change to the current form widget XSD because the submit
button is a member of the field element. I'm including a patch file with
the requested changes. Thanks.


Mike

 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev

HtmlFormRender.txt (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dev - Requesting Minor Change to HtmlFormRenderer.java

David E. Jones

Looks okay to me. It's in SVN rev 7743.

-David


Mike Baschky wrote:

> HiDavid,
> I'm submitting a change to HtmlFormRenderer.java for your
> consideration. For form widget submit buttons HtmlFormRender
> automatically  appends the following javascript:
> onClick="javascript:submitFormDisableButton(this)". I would like have
> the ability to over ride this behavior if I specify my own 'event' and
> 'action'. The following code snippet will do just that:
>
> event = modelFormField.getEvent();
> action = modelFormField.getAction();
> if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
> buffer.append(" ");
> buffer.append(event);
> buffer.append("=\"");
> buffer.append(action);
> buffer.append('"');
> } else {
> buffer.append(singleClickAction);
> }
>
> This code change is only in HtmlFormRenderer (in two places) and
> requires no change to the current form widget XSD because the submit
> button is a member of the field element. I'm including a patch file with
> the requested changes. Thanks.
>
>
> Mike
>
>
> ------------------------------------------------------------------------
>
> Index: E:/sandbox/ofbiz/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
> ===================================================================
> --- E:/sandbox/ofbiz/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (revision 7745)
> +++ E:/sandbox/ofbiz/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (working copy)
> @@ -785,6 +785,8 @@
>          ModelFormField modelFormField = submitField.getModelFormField();
>          ModelForm modelForm = modelFormField.getModelForm();
>          String singleClickAction = " onClick=\"javascript:submitFormDisableButton(this)\" ";
> +        String event = null;
> +        String action = null;        
>  
>          if ("text-link".equals(submitField.getButtonType())) {
>              buffer.append("<a");
> @@ -827,9 +829,19 @@
>              buffer.append(" src=\"");
>              this.appendContentUrl(buffer, submitField.getImageLocation());
>              buffer.append('"');
> -
> -            buffer.append(singleClickAction);
>              
> +            event = modelFormField.getEvent();
> +            action = modelFormField.getAction();
> +            if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
> +                buffer.append(" ");
> +                buffer.append(event);
> +                buffer.append("=\"");
> +                buffer.append(action);
> +                buffer.append('"');
> +            } else {
> +             buffer.append(singleClickAction);
> +            }
> +            
>              buffer.append("/>");
>          } else {
>              // default to "button"
> @@ -854,9 +866,20 @@
>                  buffer.append('"');
>              }
>  
> -            // add single click JS onclick
> -            buffer.append(singleClickAction);
>              
> +            event = modelFormField.getEvent();
> +            action = modelFormField.getAction();
> +            if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
> +                buffer.append(" ");
> +                buffer.append(event);
> +                buffer.append("=\"");
> +                buffer.append(action);
> +                buffer.append('"');
> +            } else {
> +             //add single click JS onclick
> +             buffer.append(singleClickAction);
> +            }
> +            
>              buffer.append("/>");
>          }
>  
>
>
> ------------------------------------------------------------------------
>
>  
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev