Minor things:
- The CommonConfirm* labels are duplicated but different, also "Confirm adding ?" is not a good english label. Why would we want to confirm creating something anyway? Usually you would reserve confirmation for something a bit more dangerous than that. - onClick should be onclick Regards Scott HotWax Media http://www.hotwaxmedia.com On 17/09/2009, at 12:16 AM, [hidden email] wrote: > Author: jleroux > Date: Wed Sep 16 12:16:03 2009 > New Revision: 815734 > > URL: http://svn.apache.org/viewvc?rev=815734&view=rev > Log: > A patch from Nicolas Malin "Add confirm action before do submit > action." (https://issues.apache.org/jira/browse/OFBIZ-2916) - > OFBIZ-2916 > Add this feature to forms in a consistent way with existing feature > in menu (enhancing this previous feature) > > Modified: > ofbiz/trunk/framework/common/config/CommonUiLabels.xml > ofbiz/trunk/framework/example/widget/example/ExampleForms.xml > ofbiz/trunk/framework/widget/dtd/widget-form.xsd > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ > MacroFormRenderer.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ > ModelFormField.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ > HtmlFormRenderer.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ > HtmlMenuRenderer.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ > ModelMenuItem.java > ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl > > Modified: ofbiz/trunk/framework/common/config/CommonUiLabels.xml > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/CommonUiLabels.xml?rev=815734&r1=815733&r2=815734&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/framework/common/config/CommonUiLabels.xml (original) > +++ ofbiz/trunk/framework/common/config/CommonUiLabels.xml Wed Sep > 16 12:16:03 2009 > @@ -1408,7 +1408,7 @@ > <value xml:lang="de">Bestätigen</value> > <value xml:lang="en">Confirm</value> > <value xml:lang="es">Confirmar</value> > - <value xml:lang="fr">Confirmer</value> > + <value xml:lang="fr">Vous confirmez ?</value> > <value xml:lang="hi_IN">पà¥à¤·à¥à¤à¤¿</value> > <value xml:lang="it">Conferma</value> > <value xml:lang="pt">Confirmar</value> > @@ -1417,6 +1417,62 @@ > <value xml:lang="th">ยืà¸à¸¢à¸±à¸</value> > <value xml:lang="zh">确认</value> > </property> > + <property key="CommonConfirmAdd"> > + <value xml:lang="ar">تأÙÙد</value> > + <value xml:lang="de">Bestätigen</value> > + <value xml:lang="en">Confirm</value> > + <value xml:lang="es">Confirmar</value> > + <value xml:lang="fr">Confirmez-vous l'ajout ?</value> > + <value xml:lang="hi_IN">पà¥à¤·à¥à¤à¤¿</value> > + <value xml:lang="it">Conferma</value> > + <value xml:lang="pt">Confirmar</value> > + <value xml:lang="ro">Confirma</value> > + <value xml:lang="ru">ÐодÑвеÑдиÑÑ</value> > + <value xml:lang="th">ยืà¸à¸¢à¸±à¸</value> > + <value xml:lang="zh">确认</value> > + </property> > + <property key="CommonConfirmDelete"> > + <value xml:lang="ar">تأÙÙد</value> > + <value xml:lang="de">Bestätigen</value> > + <value xml:lang="en">Confirm Delete</value> > + <value xml:lang="es">Confirmar</value> > + <value xml:lang="fr">Confirmez-vous la suppression ?</value> > + <value xml:lang="hi_IN">पà¥à¤·à¥à¤à¤¿</value> > + <value xml:lang="it">Conferma</value> > + <value xml:lang="pt">Confirmar</value> > + <value xml:lang="ro">Confirma</value> > + <value xml:lang="ru">ÐодÑвеÑдиÑÑ</value> > + <value xml:lang="th">ยืà¸à¸¢à¸±à¸</value> > + <value xml:lang="zh">确认</value> > + </property> > + <property key="CommonConfirmAdd"> > + <value xml:lang="ar">êãÃÆÊï</value> > + <value xml:lang="de">Bestätigen</value> > + <value xml:lang="en">Confirm adding ?</value> > + <value xml:lang="es">Confirmar</value> > + <value xml:lang="fr">Confirmez-vous l'ajout ?</value> > + <value xml:lang="hi_IN">à ¤ªà ¥Âà ¤·à ¥Âà ¤Ÿà  > ¤Â¿</value> > + <value xml:lang="it">Conferma</value> > + <value xml:lang="pt">Confirmar</value> > + <value xml:lang="ro">Confirma</value> > + <value xml:lang="ru">ßþôÃâòõÃâ¬Ã > ´Ã¸ÃâÃÅ</value> > + <value xml:lang="th">à ¸¢à ¸·à ¸â¢Ã ¸¢à ¸±à ¸â > ¢</value> > + <value xml:lang="zh">确认</value> > + </property> > + <property key="CommonConfirmDelete"> > + <value xml:lang="ar">êãÃÆÊï</value> > + <value xml:lang="de">Bestätigen</value> > + <value xml:lang="en">Confirm Delete</value> > + <value xml:lang="es">Confirmar</value> > + <value xml:lang="fr">Confirmez vous la suppression ?</value> > + <value xml:lang="hi_IN">à ¤ªà ¥Âà ¤·à ¥Âà ¤Ÿà  > ¤Â¿</value> > + <value xml:lang="it">Conferma</value> > + <value xml:lang="pt">Confirmar</value> > + <value xml:lang="ro">Confirma</value> > + <value xml:lang="ru">ßþôÃâòõÃâ¬Ã > ´Ã¸ÃâÃÅ</value> > + <value xml:lang="th">à ¸¢à ¸·à ¸â¢Ã ¸¢à ¸±à ¸â > ¢</value> > + <value xml:lang="zh">确认</value> > + </property> > <property key="CommonContactMechID"> > <value xml:lang="ar">Ø¥Ø Ø¯Ø§Ø«Ùات</value> > <value xml:lang="de">KontaktMechId</value> > @@ -1438,7 +1494,7 @@ > <value xml:lang="de">Kontakt Zweck</value> > <value xml:lang="en">Contact Purpose</value> > <value xml:lang="es">Propósito del contacto</value> > - <value xml:lang="fr">Objet du contact</value> > + <value xml:lang="fr">But du contact</value> > <value xml:lang="hi_IN">सà¤à¤ªà¤°à¥à¤ पà¥à¤°à¤¯à¥à > ¤à¤¨</value> > <value xml:lang="it">Funzione contatto</value> > <value xml:lang="nl">Kontact reden</value> > > Modified: ofbiz/trunk/framework/example/widget/example/ > ExampleForms.xml > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/widget/example/ExampleForms.xml?rev=815734&r1=815733&r2=815734&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/framework/example/widget/example/ExampleForms.xml > (original) > +++ ofbiz/trunk/framework/example/widget/example/ExampleForms.xml > Wed Sep 16 12:16:03 2009 > @@ -175,7 +175,7 @@ > </drop-down> > </field> > <field name="deleteLink" title="" widget-style="buttontext"> > - <hyperlink target="deleteExampleItem" description="$ > {uiLabelMap.CommonDelete}" also-hidden="false"> > + <hyperlink target="deleteExampleItem" description="$ > {uiLabelMap.CommonDelete}" also-hidden="false" confirmation- > message="${uiLabelMap.CommonConfirmDelete}"> > <parameter param-name="exampleId"/> > <parameter param-name="exampleItemSeqId"/> > </hyperlink> > @@ -195,7 +195,7 @@ > </entity-options> > </drop-down> > </field> > - <field name="submitButton" title="$ > {uiLabelMap.CommonAdd}"><submit button-type="button"/></field> > + <field name="submitButton" title="$ > {uiLabelMap.CommonAdd}"><submit button-type="button" request- > confirmation="true"/></field> > </form> > > <!-- ExampleFeatureAppl --> > > Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=815734&r1=815733&r2=815734&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) > +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Wed Sep 16 > 12:16:03 2009 > @@ -832,6 +832,16 @@ > </xs:attribute> > <xs:attribute type="xs:string" name="target-window"/> > <xs:attribute type="xs:string" name="image-location"/> > + <xs:attribute name="request-confirmation" default="false"> > + <xs:annotation><xs:documentation>If true then the user > is presented with a dialog box, if confirmation-message is empty, > use default</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 in confirmation box</xs:documentation></xs:annotation></ > xs:attribute> > </xs:attributeGroup> > <xs:element name="parameter"> > <xs:complexType> > @@ -982,6 +992,16 @@ > <xs:annotation><xs:documentation>Deprecated. Use the on- > event-update-area element > instead.</xs:documentation></xs:annotation> > </xs:attribute> > + <xs:attribute name="request-confirmation" default="false"> > + <xs:annotation><xs:documentation>If true then the user > is presented with a dialog box, if confirmation-message is empty, > use default</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 in confirmation box</xs:documentation></xs:annotation></ > xs:attribute> > </xs:attributeGroup> > <xs:element name="text" substitutionGroup="AllFields"> > <xs:complexType> > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ > WidgetWorker.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java?rev=815734&r1=815733&r2=815734&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ > WidgetWorker.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ > WidgetWorker.java Wed Sep 16 12:16:03 2009 > @@ -119,14 +119,13 @@ > writer.append(buffer.toString()); > writer.append(location); > } > - > public static void makeHyperlinkByType(Appendable writer, String > linkType, String linkStyle, String targetType, String target, > - List<WidgetWorker.Parameter> parameterList, String > description, String targetWindow, ModelFormField modelFormField, > + List<WidgetWorker.Parameter> parameterList, String > description, String targetWindow, String confirmation, > ModelFormField modelFormField, > HttpServletRequest request, HttpServletResponse > response, Map<String, Object> context) throws IOException { > String realLinkType = > WidgetWorker.determineAutoLinkType(linkType, target, targetType, > request); > if ("hidden-form".equals(realLinkType)) { > if (modelFormField != null && > "multi".equals(modelFormField.getModelForm().getType())) { > - WidgetWorker.makeHiddenFormLinkAnchor(writer, > linkStyle, description, modelFormField, request, response, context); > + WidgetWorker.makeHiddenFormLinkAnchor(writer, > linkStyle, description, confirmation, modelFormField, request, > response, context); > > // this is a bit trickier, since we can't do a > nested form we'll have to put the link to submit the form in place, > but put the actual form def elsewhere, ie after the big form is closed > Map<String, Object> wholeFormContext = > UtilGenerics.checkMap(context.get("wholeFormContext")); > @@ -138,16 +137,15 @@ > > WidgetWorker.makeHiddenFormLinkForm(postMultiFormWriter, target, > targetType, targetWindow, parameterList, modelFormField, request, > response, context); > } else { > WidgetWorker.makeHiddenFormLinkForm(writer, target, > targetType, targetWindow, parameterList, modelFormField, request, > response, context); > - WidgetWorker.makeHiddenFormLinkAnchor(writer, > linkStyle, description, modelFormField, request, response, context); > + WidgetWorker.makeHiddenFormLinkAnchor(writer, > linkStyle, description, confirmation, modelFormField, request, > response, context); > } > } else { > - WidgetWorker.makeHyperlinkString(writer, linkStyle, > targetType, target, parameterList, description, modelFormField, > request, response, context, targetWindow); > + WidgetWorker.makeHyperlinkString(writer, linkStyle, > targetType, target, parameterList, description, confirmation, > modelFormField, request, response, context, targetWindow); > } > > } > - > public static void makeHyperlinkString(Appendable writer, String > linkStyle, String targetType, String target, > List<WidgetWorker.Parameter> parameterList, > - String description, ModelFormField modelFormField, > HttpServletRequest request, HttpServletResponse response, > Map<String, Object> context, String targetWindow) > + String description, String confirmation, ModelFormField > modelFormField, HttpServletRequest request, HttpServletResponse > response, Map<String, Object> context, String targetWindow) > throws IOException { > if (UtilValidate.isNotEmpty(description) || > UtilValidate.isNotEmpty(request.getAttribute("image"))) { > writer.append("<a"); > @@ -177,7 +175,11 @@ > writer.append(modelFormField.getAction(context)); > writer.append('"'); > } > - > + if (UtilValidate.isNotEmpty(confirmation)){ > + writer.append(" onClick=\"return confirm('"); > + writer.append(confirmation); > + writer.append("')\""); > + } > writer.append('>'); > > if > (UtilValidate.isNotEmpty(request.getAttribute("image"))) { > @@ -190,8 +192,8 @@ > writer.append("</a>"); > } > } > - > - public static void makeHiddenFormLinkAnchor(Appendable writer, > String linkStyle, String description, ModelFormField modelFormField, > HttpServletRequest request, HttpServletResponse response, > Map<String, Object> context) throws IOException { > + > + public static void makeHiddenFormLinkAnchor(Appendable writer, > String linkStyle, String description, String confirmation, > ModelFormField modelFormField, HttpServletRequest request, > HttpServletResponse response, Map<String, Object> context) throws > IOException { > if (UtilValidate.isNotEmpty(description) || > UtilValidate.isNotEmpty(request.getAttribute("image"))) { > writer.append("<a"); > > @@ -212,6 +214,12 @@ > writer.append(modelFormField.getAction(context)); > writer.append('"'); > } > + > + if (UtilValidate.isNotEmpty(confirmation)){ > + writer.append(" onClick=\"return confirm('"); > + writer.append(confirmation); > + writer.append("')\""); > + } > > writer.append('>'); > > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ > MacroFormRenderer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=815734&r1=815733&r2=815734&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ > MacroFormRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ > MacroFormRenderer.java Wed Sep 16 12:16:03 2009 > @@ -320,7 +320,7 @@ > ModelFormField modelFormField = > hyperlinkField.getModelFormField(); > > makeHyperlinkByType(writer, hyperlinkField.getLinkType(), > modelFormField.getWidgetStyle(), hyperlinkField.getTargetType(), > hyperlinkField.getTarget(context), > - hyperlinkField.getParameterList(), > hyperlinkField.getDescription(context), > hyperlinkField.getTargetWindow(context), modelFormField, > + hyperlinkField.getParameterList(), > hyperlinkField.getDescription(context), > hyperlinkField.getTargetWindow(context), > hyperlinkField.getConfirmation(context), modelFormField, > this.request, this.response, context); > > this.appendTooltip(writer, context, modelFormField); > @@ -996,6 +996,7 @@ > String buttonType = submitField.getButtonType(); > String formName = modelForm.getCurrentFormName(context); > String imgSrc = submitField.getImageLocation(); > + String confirmation = submitField.getConfirmation(context); > String className = ""; > String alert = "false"; > if > (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) { > @@ -1050,6 +1051,8 @@ > if (ajaxEnabled) { > sr.append(formId); > } > + sr.append("\" confirmation =\""); > + sr.append(confirmation ); > sr.append("\" ajaxUrl=\""); > if (ajaxEnabled) { > sr.append(ajaxUrl); > @@ -2478,8 +2481,8 @@ > targetType="plain"; > } > StringWriter sr = new StringWriter(); > - WidgetWorker.makeHyperlinkString(sr, > modelFormField.getHeaderLinkStyle(), targetType, > targetBuffer.toString(), null, titleText, modelFormField, > this.request, this.response, null, null); > - String title = sr.toString().replace("\"", "\'"); > + WidgetWorker.makeHyperlinkString(sr, > modelFormField.getHeaderLinkStyle(), targetType, > targetBuffer.toString(), null, titleText, null, modelFormField, > this.request, this.response, null, null); > + String title = sr.toString().replace("\"", "\'"); > sr = new StringWriter(); > sr.append("<@renderHyperlinkTitle "); > sr.append(" name=\""); > @@ -2652,7 +2655,7 @@ > if (subHyperlink.shouldUse(context)) { > writer.append(' '); > WidgetWorker.makeHyperlinkByType(writer, > subHyperlink.getLinkType(), subHyperlink.getLinkStyle(), > subHyperlink.getTargetType(), subHyperlink.getTarget(context), > - subHyperlink.getParameterList(), > subHyperlink.getDescription(context), > subHyperlink.getTargetWindow(context), > subHyperlink.getModelFormField(), > + subHyperlink.getParameterList(), > subHyperlink.getDescription(context), > subHyperlink.getTargetWindow(context), > subHyperlink.getConfirmation(context), > subHyperlink.getModelFormField(), > this.request, this.response, context); > } > } > @@ -2680,12 +2683,12 @@ > } > > public void makeHyperlinkByType(Appendable writer, String > linkType, String linkStyle, String targetType, String target, > - List<WidgetWorker.Parameter> parameterList, String > description, String targetWindow, ModelFormField modelFormField, > + List<WidgetWorker.Parameter> parameterList, String > description, String targetWindow, String confirmation , > ModelFormField modelFormField, > HttpServletRequest request, HttpServletResponse > response, Map<String, Object> context) throws IOException { > String realLinkType = > WidgetWorker.determineAutoLinkType(linkType, target, targetType, > request); > if ("hidden-form".equals(realLinkType)) { > if (modelFormField != null && > "multi".equals(modelFormField.getModelForm().getType())) { > - WidgetWorker.makeHiddenFormLinkAnchor(writer, > linkStyle, description, modelFormField, request, response, context); > + WidgetWorker.makeHiddenFormLinkAnchor(writer, > linkStyle, description, confirmation , modelFormField, request, > response, context); > > // this is a bit trickier, since we can't do a > nested form we'll have to put the link to submit the form in place, > but put the actual form def elsewhere, ie after the big form is closed > Map<String, Object> wholeFormContext = > UtilGenerics.checkMap(context.get("wholeFormContext")); > @@ -2697,16 +2700,16 @@ > > WidgetWorker.makeHiddenFormLinkForm(postMultiFormWriter, target, > targetType, targetWindow, parameterList, modelFormField, request, > response, context); > } else { > WidgetWorker.makeHiddenFormLinkForm(writer, target, > targetType, targetWindow, parameterList, modelFormField, request, > response, context); > - WidgetWorker.makeHiddenFormLinkAnchor(writer, > linkStyle, description, modelFormField, request, response, context); > + WidgetWorker.makeHiddenFormLinkAnchor(writer, > linkStyle, description, confirmation , modelFormField, request, > response, context); > } > } else { > - WidgetWorker.makeHyperlinkString(writer, linkStyle, > targetType, target, parameterList, description, modelFormField, > request, response, context, targetWindow); > + WidgetWorker.makeHyperlinkString(writer, linkStyle, > targetType, target, parameterList, description, confirmation , > modelFormField, request, response, context, targetWindow); > } > > } > > public void makeHyperlinkString(Appendable writer, String > linkStyle, String targetType, String target, > List<WidgetWorker.Parameter> parameterList, > - String description, ModelFormField modelFormField, > HttpServletRequest request, HttpServletResponse response, > Map<String, Object> context, String targetWindow) > + String description, String confirmation , > ModelFormField modelFormField, HttpServletRequest request, > HttpServletResponse response, Map<String, Object> context, String > targetWindow) > throws IOException { > if (UtilValidate.isNotEmpty(description) || > UtilValidate.isNotEmpty(request.getAttribute("image"))) { > StringBuilder linkUrl = new StringBuilder(); > @@ -2745,12 +2748,14 @@ > sr.append(targetWindow); > sr.append("\" description=\""); > sr.append(description); > + sr.append("\" confirmation =\""); > + sr.append(confirmation ); > sr.append("\" />"); > executeMacro(sr.toString()); > } > } > - > - public void makeHiddenFormLinkAnchor(Appendable writer, String > linkStyle, String description, ModelFormField modelFormField, > HttpServletRequest request, HttpServletResponse response, > Map<String, Object> context) throws IOException { > + > + public void makeHiddenFormLinkAnchor(Appendable writer, String > linkStyle, String description, String confirmation , ModelFormField > modelFormField, HttpServletRequest request, HttpServletResponse > response, Map<String, Object> context) throws IOException { > if (UtilValidate.isNotEmpty(description) || > UtilValidate.isNotEmpty(request.getAttribute("image"))) { > String hiddenFormName = > WidgetWorker.makeLinkHiddenFormName(context, modelFormField); > String event = ""; > @@ -2780,6 +2785,8 @@ > sr.append(imgSrc); > sr.append("\" description=\""); > sr.append(description); > + sr.append("\" confirmation =\""); > + sr.append(confirmation ); > sr.append("\" />"); > executeMacro(sr.toString()); > } > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ > ModelFormField.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=815734&r1=815733&r2=815734&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ > ModelFormField.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ > ModelFormField.java Wed Sep 16 12:16:03 2009 > @@ -42,6 +42,7 @@ > import org.ofbiz.base.util.UtilFormatOut; > import org.ofbiz.base.util.UtilGenerics; > import org.ofbiz.base.util.UtilMisc; > +import org.ofbiz.base.util.UtilProperties; > import org.ofbiz.base.util.UtilValidate; > import org.ofbiz.base.util.UtilXml; > import org.ofbiz.base.util.collections.FlexibleMapAccessor; > @@ -2236,6 +2237,8 @@ > protected FlexibleStringExpander targetWindowExdr; > protected List<WidgetWorker.Parameter> parameterList = > FastList.newInstance(); > > + protected boolean requestConfirmation = false; > + protected FlexibleStringExpander confirmationMsgExdr; > protected HyperlinkField() { > super(); > } > @@ -2258,7 +2261,8 @@ > this.targetType = element.getAttribute("target-type"); > this.targetWindowExdr = > FlexibleStringExpander.getInstance(element.getAttribute("target- > window")); > this.image = element.getAttribute("image-location"); > - > + > this > .setRequestConfirmation("true".equals(element.getAttribute("request- > confirmation"))); > + > this.setConfirmationMsg(element.getAttribute("confirmation-message")); > List<? extends Element> parameterElementList = > UtilXml.childElementList(element, "parameter"); > for (Element parameterElement: parameterElementList) { > this.parameterList.add(new > WidgetWorker.Parameter(parameterElement)); > @@ -2273,7 +2277,28 @@ > public boolean getAlsoHidden() { > return this.alsoHidden; > } > + > + public boolean getRequestConfirmation() { > + return this.requestConfirmation; > + } > > + public String getConfirmation(Map<String, Object> context) { > + String message = getConfirmationMsg(context); > + if (UtilValidate.isNotEmpty(message)) { > + return message; > + } > + else if (getRequestConfirmation()) { > + String defaultMessage = > UtilProperties.getPropertyValue("general", > "default.confirmation.message", "${uiLabelMap.CommonConfirm}"); > + setConfirmationMsg(defaultMessage); > + return getConfirmationMsg(context); > + } > + return ""; > + } > + > + public String getConfirmationMsg(Map<String, Object> > context) { > + return this.confirmationMsgExdr.expandString(context); > + } > + > public String getLinkType() { > return this.linkType; > } > @@ -2334,6 +2359,14 @@ > public void setTarget(String string) { > this.target = FlexibleStringExpander.getInstance(string); > } > + > + public void setRequestConfirmation(boolean val) { > + this.requestConfirmation = val; > + } > + > + public void setConfirmationMsg(String val) { > + this.confirmationMsgExdr = > FlexibleStringExpander.getInstance(val); > + } > } > > public static class SubHyperlink { > @@ -2345,6 +2378,8 @@ > protected FlexibleStringExpander description; > protected FlexibleStringExpander targetWindowExdr; > protected List<WidgetWorker.Parameter> parameterList = > FastList.newInstance(); > + protected boolean requestConfirmation = false; > + protected FlexibleStringExpander confirmationMsgExdr; > protected ModelFormField modelFormField; > > public SubHyperlink(Element element, ModelFormField > modelFormField) { > @@ -2355,15 +2390,16 @@ > this.linkStyle = element.getAttribute("link-style"); > this.targetType = element.getAttribute("target-type"); > this.targetWindowExdr = > FlexibleStringExpander.getInstance(element.getAttribute("target- > window")); > - > List<? extends Element> parameterElementList = > UtilXml.childElementList(element, "parameter"); > for (Element parameterElement: parameterElementList) { > this.parameterList.add(new > WidgetWorker.Parameter(parameterElement)); > } > + > setRequestConfirmation("true".equals(element.getAttribute("request- > confirmation"))); > + setConfirmationMsg(element.getAttribute("confirmation- > message")); > > this.modelFormField = modelFormField; > } > - > + > public String getLinkStyle() { > return this.linkStyle; > } > @@ -2412,7 +2448,28 @@ > return ""; > } > } > - > + > + public boolean getRequestConfirmation() { > + return this.requestConfirmation; > + } > + > + public String getConfirmationMsg(Map<String, Object> > context) { > + return this.confirmationMsgExdr.expandString(context); > + } > + > + public String getConfirmation(Map<String, Object> context) { > + String message = getConfirmationMsg(context); > + if (UtilValidate.isNotEmpty(message)) { > + return message; > + } > + else if (getRequestConfirmation()) { > + String defaultMessage = > UtilProperties.getPropertyValue("general", > "default.confirmation.message", "${uiLabelMap.CommonConfirm}"); > + setConfirmationMsg(defaultMessage); > + return getConfirmationMsg(context); > + } > + return ""; > + } > + > public ModelFormField getModelFormField() { > return this.modelFormField; > } > @@ -2480,6 +2537,14 @@ > */ > public void setUseWhen(String string) { > this.useWhen = FlexibleStringExpander.getInstance(string); > + } > + > + public void setRequestConfirmation(boolean val) { > + this.requestConfirmation = val; > + } > + > + public void setConfirmationMsg(String val) { > + this.confirmationMsgExdr = > FlexibleStringExpander.getInstance(val); > } > } > > @@ -3112,6 +3177,8 @@ > protected String buttonType; > protected String imageLocation; > protected FlexibleStringExpander > backgroundSubmitRefreshTargetExdr; > + protected boolean requestConfirmation = false; > + protected FlexibleStringExpander confirmationMsgExdr; > > protected SubmitField() { > super(); > @@ -3130,7 +3197,9 @@ > this.buttonType = element.getAttribute("button-type"); > this.imageLocation = element.getAttribute("image- > location"); > this.backgroundSubmitRefreshTargetExdr = > FlexibleStringExpander.getInstance(element.getAttribute("background- > submit-refresh-target")); > - } > + > setRequestConfirmation("true".equals(element.getAttribute("request- > confirmation"))); > + setConfirmationMsg(element.getAttribute("confirmation- > message")); > + } > > @Override > public void renderFieldString(Appendable writer, Map<String, > Object> context, FormStringRenderer formStringRenderer) throws > IOException { > @@ -3143,8 +3212,29 @@ > > public String getImageLocation() { > return imageLocation; > - } > + } > > + public boolean getRequestConfirmation() { > + return this.requestConfirmation; > + } > + > + public String getConfirmationMsg(Map<String, Object> > context) { > + return this.confirmationMsgExdr.expandString(context); > + } > + > + public String getConfirmation(Map<String, Object> context) { > + String message = getConfirmationMsg(context); > + if (UtilValidate.isNotEmpty(message)) { > + return message; > + } > + else if (getRequestConfirmation()) { > + String defaultMessage = > UtilProperties.getPropertyValue("general", > "default.confirmation.message", "${uiLabelMap.CommonConfirm}"); > + setConfirmationMsg(defaultMessage); > + return getConfirmationMsg(context); > + } > + return ""; > + } > + > /** > * @param string > */ > @@ -3161,7 +3251,16 @@ > > public String getBackgroundSubmitRefreshTarget(Map<String, > Object> context) { > return > this.backgroundSubmitRefreshTargetExdr.expandString(context); > + } > + > + public void setRequestConfirmation(boolean val) { > + this.requestConfirmation = val; > + } > + > + public void setConfirmationMsg(String val) { > + this.confirmationMsgExdr = > FlexibleStringExpander.getInstance(val); > } > + > } > > public static class ResetField extends FieldInfo { > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ > HtmlFormRenderer.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=815734&r1=815733&r2=815734&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ > HtmlFormRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ > HtmlFormRenderer.java Wed Sep 16 12:16:03 2009 > @@ -331,11 +331,9 @@ > public void renderHyperlinkField(Appendable writer, Map<String, > Object> context, HyperlinkField hyperlinkField) throws IOException { > this.request.setAttribute("image", hyperlinkField.getImage()); > ModelFormField modelFormField = > hyperlinkField.getModelFormField(); > - > WidgetWorker.makeHyperlinkByType(writer, > hyperlinkField.getLinkType(), modelFormField.getWidgetStyle(), > hyperlinkField.getTargetType(), hyperlinkField.getTarget(context), > - hyperlinkField.getParameterList(), > hyperlinkField.getDescription(context), > hyperlinkField.getTargetWindow(context), modelFormField, > - this.request, this.response, context); > - > + hyperlinkField.getParameterList(), > hyperlinkField.getDescription(context), > hyperlinkField.getTargetWindow(context), > hyperlinkField.getConfirmation(context), modelFormField, > + this.request, this.response, context); > this.appendTooltip(writer, context, modelFormField); > //appendWhitespace(writer); > } > @@ -343,12 +341,12 @@ > public void makeHyperlinkString(Appendable writer, > ModelFormField.SubHyperlink subHyperlink, Map<String, Object> > context) throws IOException { > if (subHyperlink == null) { > return; > - } > + } > if (subHyperlink.shouldUse(context)) { > writer.append(' '); > WidgetWorker.makeHyperlinkByType(writer, > subHyperlink.getLinkType(), subHyperlink.getLinkStyle(), > subHyperlink.getTargetType(), subHyperlink.getTarget(context), > - subHyperlink.getParameterList(), > subHyperlink.getDescription(context), > subHyperlink.getTargetWindow(context), > subHyperlink.getModelFormField(), > - this.request, this.response, context); > + subHyperlink.getParameterList(), > subHyperlink.getDescription(context), > subHyperlink.getTargetWindow(context), > subHyperlink.getConfirmation(context), > subHyperlink.getModelFormField(), > + this.request, this.response, context); > } > } > > @@ -1041,12 +1039,18 @@ > ModelForm modelForm = modelFormField.getModelForm(); > String event = null; > String action = null; > + String confirmation = submitField.getConfirmation(context); > > if ("text-link".equals(submitField.getButtonType())) { > writer.append("<a"); > > appendClassNames(writer, context, modelFormField); > - > + if (UtilValidate.isNotEmpty(confirmation)) { > + writer.append("onClick=\" return confirm('"); > + writer.append(confirmation); > + writer.append("); \" "); > + } > + > writer.append(" href=\"javascript:document."); > writer.append(modelForm.getCurrentFormName(context)); > writer.append(".submit()\">"); > @@ -1083,6 +1087,12 @@ > writer.append(action); > writer.append('"'); > } > + > + if (UtilValidate.isNotEmpty(confirmation)) { > + writer.append("onClick=\" return confirm('"); > + writer.append(confirmation); > + writer.append("); \" "); > + } > > writer.append("/>"); > } else { > @@ -1136,6 +1146,11 @@ > > if (ajaxEnabled) { > writer.append(" onclick=\""); > + if (UtilValidate.isNotEmpty(confirmation)) { > + writer.append("if (confirm('"); > + writer.append(confirmation); > + writer.append(");) "); > + } > writer.append("ajaxSubmitFormUpdateAreas('"); > writer.append(formId); > writer.append("', > '").append(createAjaxParamsFromUpdateAreas(updateAreas, null, > context)); > @@ -2855,7 +2870,7 @@ > if (UtilValidate.isNotEmpty(targetBuffer.toString()) && > targetBuffer.toString().toLowerCase().startsWith("javascript:")) { > targetType="plain"; > } > - WidgetWorker.makeHyperlinkString(writer, > modelFormField.getHeaderLinkStyle(), targetType, > targetBuffer.toString(), null, titleText, modelFormField, > this.request, this.response, null, null); > + WidgetWorker.makeHyperlinkString(writer, > modelFormField.getHeaderLinkStyle(), targetType, > targetBuffer.toString(), null, titleText, null, modelFormField, > this.request, this.response, null, null); > } else if (modelFormField.isSortField()) { > renderSortField (writer, context, modelFormField, > titleText); > } else if (modelFormField.isRowSubmit()) { > > 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=815734&r1=815733&r2=815734&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 Wed Sep 16 12:16:03 2009 > @@ -450,10 +450,11 @@ > } > > writer.append(" href=\""); > + String confirmationMsg = link.getConfirmation(context); > if ("hidden-form".equals(linkType)) { > - if (link.getRequestConfirmation()) { > + if (UtilValidate.isNotEmpty(confirmationMsg)) { > > writer.append("javascript:confirmActionFormLink('"); > - writer.append(link.getConfirmationMsg(context)); > + writer.append(confirmationMsg); > writer.append("', '"); > writer.append(uniqueItemName); > writer.append("')"); > @@ -463,9 +464,9 @@ > writer.append(".submit()"); > } > } else { > - if (link.getRequestConfirmation()) { > + if (UtilValidate.isNotEmpty(confirmationMsg)) { > writer.append("javascript:confirmActionLink('"); > - writer.append(link.getConfirmationMsg(context)); > + writer.append(confirmationMsg); > writer.append("', '"); > WidgetWorker.buildHyperlinkUrl(writer, target, > link.getUrlMode(), link.getParameterList(), link.getPrefix(context), > link.getFullPath(), link.getSecure(), > link.getEncode(), request, response, context); > > 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=815734&r1=815733&r2=815734&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 Wed Sep 16 12:16:03 2009 > @@ -32,6 +32,7 @@ > import org.ofbiz.base.util.StringUtil; > import org.ofbiz.base.util.UtilFormatOut; > import org.ofbiz.base.util.UtilMisc; > +import org.ofbiz.base.util.UtilProperties; > import org.ofbiz.base.util.UtilValidate; > import org.ofbiz.base.util.UtilXml; > import org.ofbiz.base.util.string.FlexibleStringExpander; > @@ -724,6 +725,19 @@ > return this.parameterList; > } > > + public String getConfirmation(Map<String, Object> context) { > + String message = getConfirmationMsg(context); > + if (UtilValidate.isNotEmpty(message)) { > + return message; > + } > + else if (getRequestConfirmation()) { > + String defaultMessage = > UtilProperties.getPropertyValue("general", > "default.confirmation.message", "${uiLabelMap.CommonConfirm}"); > + setConfirmationMsg(defaultMessage); > + return getConfirmationMsg(context); > + } > + return ""; > + } > + > public boolean getRequestConfirmation() { > return this.requestConfirmation; > } > > Modified: ofbiz/trunk/framework/widget/templates/ > htmlFormMacroLibrary.ftl > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=815734&r1=815733&r2=815734&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl > (original) > +++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl > Wed Sep 16 12:16:03 2009 > @@ -170,13 +170,13 @@ > </#list> > </#macro> > > -<#macro renderSubmitField buttonType className alert formName title > name event action imgSrc containerId ajaxUrl> > +<#macro renderSubmitField buttonType className alert formName title > name event action imgSrc confirmation containerId ajaxUrl> > <#if buttonType=="text-link"> > - <a <@renderClass className alert /> href="javascript:document.$ > {formName}.submit()"><#if title?has_content>${title}</#if> </a> > + <a <@renderClass className alert /> href="javascript:document.$ > {formName}.submit()" <#if confirmation?has_content>onclick="return > confirm('${confirmation}');"</#if>><#if title?has_content>${title}</ > #if> </a> > <#elseif buttonType=="image"> > - <input type="image" src="${imgSrc}" <@renderClass className alert / > ><#if name?has_content> name="${name}"</#if><#if title?has_content> > alt="${title}"</#if><#if event?has_content> ${event}="${action}"</ > #if> /> > + <input type="image" src="${imgSrc}" <@renderClass className alert / > ><#if name?has_content> name="${name}"</#if><#if title?has_content> > alt="${title}"</#if><#if event?has_content> ${event}="${action}"</ > #if> <#if confirmation?has_content>onclick="return confirm('$ > {confirmation}');"</#if>/> > <#else> > -<input type="<#if containerId?has_content>button<#else>submit</ > #if>" <@renderClass className alert /><#if name?exists> name="$ > {name}"</#if><#if title?has_content> value="${title}"</#if><#if > event?has_content> ${event}="${action}"</#if><#if containerId? > has_content> onclick="ajaxSubmitFormUpdateAreas('${containerId}', '$ > {ajaxUrl}')"</#if>/></#if> > +<input type="<#if containerId?has_content>button<#else>submit</ > #if>" <@renderClass className alert /><#if name?exists> name="$ > {name}"</#if><#if title?has_content> value="${title}"</#if><#if > event?has_content> ${event}="${action}"</#if><#if containerId? > has_content> onclick="<#if confirmation?has_content>if (confirm('$ > {confirmation}')) </#if>ajaxSubmitFormUpdateAreas('${containerId}', > '${ajaxUrl}')"<#else><#if confirmation?has_content> onclick="return > confirm('${confirmation}');"</#if></#if>/></#if> > </#macro> > > <#macro renderResetField className alert name title> > @@ -469,5 +469,5 @@ > <#if requiredField=="true"><#if requiredStyle?has_content>*</#if></ > #if> > </#macro> > <#macro makeHiddenFormLinkForm actionUrl name parameters > targetWindow><form method="post" action="${actionUrl}" <#if > targetWindow?has_content>target="${targetWindow}"</#if> > onsubmit="javascript:submitFormDisableSubmits(this)" name="$ > {name}"><#list parameters as parameter><input name="$ > {parameter.name}" value="${parameter.value}" type="hidden"/></ > #list></form></#macro> > -<#macro makeHiddenFormLinkAnchor linkStyle hiddenFormName event > action imgSrc description><a <#if linkStyle?has_content>class="$ > {linkStyle}"</#if> href="javascript:document.$ > {hiddenFormName}.submit()"<#if action?has_content && event? > has_content> ${event}="${action}"</#if>><#if imgSrc?has_content><img > src="${imgSrc}"/></#if>${description}</a></#macro> > -<#macro makeHyperlinkString linkStyle hiddenFormName event action > imgSrc linkUrl targetWindow description><a <#if linkStyle? > has_content>class="${linkStyle}"</#if> href="${linkUrl}"<#if > targetWindow?has_content> target="${targetWindow}"</#if><#if action? > has_content && event?has_content> ${event}="${action}"</#if>><#if > imgSrc?has_content><img src="${imgSrc}"/></#if>${description}</a></ > #macro> > +<#macro makeHiddenFormLinkAnchor linkStyle hiddenFormName event > action imgSrc description confirmation><a <#if linkStyle? > has_content>class="${linkStyle}"</#if> href="javascript:document.$ > {hiddenFormName}.submit()"<#if action?has_content && event? > has_content> ${event}="${action}"</#if><#if confirmation? > has_content> onclick="return confirm('${confirmation}')"</#if>><#if > imgSrc?has_content><img src="${imgSrc}"/></#if>${description}</a></ > #macro> > +<#macro makeHyperlinkString linkStyle hiddenFormName event action > imgSrc linkUrl targetWindow description confirmation><a <#if > linkStyle?has_content>class="${linkStyle}"</#if> href="$ > {linkUrl}"<#if targetWindow?has_content> target="${targetWindow}"</ > #if><#if action?has_content && event?has_content> ${event}="$ > {action}"</#if><#if confirmation?has_content> onclick="return > confirm('${confirmation}')"</#if>><#if imgSrc?has_content><img src="$ > {imgSrc}"/></#if>${description}</a></#macro> > > smime.p7s (3K) Download Attachment |
Administrator
|
Hi Scott,
Fixed at r815770 I have kept the addition message. Some may find it useful, I guess Nicolas did. Thanks Jacques From: "Scott Gray" <[hidden email]> Minor things: - The CommonConfirm* labels are duplicated but different, also "Confirm adding ?" is not a good english label. Why would we want to confirm creating something anyway? Usually you would reserve confirmation for something a bit more dangerous than that. - onClick should be onclick Regards Scott HotWax Media http://www.hotwaxmedia.com On 17/09/2009, at 12:16 AM, [hidden email] wrote: > Author: jleroux > Date: Wed Sep 16 12:16:03 2009 > New Revision: 815734 > > URL: http://svn.apache.org/viewvc?rev=815734&view=rev > Log: > A patch from Nicolas Malin "Add confirm action before do submit action." (https://issues.apache.org/jira/browse/OFBIZ-2916) - > OFBIZ-2916 > Add this feature to forms in a consistent way with existing feature in menu (enhancing this previous feature) > > Modified: > ofbiz/trunk/framework/common/config/CommonUiLabels.xml > ofbiz/trunk/framework/example/widget/example/ExampleForms.xml > ofbiz/trunk/framework/widget/dtd/widget-form.xsd > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ MacroFormRenderer.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ ModelFormField.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ HtmlFormRenderer.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ HtmlMenuRenderer.java > ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ ModelMenuItem.java > ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl > > Modified: ofbiz/trunk/framework/common/config/CommonUiLabels.xml > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/CommonUiLabels.xml?rev=815734&r1=815733&r2=815734&view=diff > = = = = = = = = ====================================================================== > --- ofbiz/trunk/framework/common/config/CommonUiLabels.xml (original) > +++ ofbiz/trunk/framework/common/config/CommonUiLabels.xml Wed Sep 16 12:16:03 2009 > @@ -1408,7 +1408,7 @@ > <value xml:lang="de">Bestätigen</value> > <value xml:lang="en">Confirm</value> > <value xml:lang="es">Confirmar</value> > - <value xml:lang="fr">Confirmer</value> > + <value xml:lang="fr">Vous confirmez ?</value> > <value xml:lang="hi_IN">पà¥à¤·à¥à¤Yि</value> > <value xml:lang="it">Conferma</value> > <value xml:lang="pt">Confirmar</value> > @@ -1417,6 +1417,62 @@ > <value xml:lang="th">ยืà¸Tยัà¸T</value> > <value xml:lang="zh">确认</value> > </property> > + <property key="CommonConfirmAdd"> > + <value xml:lang="ar">تأÙfÙSد</value> > + <value xml:lang="de">Bestätigen</value> > + <value xml:lang="en">Confirm</value> > + <value xml:lang="es">Confirmar</value> > + <value xml:lang="fr">Confirmez-vous l'ajout ?</value> > + <value xml:lang="hi_IN">पà¥à¤·à¥à¤Yि</value> > + <value xml:lang="it">Conferma</value> > + <value xml:lang="pt">Confirmar</value> > + <value xml:lang="ro">Confirma</value> > + <value xml:lang="ru">ÐYодÑ,веÑ?диÑ,ÑO</value> > + <value xml:lang="th">ยืà¸Tยัà¸T</value> > + <value xml:lang="zh">确认</value> > + </property> > + <property key="CommonConfirmDelete"> > + <value xml:lang="ar">تأÙfÙSد</value> > + <value xml:lang="de">Bestätigen</value> > + <value xml:lang="en">Confirm Delete</value> > + <value xml:lang="es">Confirmar</value> > + <value xml:lang="fr">Confirmez-vous la suppression ?</value> > + <value xml:lang="hi_IN">पà¥à¤·à¥à¤Yि</value> > + <value xml:lang="it">Conferma</value> > + <value xml:lang="pt">Confirmar</value> > + <value xml:lang="ro">Confirma</value> > + <value xml:lang="ru">ÐYодÑ,веÑ?диÑ,ÑO</value> > + <value xml:lang="th">ยืà¸Tยัà¸T</value> > + <value xml:lang="zh">确认</value> > + </property> > + <property key="CommonConfirmAdd"> > + <value xml:lang="ar">Ã~ªÃ~£ÃTÆ'ÃTÅ Ã~¯</value> > + <value xml:lang="de">BestÃf¤tigen</value> > + <value xml:lang="en">Confirm adding ?</value> > + <value xml:lang="es">Confirmar</value> > + <value xml:lang="fr">Confirmez-vous l'ajout ?</value> > + <value xml:lang="hi_IN">à ¤ªà ¥Âà ¤·à ¥Âà ¤Ÿà  ¤Â¿</value> > + <value xml:lang="it">Conferma</value> > + <value xml:lang="pt">Confirmar</value> > + <value xml:lang="ro">Confirma</value> > + <value xml:lang="ru">ßþôÃ'â?sòõÃ'â,¬Ã ´Ã¸Ã'â?sÃ'Å'</value> > + <value xml:lang="th">à ¸¢à ¸·à ¸â"¢Ã ¸¢à ¸±à ¸â" ¢</value> > + <value xml:lang="zh">确认</value> > + </property> > + <property key="CommonConfirmDelete"> > + <value xml:lang="ar">Ã~ªÃ~£ÃTÆ'ÃTÅ Ã~¯</value> > + <value xml:lang="de">BestÃf¤tigen</value> > + <value xml:lang="en">Confirm Delete</value> > + <value xml:lang="es">Confirmar</value> > + <value xml:lang="fr">Confirmez vous la suppression ?</value> > + <value xml:lang="hi_IN">à ¤ªà ¥Âà ¤·à ¥Âà ¤Ÿà  ¤Â¿</value> > + <value xml:lang="it">Conferma</value> > + <value xml:lang="pt">Confirmar</value> > + <value xml:lang="ro">Confirma</value> > + <value xml:lang="ru">ßþôÃ'â?sòõÃ'â,¬Ã ´Ã¸Ã'â?sÃ'Å'</value> > + <value xml:lang="th">à ¸¢à ¸·à ¸â"¢Ã ¸¢à ¸±à ¸â" ¢</value> > + <value xml:lang="zh">确认</value> > + </property> > <property key="CommonContactMechID"> > <value xml:lang="ar">Ø¥Ø Ø¯Ø§Ø«ÙSات</value> > <value xml:lang="de">KontaktMechId</value> > @@ -1438,7 +1494,7 @@ > <value xml:lang="de">Kontakt Zweck</value> > <value xml:lang="en">Contact Purpose</value> > <value xml:lang="es">Propósito del contacto</value> > - <value xml:lang="fr">Objet du contact</value> > + <value xml:lang="fr">But du contact</value> > <value xml:lang="hi_IN">सà¤,परà¥à¤. पà¥à¤°à¤¯à¥<à ¤oन</value> > <value xml:lang="it">Funzione contatto</value> > <value xml:lang="nl">Kontact reden</value> > > Modified: ofbiz/trunk/framework/example/widget/example/ ExampleForms.xml > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/widget/example/ExampleForms.xml?rev=815734&r1=815733&r2=815734&view=diff > = = = = = = = = ====================================================================== > --- ofbiz/trunk/framework/example/widget/example/ExampleForms.xml (original) > +++ ofbiz/trunk/framework/example/widget/example/ExampleForms.xml Wed Sep 16 12:16:03 2009 > @@ -175,7 +175,7 @@ > </drop-down> > </field> > <field name="deleteLink" title="" widget-style="buttontext"> > - <hyperlink target="deleteExampleItem" description="$ {uiLabelMap.CommonDelete}" also-hidden="false"> > + <hyperlink target="deleteExampleItem" description="$ {uiLabelMap.CommonDelete}" also-hidden="false" confirmation- > message="${uiLabelMap.CommonConfirmDelete}"> > <parameter param-name="exampleId"/> > <parameter param-name="exampleItemSeqId"/> > </hyperlink> > @@ -195,7 +195,7 @@ > </entity-options> > </drop-down> > </field> > - <field name="submitButton" title="$ {uiLabelMap.CommonAdd}"><submit button-type="button"/></field> > + <field name="submitButton" title="$ {uiLabelMap.CommonAdd}"><submit button-type="button" request- > confirmation="true"/></field> > </form> > > <!-- ExampleFeatureAppl --> > > Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=815734&r1=815733&r2=815734&view=diff > = = = = = = = = ====================================================================== > --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) > +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Wed Sep 16 12:16:03 2009 > @@ -832,6 +832,16 @@ > </xs:attribute> > <xs:attribute type="xs:string" name="target-window"/> > <xs:attribute type="xs:string" name="image-location"/> > + <xs:attribute name="request-confirmation" default="false"> > + <xs:annotation><xs:documentation>If true then the user is presented with a dialog box, if confirmation-message is > empty, use default</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 in > confirmation box</xs:documentation></xs:annotation></ xs:attribute> > </xs:attributeGroup> > <xs:element name="parameter"> > <xs:complexType> > @@ -982,6 +992,16 @@ > <xs:annotation><xs:documentation>Deprecated. Use the on- event-update-area element > instead.</xs:documentation></xs:annotation> > </xs:attribute> > + <xs:attribute name="request-confirmation" default="false"> > + <xs:annotation><xs:documentation>If true then the user is presented with a dialog box, if confirmation-message is > empty, use default</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 in > confirmation box</xs:documentation></xs:annotation></ xs:attribute> > </xs:attributeGroup> > <xs:element name="text" substitutionGroup="AllFields"> > <xs:complexType> > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ WidgetWorker.java > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java?rev=815734&r1=815733&r2=815734&view=diff > = = = = = = = = ====================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ WidgetWorker.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ WidgetWorker.java Wed Sep 16 12:16:03 2009 > @@ -119,14 +119,13 @@ > writer.append(buffer.toString()); > writer.append(location); > } > - > public static void makeHyperlinkByType(Appendable writer, String linkType, String linkStyle, String targetType, String > target, > - List<WidgetWorker.Parameter> parameterList, String description, String targetWindow, ModelFormField modelFormField, > + List<WidgetWorker.Parameter> parameterList, String description, String targetWindow, String confirmation, > ModelFormField modelFormField, > HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException { > String realLinkType = WidgetWorker.determineAutoLinkType(linkType, target, targetType, request); > if ("hidden-form".equals(realLinkType)) { > if (modelFormField != null && "multi".equals(modelFormField.getModelForm().getType())) { > - WidgetWorker.makeHiddenFormLinkAnchor(writer, linkStyle, description, modelFormField, request, response, > context); > + WidgetWorker.makeHiddenFormLinkAnchor(writer, linkStyle, description, confirmation, modelFormField, request, > response, context); > > // this is a bit trickier, since we can't do a nested form we'll have to put the link to submit the form in > place, but put the actual form def elsewhere, ie after the big form is closed > Map<String, Object> wholeFormContext = UtilGenerics.checkMap(context.get("wholeFormContext")); > @@ -138,16 +137,15 @@ > WidgetWorker.makeHiddenFormLinkForm(postMultiFormWriter, target, targetType, targetWindow, parameterList, > modelFormField, request, response, context); > } else { > WidgetWorker.makeHiddenFormLinkForm(writer, target, targetType, targetWindow, parameterList, modelFormField, > request, response, context); > - WidgetWorker.makeHiddenFormLinkAnchor(writer, linkStyle, description, modelFormField, request, response, > context); > + WidgetWorker.makeHiddenFormLinkAnchor(writer, linkStyle, description, confirmation, modelFormField, request, > response, context); > } > } else { > - WidgetWorker.makeHyperlinkString(writer, linkStyle, targetType, target, parameterList, description, modelFormField, > request, response, context, targetWindow); > + WidgetWorker.makeHyperlinkString(writer, linkStyle, targetType, target, parameterList, description, confirmation, > modelFormField, request, response, context, targetWindow); > } > > } > - > public static void makeHyperlinkString(Appendable writer, String linkStyle, String targetType, String target, > List<WidgetWorker.Parameter> parameterList, > - String description, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, > Map<String, Object> context, String targetWindow) > + String description, String confirmation, ModelFormField modelFormField, HttpServletRequest request, > HttpServletResponse response, Map<String, Object> context, String targetWindow) > throws IOException { > if (UtilValidate.isNotEmpty(description) || UtilValidate.isNotEmpty(request.getAttribute("image"))) { > writer.append("<a"); > @@ -177,7 +175,11 @@ > writer.append(modelFormField.getAction(context)); > writer.append('"'); > } > - > + if (UtilValidate.isNotEmpty(confirmation)){ > + writer.append(" onClick=\"return confirm('"); > + writer.append(confirmation); > + writer.append("')\""); > + } > writer.append('>'); > > if (UtilValidate.isNotEmpty(request.getAttribute("image"))) { > @@ -190,8 +192,8 @@ > writer.append("</a>"); > } > } > - > - public static void makeHiddenFormLinkAnchor(Appendable writer, String linkStyle, String description, ModelFormField > modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException { > + > + public static void makeHiddenFormLinkAnchor(Appendable writer, String linkStyle, String description, String confirmation, > ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws > IOException { > if (UtilValidate.isNotEmpty(description) || UtilValidate.isNotEmpty(request.getAttribute("image"))) { > writer.append("<a"); > > @@ -212,6 +214,12 @@ > writer.append(modelFormField.getAction(context)); > writer.append('"'); > } > + > + if (UtilValidate.isNotEmpty(confirmation)){ > + writer.append(" onClick=\"return confirm('"); > + writer.append(confirmation); > + writer.append("')\""); > + } > > writer.append('>'); > > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ MacroFormRenderer.java > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=815734&r1=815733&r2=815734&view=diff > = = = = = = = = ====================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ MacroFormRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ MacroFormRenderer.java Wed Sep 16 12:16:03 2009 > @@ -320,7 +320,7 @@ > ModelFormField modelFormField = hyperlinkField.getModelFormField(); > > makeHyperlinkByType(writer, hyperlinkField.getLinkType(), modelFormField.getWidgetStyle(), > hyperlinkField.getTargetType(), hyperlinkField.getTarget(context), > - hyperlinkField.getParameterList(), hyperlinkField.getDescription(context), > hyperlinkField.getTargetWindow(context), modelFormField, > + hyperlinkField.getParameterList(), hyperlinkField.getDescription(context), > hyperlinkField.getTargetWindow(context), hyperlinkField.getConfirmation(context), modelFormField, > this.request, this.response, context); > > this.appendTooltip(writer, context, modelFormField); > @@ -996,6 +996,7 @@ > String buttonType = submitField.getButtonType(); > String formName = modelForm.getCurrentFormName(context); > String imgSrc = submitField.getImageLocation(); > + String confirmation = submitField.getConfirmation(context); > String className = ""; > String alert = "false"; > if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) { > @@ -1050,6 +1051,8 @@ > if (ajaxEnabled) { > sr.append(formId); > } > + sr.append("\" confirmation =\""); > + sr.append(confirmation ); > sr.append("\" ajaxUrl=\""); > if (ajaxEnabled) { > sr.append(ajaxUrl); > @@ -2478,8 +2481,8 @@ > targetType="plain"; > } > StringWriter sr = new StringWriter(); > - WidgetWorker.makeHyperlinkString(sr, modelFormField.getHeaderLinkStyle(), targetType, targetBuffer.toString(), > null, titleText, modelFormField, this.request, this.response, null, null); > - String title = sr.toString().replace("\"", "\'"); > + WidgetWorker.makeHyperlinkString(sr, modelFormField.getHeaderLinkStyle(), targetType, targetBuffer.toString(), > null, titleText, null, modelFormField, this.request, this.response, null, null); > + String title = sr.toString().replace("\"", "\'"); > sr = new StringWriter(); > sr.append("<@renderHyperlinkTitle "); > sr.append(" name=\""); > @@ -2652,7 +2655,7 @@ > if (subHyperlink.shouldUse(context)) { > writer.append(' '); > WidgetWorker.makeHyperlinkByType(writer, subHyperlink.getLinkType(), subHyperlink.getLinkStyle(), > subHyperlink.getTargetType(), subHyperlink.getTarget(context), > - subHyperlink.getParameterList(), subHyperlink.getDescription(context), > subHyperlink.getTargetWindow(context), subHyperlink.getModelFormField(), > + subHyperlink.getParameterList(), subHyperlink.getDescription(context), > subHyperlink.getTargetWindow(context), subHyperlink.getConfirmation(context), subHyperlink.getModelFormField(), > this.request, this.response, context); > } > } > @@ -2680,12 +2683,12 @@ > } > > public void makeHyperlinkByType(Appendable writer, String linkType, String linkStyle, String targetType, String target, > - List<WidgetWorker.Parameter> parameterList, String description, String targetWindow, ModelFormField modelFormField, > + List<WidgetWorker.Parameter> parameterList, String description, String targetWindow, String confirmation , > ModelFormField modelFormField, > HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException { > String realLinkType = WidgetWorker.determineAutoLinkType(linkType, target, targetType, request); > if ("hidden-form".equals(realLinkType)) { > if (modelFormField != null && "multi".equals(modelFormField.getModelForm().getType())) { > - WidgetWorker.makeHiddenFormLinkAnchor(writer, linkStyle, description, modelFormField, request, response, > context); > + WidgetWorker.makeHiddenFormLinkAnchor(writer, linkStyle, description, confirmation , modelFormField, request, > response, context); > > // this is a bit trickier, since we can't do a nested form we'll have to put the link to submit the form in > place, but put the actual form def elsewhere, ie after the big form is closed > Map<String, Object> wholeFormContext = UtilGenerics.checkMap(context.get("wholeFormContext")); > @@ -2697,16 +2700,16 @@ > WidgetWorker.makeHiddenFormLinkForm(postMultiFormWriter, target, targetType, targetWindow, parameterList, > modelFormField, request, response, context); > } else { > WidgetWorker.makeHiddenFormLinkForm(writer, target, targetType, targetWindow, parameterList, modelFormField, > request, response, context); > - WidgetWorker.makeHiddenFormLinkAnchor(writer, linkStyle, description, modelFormField, request, response, > context); > + WidgetWorker.makeHiddenFormLinkAnchor(writer, linkStyle, description, confirmation , modelFormField, request, > response, context); > } > } else { > - WidgetWorker.makeHyperlinkString(writer, linkStyle, targetType, target, parameterList, description, modelFormField, > request, response, context, targetWindow); > + WidgetWorker.makeHyperlinkString(writer, linkStyle, targetType, target, parameterList, description, confirmation , > modelFormField, request, response, context, targetWindow); > } > > } > > public void makeHyperlinkString(Appendable writer, String linkStyle, String targetType, String target, > List<WidgetWorker.Parameter> parameterList, > - String description, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, > Map<String, Object> context, String targetWindow) > + String description, String confirmation , ModelFormField modelFormField, HttpServletRequest request, > HttpServletResponse response, Map<String, Object> context, String targetWindow) > throws IOException { > if (UtilValidate.isNotEmpty(description) || UtilValidate.isNotEmpty(request.getAttribute("image"))) { > StringBuilder linkUrl = new StringBuilder(); > @@ -2745,12 +2748,14 @@ > sr.append(targetWindow); > sr.append("\" description=\""); > sr.append(description); > + sr.append("\" confirmation =\""); > + sr.append(confirmation ); > sr.append("\" />"); > executeMacro(sr.toString()); > } > } > - > - public void makeHiddenFormLinkAnchor(Appendable writer, String linkStyle, String description, ModelFormField modelFormField, > HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException { > + > + public void makeHiddenFormLinkAnchor(Appendable writer, String linkStyle, String description, String confirmation , > ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws > IOException { > if (UtilValidate.isNotEmpty(description) || UtilValidate.isNotEmpty(request.getAttribute("image"))) { > String hiddenFormName = WidgetWorker.makeLinkHiddenFormName(context, modelFormField); > String event = ""; > @@ -2780,6 +2785,8 @@ > sr.append(imgSrc); > sr.append("\" description=\""); > sr.append(description); > + sr.append("\" confirmation =\""); > + sr.append(confirmation ); > sr.append("\" />"); > executeMacro(sr.toString()); > } > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ ModelFormField.java > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=815734&r1=815733&r2=815734&view=diff > = = = = = = = = ====================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ ModelFormField.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ ModelFormField.java Wed Sep 16 12:16:03 2009 > @@ -42,6 +42,7 @@ > import org.ofbiz.base.util.UtilFormatOut; > import org.ofbiz.base.util.UtilGenerics; > import org.ofbiz.base.util.UtilMisc; > +import org.ofbiz.base.util.UtilProperties; > import org.ofbiz.base.util.UtilValidate; > import org.ofbiz.base.util.UtilXml; > import org.ofbiz.base.util.collections.FlexibleMapAccessor; > @@ -2236,6 +2237,8 @@ > protected FlexibleStringExpander targetWindowExdr; > protected List<WidgetWorker.Parameter> parameterList = FastList.newInstance(); > > + protected boolean requestConfirmation = false; > + protected FlexibleStringExpander confirmationMsgExdr; > protected HyperlinkField() { > super(); > } > @@ -2258,7 +2261,8 @@ > this.targetType = element.getAttribute("target-type"); > this.targetWindowExdr = FlexibleStringExpander.getInstance(element.getAttribute("target- window")); > this.image = element.getAttribute("image-location"); > - > + this .setRequestConfirmation("true".equals(element.getAttribute("request- confirmation"))); > + this.setConfirmationMsg(element.getAttribute("confirmation-message")); > List<? extends Element> parameterElementList = UtilXml.childElementList(element, "parameter"); > for (Element parameterElement: parameterElementList) { > this.parameterList.add(new WidgetWorker.Parameter(parameterElement)); > @@ -2273,7 +2277,28 @@ > public boolean getAlsoHidden() { > return this.alsoHidden; > } > + > + public boolean getRequestConfirmation() { > + return this.requestConfirmation; > + } > > + public String getConfirmation(Map<String, Object> context) { > + String message = getConfirmationMsg(context); > + if (UtilValidate.isNotEmpty(message)) { > + return message; > + } > + else if (getRequestConfirmation()) { > + String defaultMessage = UtilProperties.getPropertyValue("general", "default.confirmation.message", > "${uiLabelMap.CommonConfirm}"); > + setConfirmationMsg(defaultMessage); > + return getConfirmationMsg(context); > + } > + return ""; > + } > + > + public String getConfirmationMsg(Map<String, Object> context) { > + return this.confirmationMsgExdr.expandString(context); > + } > + > public String getLinkType() { > return this.linkType; > } > @@ -2334,6 +2359,14 @@ > public void setTarget(String string) { > this.target = FlexibleStringExpander.getInstance(string); > } > + > + public void setRequestConfirmation(boolean val) { > + this.requestConfirmation = val; > + } > + > + public void setConfirmationMsg(String val) { > + this.confirmationMsgExdr = FlexibleStringExpander.getInstance(val); > + } > } > > public static class SubHyperlink { > @@ -2345,6 +2378,8 @@ > protected FlexibleStringExpander description; > protected FlexibleStringExpander targetWindowExdr; > protected List<WidgetWorker.Parameter> parameterList = FastList.newInstance(); > + protected boolean requestConfirmation = false; > + protected FlexibleStringExpander confirmationMsgExdr; > protected ModelFormField modelFormField; > > public SubHyperlink(Element element, ModelFormField modelFormField) { > @@ -2355,15 +2390,16 @@ > this.linkStyle = element.getAttribute("link-style"); > this.targetType = element.getAttribute("target-type"); > this.targetWindowExdr = FlexibleStringExpander.getInstance(element.getAttribute("target- window")); > - > List<? extends Element> parameterElementList = UtilXml.childElementList(element, "parameter"); > for (Element parameterElement: parameterElementList) { > this.parameterList.add(new WidgetWorker.Parameter(parameterElement)); > } > + setRequestConfirmation("true".equals(element.getAttribute("request- confirmation"))); > + setConfirmationMsg(element.getAttribute("confirmation- message")); > > this.modelFormField = modelFormField; > } > - > + > public String getLinkStyle() { > return this.linkStyle; > } > @@ -2412,7 +2448,28 @@ > return ""; > } > } > - > + > + public boolean getRequestConfirmation() { > + return this.requestConfirmation; > + } > + > + public String getConfirmationMsg(Map<String, Object> context) { > + return this.confirmationMsgExdr.expandString(context); > + } > + > + public String getConfirmation(Map<String, Object> context) { > + String message = getConfirmationMsg(context); > + if (UtilValidate.isNotEmpty(message)) { > + return message; > + } > + else if (getRequestConfirmation()) { > + String defaultMessage = UtilProperties.getPropertyValue("general", "default.confirmation.message", > "${uiLabelMap.CommonConfirm}"); > + setConfirmationMsg(defaultMessage); > + return getConfirmationMsg(context); > + } > + return ""; > + } > + > public ModelFormField getModelFormField() { > return this.modelFormField; > } > @@ -2480,6 +2537,14 @@ > */ > public void setUseWhen(String string) { > this.useWhen = FlexibleStringExpander.getInstance(string); > + } > + > + public void setRequestConfirmation(boolean val) { > + this.requestConfirmation = val; > + } > + > + public void setConfirmationMsg(String val) { > + this.confirmationMsgExdr = FlexibleStringExpander.getInstance(val); > } > } > > @@ -3112,6 +3177,8 @@ > protected String buttonType; > protected String imageLocation; > protected FlexibleStringExpander backgroundSubmitRefreshTargetExdr; > + protected boolean requestConfirmation = false; > + protected FlexibleStringExpander confirmationMsgExdr; > > protected SubmitField() { > super(); > @@ -3130,7 +3197,9 @@ > this.buttonType = element.getAttribute("button-type"); > this.imageLocation = element.getAttribute("image- location"); > this.backgroundSubmitRefreshTargetExdr = FlexibleStringExpander.getInstance(element.getAttribute("background- > submit-refresh-target")); > - } > + setRequestConfirmation("true".equals(element.getAttribute("request- confirmation"))); > + setConfirmationMsg(element.getAttribute("confirmation- message")); > + } > > @Override > public void renderFieldString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) > throws IOException { > @@ -3143,8 +3212,29 @@ > > public String getImageLocation() { > return imageLocation; > - } > + } > > + public boolean getRequestConfirmation() { > + return this.requestConfirmation; > + } > + > + public String getConfirmationMsg(Map<String, Object> context) { > + return this.confirmationMsgExdr.expandString(context); > + } > + > + public String getConfirmation(Map<String, Object> context) { > + String message = getConfirmationMsg(context); > + if (UtilValidate.isNotEmpty(message)) { > + return message; > + } > + else if (getRequestConfirmation()) { > + String defaultMessage = UtilProperties.getPropertyValue("general", "default.confirmation.message", > "${uiLabelMap.CommonConfirm}"); > + setConfirmationMsg(defaultMessage); > + return getConfirmationMsg(context); > + } > + return ""; > + } > + > /** > * @param string > */ > @@ -3161,7 +3251,16 @@ > > public String getBackgroundSubmitRefreshTarget(Map<String, Object> context) { > return this.backgroundSubmitRefreshTargetExdr.expandString(context); > + } > + > + public void setRequestConfirmation(boolean val) { > + this.requestConfirmation = val; > + } > + > + public void setConfirmationMsg(String val) { > + this.confirmationMsgExdr = FlexibleStringExpander.getInstance(val); > } > + > } > > public static class ResetField extends FieldInfo { > > Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ HtmlFormRenderer.java > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=815734&r1=815733&r2=815734&view=diff > = = = = = = = = ====================================================================== > --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ HtmlFormRenderer.java (original) > +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/ HtmlFormRenderer.java Wed Sep 16 12:16:03 2009 > @@ -331,11 +331,9 @@ > public void renderHyperlinkField(Appendable writer, Map<String, Object> context, HyperlinkField hyperlinkField) throws > IOException { > this.request.setAttribute("image", hyperlinkField.getImage()); > ModelFormField modelFormField = hyperlinkField.getModelFormField(); > - > WidgetWorker.makeHyperlinkByType(writer, hyperlinkField.getLinkType(), modelFormField.getWidgetStyle(), > hyperlinkField.getTargetType(), hyperlinkField.getTarget(context), > - hyperlinkField.getParameterList(), hyperlinkField.getDescription(context), > hyperlinkField.getTargetWindow(context), modelFormField, > - this.request, this.response, context); > - > + hyperlinkField.getParameterList(), hyperlinkField.getDescription(context), > hyperlinkField.getTargetWindow(context), hyperlinkField.getConfirmation(context), modelFormField, > + this.request, this.response, context); > this.appendTooltip(writer, context, modelFormField); > //appendWhitespace(writer); > } > @@ -343,12 +341,12 @@ > public void makeHyperlinkString(Appendable writer, ModelFormField.SubHyperlink subHyperlink, Map<String, Object> context) > throws IOException { > if (subHyperlink == null) { > return; > - } > + } > if (subHyperlink.shouldUse(context)) { > writer.append(' '); > WidgetWorker.makeHyperlinkByType(writer, subHyperlink.getLinkType(), subHyperlink.getLinkStyle(), > subHyperlink.getTargetType(), subHyperlink.getTarget(context), > - subHyperlink.getParameterList(), subHyperlink.getDescription(context), > subHyperlink.getTargetWindow(context), subHyperlink.getModelFormField(), > - this.request, this.response, context); > + subHyperlink.getParameterList(), subHyperlink.getDescription(context), > subHyperlink.getTargetWindow(context), subHyperlink.getConfirmation(context), subHyperlink.getModelFormField(), > + this.request, this.response, context); > } > } > > @@ -1041,12 +1039,18 @@ > ModelForm modelForm = modelFormField.getModelForm(); > String event = null; > String action = null; > + String confirmation = submitField.getConfirmation(context); > > if ("text-link".equals(submitField.getButtonType())) { > writer.append("<a"); > > appendClassNames(writer, context, modelFormField); > - > + if (UtilValidate.isNotEmpty(confirmation)) { > + writer.append("onClick=\" return confirm('"); > + writer.append(confirmation); > + writer.append("); \" "); > + } > + > writer.append(" href=\"javascript:document."); > writer.append(modelForm.getCurrentFormName(context)); > writer.append(".submit()\">"); > @@ -1083,6 +1087,12 @@ > writer.append(action); > writer.append('"'); > } > + > + if (UtilValidate.isNotEmpty(confirmation)) { > + writer.append("onClick=\" return confirm('"); > + writer.append(confirmation); > + writer.append("); \" "); > + } > > writer.append("/>"); > } else { > @@ -1136,6 +1146,11 @@ > > if (ajaxEnabled) { > writer.append(" onclick=\""); > + if (UtilValidate.isNotEmpty(confirmation)) { > + writer.append("if (confirm('"); > + writer.append(confirmation); > + writer.append(");) "); > + } > writer.append("ajaxSubmitFormUpdateAreas('"); > writer.append(formId); > writer.append("', '").append(createAjaxParamsFromUpdateAreas(updateAreas, null, context)); > @@ -2855,7 +2870,7 @@ > if (UtilValidate.isNotEmpty(targetBuffer.toString()) && > targetBuffer.toString().toLowerCase().startsWith("javascript:")) { > targetType="plain"; > } > - WidgetWorker.makeHyperlinkString(writer, modelFormField.getHeaderLinkStyle(), targetType, targetBuffer.toString(), > null, titleText, modelFormField, this.request, this.response, null, null); > + WidgetWorker.makeHyperlinkString(writer, modelFormField.getHeaderLinkStyle(), targetType, targetBuffer.toString(), > null, titleText, null, modelFormField, this.request, this.response, null, null); > } else if (modelFormField.isSortField()) { > renderSortField (writer, context, modelFormField, titleText); > } else if (modelFormField.isRowSubmit()) { > > 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=815734&r1=815733&r2=815734&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 Wed Sep 16 12:16:03 2009 > @@ -450,10 +450,11 @@ > } > > writer.append(" href=\""); > + String confirmationMsg = link.getConfirmation(context); > if ("hidden-form".equals(linkType)) { > - if (link.getRequestConfirmation()) { > + if (UtilValidate.isNotEmpty(confirmationMsg)) { > writer.append("javascript:confirmActionFormLink('"); > - writer.append(link.getConfirmationMsg(context)); > + writer.append(confirmationMsg); > writer.append("', '"); > writer.append(uniqueItemName); > writer.append("')"); > @@ -463,9 +464,9 @@ > writer.append(".submit()"); > } > } else { > - if (link.getRequestConfirmation()) { > + if (UtilValidate.isNotEmpty(confirmationMsg)) { > writer.append("javascript:confirmActionLink('"); > - writer.append(link.getConfirmationMsg(context)); > + writer.append(confirmationMsg); > writer.append("', '"); > WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), link.getParameterList(), > link.getPrefix(context), > link.getFullPath(), link.getSecure(), link.getEncode(), request, response, context); > > 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=815734&r1=815733&r2=815734&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 Wed Sep 16 12:16:03 2009 > @@ -32,6 +32,7 @@ > import org.ofbiz.base.util.StringUtil; > import org.ofbiz.base.util.UtilFormatOut; > import org.ofbiz.base.util.UtilMisc; > +import org.ofbiz.base.util.UtilProperties; > import org.ofbiz.base.util.UtilValidate; > import org.ofbiz.base.util.UtilXml; > import org.ofbiz.base.util.string.FlexibleStringExpander; > @@ -724,6 +725,19 @@ > return this.parameterList; > } > > + public String getConfirmation(Map<String, Object> context) { > + String message = getConfirmationMsg(context); > + if (UtilValidate.isNotEmpty(message)) { > + return message; > + } > + else if (getRequestConfirmation()) { > + String defaultMessage = UtilProperties.getPropertyValue("general", "default.confirmation.message", > "${uiLabelMap.CommonConfirm}"); > + setConfirmationMsg(defaultMessage); > + return getConfirmationMsg(context); > + } > + return ""; > + } > + > public boolean getRequestConfirmation() { > return this.requestConfirmation; > } > > Modified: ofbiz/trunk/framework/widget/templates/ htmlFormMacroLibrary.ftl > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=815734&r1=815733&r2=815734&view=diff > = = = = = = = = ====================================================================== > --- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original) > +++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Wed Sep 16 12:16:03 2009 > @@ -170,13 +170,13 @@ > </#list> > </#macro> > > -<#macro renderSubmitField buttonType className alert formName title name event action imgSrc containerId ajaxUrl> > +<#macro renderSubmitField buttonType className alert formName title name event action imgSrc confirmation containerId ajaxUrl> > <#if buttonType=="text-link"> > - <a <@renderClass className alert /> href="javascript:document.$ {formName}.submit()"><#if title?has_content>${title}</#if> </a> > + <a <@renderClass className alert /> href="javascript:document.$ {formName}.submit()" <#if > confirmation?has_content>onclick="return confirm('${confirmation}');"</#if>><#if title?has_content>${title}</ #if> </a> > <#elseif buttonType=="image"> > - <input type="image" src="${imgSrc}" <@renderClass className alert / > ><#if name?has_content> name="${name}"</#if><#if title?has_content> > alt="${title}"</#if><#if event?has_content> ${event}="${action}"</ #if> /> > + <input type="image" src="${imgSrc}" <@renderClass className alert / > ><#if name?has_content> name="${name}"</#if><#if title?has_content> > alt="${title}"</#if><#if event?has_content> ${event}="${action}"</ #if> <#if confirmation?has_content>onclick="return confirm('$ > {confirmation}');"</#if>/> > <#else> > -<input type="<#if containerId?has_content>button<#else>submit</ #if>" <@renderClass className alert /><#if name?exists> name="$ > {name}"</#if><#if title?has_content> value="${title}"</#if><#if event?has_content> ${event}="${action}"</#if><#if containerId? > has_content> onclick="ajaxSubmitFormUpdateAreas('${containerId}', '$ {ajaxUrl}')"</#if>/></#if> > +<input type="<#if containerId?has_content>button<#else>submit</ #if>" <@renderClass className alert /><#if name?exists> name="$ > {name}"</#if><#if title?has_content> value="${title}"</#if><#if event?has_content> ${event}="${action}"</#if><#if containerId? > has_content> onclick="<#if confirmation?has_content>if (confirm('$ {confirmation}')) > </#if>ajaxSubmitFormUpdateAreas('${containerId}', '${ajaxUrl}')"<#else><#if confirmation?has_content> onclick="return > confirm('${confirmation}');"</#if></#if>/></#if> > </#macro> > > <#macro renderResetField className alert name title> > @@ -469,5 +469,5 @@ > <#if requiredField=="true"><#if requiredStyle?has_content>*</#if></ #if> > </#macro> > <#macro makeHiddenFormLinkForm actionUrl name parameters targetWindow><form method="post" action="${actionUrl}" <#if > targetWindow?has_content>target="${targetWindow}"</#if> onsubmit="javascript:submitFormDisableSubmits(this)" name="$ > {name}"><#list parameters as parameter><input name="$ {parameter.name}" value="${parameter.value}" type="hidden"/></ > #list></form></#macro> > -<#macro makeHiddenFormLinkAnchor linkStyle hiddenFormName event action imgSrc description><a <#if linkStyle?has_content>class="$ > {linkStyle}"</#if> href="javascript:document.$ {hiddenFormName}.submit()"<#if action?has_content && event? has_content> > ${event}="${action}"</#if>><#if imgSrc?has_content><img src="${imgSrc}"/></#if>${description}</a></#macro> > -<#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc linkUrl targetWindow description><a <#if linkStyle? > has_content>class="${linkStyle}"</#if> href="${linkUrl}"<#if targetWindow?has_content> target="${targetWindow}"</#if><#if action? > has_content && event?has_content> ${event}="${action}"</#if>><#if imgSrc?has_content><img > src="${imgSrc}"/></#if>${description}</a></ #macro> > +<#macro makeHiddenFormLinkAnchor linkStyle hiddenFormName event action imgSrc description confirmation><a <#if linkStyle? > has_content>class="${linkStyle}"</#if> href="javascript:document.$ {hiddenFormName}.submit()"<#if action?has_content && event? > has_content> ${event}="${action}"</#if><#if confirmation? has_content> onclick="return confirm('${confirmation}')"</#if>><#if > imgSrc?has_content><img src="${imgSrc}"/></#if>${description}</a></ #macro> > +<#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc linkUrl targetWindow description confirmation><a <#if > linkStyle?has_content>class="${linkStyle}"</#if> href="$ {linkUrl}"<#if targetWindow?has_content> target="${targetWindow}"</ > #if><#if action?has_content && event?has_content> ${event}="$ {action}"</#if><#if confirmation?has_content> onclick="return > confirm('${confirmation}')"</#if>><#if imgSrc?has_content><img src="$ {imgSrc}"/></#if>${description}</a></#macro> > > |
Free forum by Nabble | Edit this page |