You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by er...@apache.org on 2012/06/05 21:10:38 UTC
svn commit: r1346538 - in /ofbiz/branches/20120329_portletWidget/framework:
images/webapp/images/ widget/dtd/ widget/src/org/ofbiz/widget/form/
widget/templates/
Author: erwan
Date: Tue Jun 5 19:10:37 2012
New Revision: 1346538
URL: http://svn.apache.org/viewvc?rev=1346538&view=rev
Log:
Adding OFBIZ-4891 to portlet widget branch
Modified:
ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/selectall.js
ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-form.xsd
ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
ofbiz/branches/20120329_portletWidget/framework/widget/templates/htmlFormMacroLibrary.ftl
Modified: ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/selectall.js
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/selectall.js?rev=1346538&r1=1346537&r2=1346538&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/selectall.js (original)
+++ ofbiz/branches/20120329_portletWidget/framework/images/webapp/images/selectall.js Tue Jun 5 19:10:37 2012
@@ -845,6 +845,21 @@ function waitSpinnerHide() {
jQuery("#wait-spinner").hide()
}
+// #Bam# validate-form
+function clickLink(linkDivId) {
+ var div = document.getElementById(linkDivId);
+ if(!div ) return;
+ var aNodeList = div.getElementsByTagName("A");
+ link = aNodeList.item(0);
+ target =link.href;
+ if(target.match(new RegExp("javascript:.*"))){
+ eval(target);
+ } else {
+ window.location.href = target;
+ }
+}
+// #Eam# validate-form
+
/**
* Reads the requiered uiLabels from the uiLabelXml Files
* @param requiredLabels JSON Object {resource : [label1, label2 ...], resource2 : [label1, label2, ...]}
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-form.xsd
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-form.xsd?rev=1346538&r1=1346537&r2=1346538&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-form.xsd Tue Jun 5 19:10:37 2012
@@ -230,6 +230,19 @@ under the License.
</xs:annotation>
</xs:attribute>
-->
+ <xs:attribute name="validate-link-on-enter" default="false">
+ <xs:annotation><xs:documentation>in some case, a single form doest not include a submit button, instead it includes an hypperlink. setting this attribute to true wil result in click on the link when enter button is pressed on any form other input</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="validate-link-id" default="submit">
+ <xs:annotation><xs:documentation>in some case, a single form doest not include a submit button, instead it includes an hypperlink. setting this attribute to true wil result in click on the link when enter button is pressed on any form other input</xs:documentation></xs:annotation>
+ </xs:attribute>
+
</xs:attributeGroup>
<xs:element name="alt-target">
<xs:complexType>
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=1346538&r1=1346537&r2=1346538&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Tue Jun 5 19:10:37 2012
@@ -334,6 +334,7 @@ public class MacroFormRenderer implement
public void renderTextField(Appendable writer, Map<String, Object> context, TextField textField) throws IOException {
ModelFormField modelFormField = textField.getModelFormField();
String name = modelFormField.getParameterName(context);
+ boolean validateLinkOnEnter = modelFormField.getModelForm().getValidateLinkOnEnter(); // #Eam# validate-form
String className = "";
String alert = "false";
String mask = "";
@@ -405,6 +406,18 @@ public class MacroFormRenderer implement
sr.append(" clientAutocomplete=\"");
sr.append(clientAutocomplete);
+ // #Bam# validate-form
+ if (validateLinkOnEnter) {
+ sr.append("\" validateLinkOnEnter=");
+ sr.append(Boolean.toString(validateLinkOnEnter));
+ sr.append(" validateLinkId=\"");
+ sr.append(modelFormField.getModelForm().getValidateLinkId());
+ } else{
+ sr.append("\" validateLinkOnEnter=");
+ sr.append(Boolean.toString(false));
+ sr.append(" validateLinkId=\"");
+ }
+ // #Eam# validate-form
sr.append("\" ajaxUrl=\"");
sr.append(ajaxUrl);
sr.append("\" ajaxEnabled=");
@@ -1759,6 +1772,7 @@ public class MacroFormRenderer implement
public void renderTextFindField(Appendable writer, Map<String, Object> context, TextFindField textFindField) throws IOException {
ModelFormField modelFormField = textFindField.getModelFormField();
+ boolean validateLinkOnEnter = modelFormField.getModelForm().getValidateLinkOnEnter(); // #Eam# validate-form
String defaultOption = textFindField.getDefaultOption();
String className = "";
String alert = "false";
@@ -1834,6 +1848,19 @@ public class MacroFormRenderer implement
sr.append(maxlength);
sr.append("\" autocomplete=\"");
sr.append(autocomplete);
+ // #Bam# validate-form
+ if (validateLinkOnEnter) {
+ sr.append("\" validateLinkOnEnter=");
+ sr.append(Boolean.toString(validateLinkOnEnter));
+ sr.append(" validateLinkId=\"");
+ sr.append(modelFormField.getModelForm().getValidateLinkId());
+ }
+ else {
+ sr.append("\" validateLinkOnEnter=");
+ sr.append(Boolean.toString(false));
+ sr.append(" validateLinkId=\"");
+ }
+ // #Eam# validate-form
sr.append("\" titleStyle=\"");
sr.append(titleStyle);
sr.append("\" hideIgnoreCase=");
@@ -3186,6 +3213,10 @@ public class MacroFormRenderer implement
sr.append(event);
sr.append("\" action=\"");
sr.append(action);
+ // #Bam# validate-form
+ sr.append("\" id=\"");
+ sr.append(modelFormField.getIdName());
+ // #Eam# validate-form
sr.append("\" imgSrc=\"");
sr.append(imgSrc);
sr.append("\" title=\"");
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=1346538&r1=1346537&r2=1346538&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelForm.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Tue Jun 5 19:10:37 2012
@@ -89,6 +89,7 @@ public class ModelForm extends ModelWidg
protected String tooltip;
protected String listName;
protected String listEntryName;
+ protected String validateLinkId; // #Eam# validateForm
protected FlexibleMapAccessor<Map<String, ? extends Object>> defaultMapName;
protected String defaultEntityName;
protected String defaultServiceName;
@@ -115,6 +116,7 @@ public class ModelForm extends ModelWidg
protected boolean separateColumns = false;
protected boolean groupColumns = true;
protected boolean useRowSubmit = false;
+ protected boolean validateLinkOnEnter = false; // #Eam# validateForm
protected FlexibleStringExpander targetWindowExdr;
protected String defaultRequiredFieldStyle;
protected String defaultSortFieldStyle;
@@ -273,6 +275,7 @@ public class ModelForm extends ModelWidg
this.tooltip = parent.tooltip;
this.listName = parent.listName;
this.listEntryName = parent.listEntryName;
+ this.validateLinkId = parent.validateLinkId;// #Eam# validateForm
this.tooltip = parent.tooltip;
this.defaultEntityName = parent.defaultEntityName;
this.defaultServiceName = parent.defaultServiceName;
@@ -487,6 +490,15 @@ public class ModelForm extends ModelWidg
this.rowCountExdr = FlexibleStringExpander.getInstance(formElement.getAttribute("row-count"));
}
+ //#Bam# : validateForm
+ if (this.validateLinkId == null || formElement.hasAttribute("validate-link-id")) {
+ this.validateLinkId = formElement.getAttribute("validate-link-id");
+ }
+ if ( formElement.hasAttribute("validate-link-on-enter")) {
+ this.validateLinkOnEnter = "true".equalsIgnoreCase(formElement.getAttribute("validate-link-on-enter"));
+ }
+ //#Eam# : validateForm
+
//alt-row-styles
for (Element altRowStyleElement : UtilXml.childElementList(formElement, "alt-row-style")) {
AltRowStyle altRowStyle = new AltRowStyle(altRowStyleElement);
@@ -2728,6 +2740,16 @@ public class ModelForm extends ModelWidg
return this.useRowSubmit;
}
+ //#Bam# : validateForm
+ public boolean getValidateLinkOnEnter() {
+ return this.validateLinkOnEnter;
+ }
+
+ public String getValidateLinkId() {
+ return this.validateLinkId;
+ }
+ //#Eam# : validateForm
+
public List<ModelFormField> getMultiSubmitFields() {
return this.multiSubmitFields;
}
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=1346538&r1=1346537&r2=1346538&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/templates/htmlFormMacroLibrary.ftl Tue Jun 5 19:10:37 2012
@@ -55,7 +55,11 @@ under the License.
<a <#if linkStyle?has_content>class="${linkStyle}"</#if> href='javascript:refrshPortlet("${target}", "${areaId}", "${params}", "${formName}", "${appendFormParams}", "${collapse}", <#if (collapse== "true" || markSelected=="true" ) && id?has_content>"${id}_div"<#else>""</#if>,"${markSelected}" )' <#if action?has_content && event?has_content> ${event}="${action}"</#if><#if imgSrc?length == 0 && title?has_content> title="${title}"</#if>><#if imgSrc?has_content><img src="${imgSrc}" alt="${alternate}" title="${title}"/></#if>${description}</a><#if id?has_content></div></#if>
</#macro>
+<#--#Bam# validate-form
<#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete ajaxUrl ajaxEnabled mask>
+-->
+<#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete validateLinkOnEnter validateLinkId ajaxUrl ajaxEnabled mask>
+<#--#Eam# validate-form -->
<#if mask?has_content>
<script type="text/javascript">
jQuery(function($){jQuery("#${id}").mask("${mask}");});
@@ -68,6 +72,7 @@ under the License.
<#if maxlength?has_content> maxlength="${maxlength}"</#if><#rt/>
<#if disabled?has_content && disabled> disabled="disabled"</#if><#rt/>
<#if id?has_content> id="${id}"</#if><#rt/>
+ <#if validateLinkOnEnter?has_content && validateLinkOnEnter && validateLinkId?has_content>onkeydown="if ((window.event && window.event.keyCode == 13) || (event && event.keyCode == 13)) clickLink('${validateLinkId}_div')"</#if> <#--#Eam# validate-form -->
<#if event?has_content && action?has_content> ${event}="${action}"</#if><#rt/>
<#if clientAutocomplete?has_content && clientAutocomplete=="false"> autocomplete="off"</#if><#rt/>
/><#t/>
@@ -448,7 +453,11 @@ ${item.description}</span>
<#macro renderFormatEmptySpace> </#macro>
+<#--#Bam# validate-form
<#macro renderTextFindField name value defaultOption opEquals opBeginsWith opContains opIsEmpty opNotEqual className alert size maxlength autocomplete titleStyle hideIgnoreCase ignCase ignoreCase>
+-->
+<#macro renderTextFindField name value defaultOption opEquals opBeginsWith opContains opIsEmpty opNotEqual className alert size maxlength autocomplete validateLinkOnEnter validateLinkId titleStyle hideIgnoreCase ignCase ignoreCase>
+<#--#Eam# validate-form -->
<#if opEquals?has_content>
<select <#if name?has_content>name="${name}_op"</#if> class="selectBox"><#rt/>
<option value="equals"<#if defaultOption=="equals"> selected="selected"</#if>>${opEquals}</option><#rt/>
@@ -460,7 +469,11 @@ ${item.description}</span>
<#else>
<input type="hidden" name=<#if name?has_content> "${name}_op"</#if> value="${defaultOption}"/><#rt/>
</#if>
+<#--#Bam# validate-form
<input type="text" <@renderClass className alert /> name="${name}"<#if value?has_content> value="${value}"</#if><#if size?has_content> size="${size}"</#if><#if maxlength?has_content> maxlength="${maxlength}"</#if><#if autocomplete?has_content> autocomplete="off"</#if>/><#rt/>
+-->
+ <input type="text" <@renderClass className alert /> <#if validateLinkOnEnter?has_content && validateLinkOnEnter && validateLinkId?has_content>onkeydown="if ((window.event && window.event.keyCode == 13) || (event && event.keyCode == 13)) clickLink('${validateLinkId}_div')"</#if> name="${name}"<#if value?has_content> value="${value}"</#if><#if size?has_content> size="${size}"</#if><#if maxlength?has_content> maxlength="${maxlength}"</#if><#if autocomplete?has_content> autocomplete="off"</#if>/><#rt/>
+<#--#Eam# validate-form -->
<#if titleStyle?has_content><span class="${titleStyle}" ><#rt/></#if>
<#if hideIgnoreCase>
<input type="hidden" name="${name}_ic" value=<#if ignCase>"Y"<#else> ""</#if>/><#rt/>
@@ -760,4 +773,8 @@ Parameter: lastViewName, String, optiona
<#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 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?js_string}')"</#if>><#if imgSrc?has_content><img src="${imgSrc}" alt=""/></#if>${description}</a></#macro>
+<#--#Bam# validate-form
<#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc title alternate 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?js_string}')"</#if><#if imgSrc?length == 0 && title?has_content> title="${title}"</#if>><#if imgSrc?has_content><img src="${imgSrc}" alt="${alternate}" title="${title}"/></#if>${description}</a></#macro>
+-->
+<#macro makeHyperlinkString linkStyle hiddenFormName event action id imgSrc title alternate linkUrl targetWindow description confirmation><#if id?has_content><div id="${id}_div"></#if><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?js_string}')"</#if><#if imgSrc?length == 0 && title?has_content> title="${title}"</#if>><#if imgSrc?has_content><img src="${imgSrc}" alt="${alternate}" title="${title}"/></#if>${description}</a><#if id?has_content></div></#if></#macro>
+<#--#Eam# validate-form -->