Author: jleroux
Date: Sun Jun 19 20:59:35 2011
New Revision: 1137433
URL: http://svn.apache.org/viewvc?rev=1137433&view=rev
Log:
A patch from Leon<<"setUserPreference" goes to main page instead
last view if current form includes any lookup field>>
https://issues.apache.org/jira/browse/OFBIZ-4313 When I open a form
which include lookup field and then click the expand/collapse button
around the upper right corner in the the
header, the page will go to "main" after user preference is settled.
The cause is the requests initiated by lookup field does not
remember the last view name. It simply use "main" instead.
Patch to make lookup requests remember the LAST_VIEW_NAME correctly.
Modified:
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
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=1137433&r1=1137432&r2=1137433&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
Sun Jun 19 20:59:35 2011 @@ -2149,6 +2149,14 @@
public class MacroFormRenderer implement boolean showDescription =
"Y".equals(UtilProperties.getPropertyValue("widget",
"widget.lookup.showDescription", "N"));
+ // lastViewName, used by lookup to remember the real last
view name
+ String lastViewName =
request.getParameter("_LAST_VIEW_NAME_"); // Try to get it from
parameters firstly
+ if (UtilValidate.isEmpty(lastViewName)) { // get from
session
+ lastViewName = (String)
request.getSession().getAttribute("_LAST_VIEW_NAME_");
+ }
+ if (UtilValidate.isEmpty(lastViewName)) {
+ lastViewName = "";
+ }
StringWriter sr = new StringWriter();
sr.append("<@renderLookupField ");
sr.append(" className=\"");
@@ -2208,6 +2216,8 @@ public class MacroFormRenderer implement
sr.append(Boolean.toString(showDescription));
sr.append("\" initiallyCollapsed=\"");
sr.append(Boolean.toString(isInitiallyCollapsed));
+ sr.append("\" lastViewName=\"");
+ sr.append(lastViewName);
sr.append("\" />");
executeMacro(writer, sr.toString());
Modified:
ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=1137433&r1=1137432&r2=1137433&view=diff
==============================================================================
---
ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
(original) +++
ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Sun
Jun 19 20:59:35 2011 @@ -543,7 +543,7 @@
${item.description}</span> </#if>
</#macro>
-<#macro renderLookupField className alert name value size maxlength
id event action readonly autocomplete descriptionFieldName
formName fieldFormName targetParameterIter imgSrc ajaxUrl
ajaxEnabled presentation width height position fadeBackground
clearText showDescription initiallyCollapsed> +<#macro
renderLookupField className alert name value size maxlength id event
action readonly autocomplete descriptionFieldName formName
fieldFormName targetParameterIter imgSrc ajaxUrl ajaxEnabled
presentation width height position fadeBackground clearText
showDescription initiallyCollapsed lastViewName="main"> <#if
ajaxEnabled?has_content&& ajaxEnabled> <script
type="text/javascript"> jQuery(document).ready(function(){ @@
-575,11 +575,7 @@
${item.description}</span> <#if ajaxEnabled?has_content&&
ajaxEnabled>
<#assign defaultMinLength =
Static["org.ofbiz.base.util.UtilProperties"].getPropertyValue("widget.properties",
"widget.autocompleter.defaultMinLength")> <#assign
defaultDelay =
Static["org.ofbiz.base.util.UtilProperties"].getPropertyValue("widget.properties",
"widget.autocompleter.defaultDelay")> -<#if
parameters?has_content&& parameters._LAST_VIEW_NAME_?has_content>
-<#local ajaxUrl = ajaxUrl + "&_LAST_VIEW_NAME_=" +
parameters._LAST_VIEW_NAME_ />
-<#else>
-<#local ajaxUrl = ajaxUrl + "&_LAST_VIEW_NAME_=main"/>
-</#if>
+<#local ajaxUrl = ajaxUrl + "&_LAST_VIEW_NAME_=" +
lastViewName />
<#if !ajaxUrl?contains("searchValueFieldName=")>
<#if descriptionFieldName?has_content&& showDescription == "true">
<#local ajaxUrl = ajaxUrl + "&searchValueFieldName=" +
descriptionFieldName />
@@ -611,10 +607,8 @@ ${item.description}</span>
<#if readonly?has_content&& readonly><a id="${id}_clear"
style="background:none;margin-left:5px;margin-right:15px;"
class="clearField" href="javascript:void();"
onclick="javascript:document.${formName}.${name}.value='';<#if
descriptionFieldName?has_content>document.${formName}.${descriptionFieldName}.value='';</#if>">${clearText}</a></#if>
</span>
<#if ajaxEnabled?has_content&& ajaxEnabled> -<#if
parameters?has_content&& parameters._LAST_VIEW_NAME_?has_content&&
ajaxUrl?index_of("_LAST_VIEW_NAME_")< 0>
-<#local ajaxUrl = ajaxUrl + "&_LAST_VIEW_NAME_=" +
parameters._LAST_VIEW_NAME_ />
-<#elseif ajaxUrl?index_of("_LAST_VIEW_NAME_")< 0>
-<#local ajaxUrl = ajaxUrl + "&_LAST_VIEW_NAME_=main"/>
+<#if ajaxUrl?index_of("_LAST_VIEW_NAME_")< 0>
+<#local ajaxUrl = ajaxUrl + "&_LAST_VIEW_NAME_=" +
lastViewName />
</#if>
<script language="JavaScript"
type="text/javascript">ajaxAutoCompleter('${ajaxUrl}',
${showDescription},
${defaultMinLength!2}, ${defaultDelay!300});</script><#t/> </#if>