You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by David E Jones <de...@me.com> on 2009/07/05 22:15:25 UTC

Re: svn commit: r791126 - in /ofbiz/trunk/framework/widget: dtd/widget-menu.xsd src/org/ofbiz/widget/html/HtmlMenuRenderer.java src/org/ofbiz/widget/menu/ModelMenuItem.java

Thanks for doing this Scott. This is very consistent with the overall  
intent and pattern used for the widgets in OFBiz, namely that they  
provide an easy way to accomplish specific and commonly used things,  
and help avoid writing anything platform-specific in a widget  
definition (ie HTML, JavaScript, etc, etc).

-David


On Jul 4, 2009, at 7:34 AM, lektran@apache.org wrote:

> Author: lektran
> Date: Sat Jul  4 13:34:18 2009
> New Revision: 791126
>
> URL: http://svn.apache.org/viewvc?rev=791126&view=rev
> Log:
> Add to new attributes to the Menu Widget's link element:
> request-confirmation - if set to true displays a dialog requesting  
> confirmation from the user before proceeding
> confirmation-message - the confirmation request message to be  
> displayed if the above is set to true
>
> This removes the need to put javascript inside the menu widget when  
> requesting confirmation
>
> Modified:
>    ofbiz/trunk/framework/widget/dtd/widget-menu.xsd
>    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ 
> HtmlMenuRenderer.java
>    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ 
> ModelMenuItem.java
>
> Modified: ofbiz/trunk/framework/widget/dtd/widget-menu.xsd
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-menu.xsd?rev=791126&r1=791125&r2=791126&view=diff
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- ofbiz/trunk/framework/widget/dtd/widget-menu.xsd (original)
> +++ ofbiz/trunk/framework/widget/dtd/widget-menu.xsd Sat Jul  4  
> 13:34:18 2009
> @@ -210,6 +210,16 @@
>                 </xs:restriction>
>             </xs:simpleType>
>         </xs:attribute>
> +        <xs:attribute name="request-confirmation" default="false">
> +            <xs:annotation><xs:documentation>If true then the user  
> is presented with a dialog box requesting confirmation prior to  
> proceeding</xs:documentation></xs:annotation>
> +            <xs:simpleType>
> +                <xs:restriction base="xs:token">
> +                    <xs:enumeration value="true"/>
> +                    <xs:enumeration value="false"/>
> +                </xs:restriction>
> +            </xs:simpleType>
> +        </xs:attribute>
> +        <xs:attribute name="confirmation-message"  
> type="xs:string"><xs:annotation><xs:documentation>The message  
> displayed when request-confirm is set to true</xs:documentation></ 
> xs:annotation></xs:attribute>
>     </xs:attributeGroup>
>     <xs:element name="parameter">
>         <xs:complexType>
>
> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ 
> HtmlMenuRenderer.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java?rev=791126&r1=791125&r2=791126&view=diff
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ 
> HtmlMenuRenderer.java (original)
> +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ 
> HtmlMenuRenderer.java Sat Jul  4 13:34:18 2009
> @@ -453,12 +453,29 @@
>
>             writer.append(" href=\"");
>             if ("hidden-form".equals(linkType)) {
> -                writer.append("javascript:document.");
> -                writer.append(uniqueItemName);
> -                writer.append(".submit()");
> +                if (link.getRequestConfirmation()) {
> +                     
> writer.append("javascript:confirmActionFormLink('");
> +                    writer.append(link.getConfirmationMsg(context));
> +                    writer.append("', '");
> +                    writer.append(uniqueItemName);
> +                    writer.append("')");
> +                } else {
> +                    writer.append("javascript:document.");
> +                    writer.append(uniqueItemName);
> +                    writer.append(".submit()");
> +                }
>             } else {
> +                if (link.getRequestConfirmation()) {
> +                    writer.append("javascript:confirmActionLink('");
> +                    writer.append(link.getConfirmationMsg(context));
> +                    writer.append("', '");
> +                    WidgetWorker.buildHyperlinkUrl(writer, target,  
> link.getUrlMode(), link.getParameterList(), link.getPrefix(context),
> +                            link.getFullPath(), link.getSecure(),  
> link.getEncode(), request, response, context);
> +                    writer.append("')");
> +                } else {
>                 WidgetWorker.buildHyperlinkUrl(writer, target,  
> link.getUrlMode(), link.getParameterList(), link.getPrefix(context),
>                         link.getFullPath(), link.getSecure(),  
> link.getEncode(), request, response, context);
> +                }
>             }
>             writer.append("\">");
>         }
>
> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ 
> ModelMenuItem.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java?rev=791126&r1=791125&r2=791126&view=diff
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ 
> ModelMenuItem.java (original)
> +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ 
> ModelMenuItem.java Sat Jul  4 13:34:18 2009
> @@ -601,6 +601,8 @@
>         protected boolean encode = false;
>         protected String linkType;
>         protected List<WidgetWorker.Parameter> parameterList =  
> FastList.newInstance();
> +        protected boolean requestConfirmation = false;
> +        protected FlexibleStringExpander confirmationMsgExdr;
>
>         public Link(Element linkElement, ModelMenuItem  
> parentMenuItem) {
>             this.linkMenuItem = parentMenuItem;
> @@ -625,6 +627,8 @@
>             for (Element parameterElement: parameterElementList) {
>                 this.parameterList.add(new  
> WidgetWorker.Parameter(parameterElement));
>             }
> +             
> setRequestConfirmation 
> ("true".equals(linkElement.getAttribute("request-confirmation")));
> +             
> setConfirmationMsg(linkElement.getAttribute("confirmation-message"));
>         }
>
>         public Link(ModelMenuItem parentMenuItem) {
> @@ -640,6 +644,7 @@
>             setSecure("");
>             setEncode("");
>             setName("");
> +            setConfirmationMsg("");
>         }
>
>         public void renderLinkString(Appendable writer, Map<String,  
> Object> context, MenuStringRenderer menuStringRenderer) throws  
> IOException {
> @@ -718,6 +723,14 @@
>         public List<WidgetWorker.Parameter> getParameterList() {
>             return this.parameterList;
>         }
> +
> +        public boolean getRequestConfirmation() {
> +            return this.requestConfirmation;
> +        }
> +
> +        public String getConfirmationMsg(Map<String, Object>  
> context) {
> +            return this.confirmationMsgExdr.expandString(context);
> +        }
>
>         public void setText(String val) {
>             String textAttr = UtilFormatOut.checkNull(val);
> @@ -780,6 +793,14 @@
>         public void setImage(Image img) {
>             this.image = img;
>         }
> +
> +        public void setRequestConfirmation(boolean val) {
> +            this.requestConfirmation = val;
> +        }
> +
> +        public void setConfirmationMsg(String val) {
> +            this.confirmationMsgExdr =  
> FlexibleStringExpander.getInstance(val);
> +        }
>
>         public ModelMenuItem getLinkMenuItem() {
>             return linkMenuItem;
>
>