Jacques,
Coincidentally, I am trying to use the renderLookupField macro in a Freemarker template. Do you have any idea what all of the macro parameters are for? I am having a difficult time sorting out what arguments to pass to get it to work. -Adrian On 6/19/2011 9:59 PM, [hidden email] wrote: > 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> > > |
Administrator
|
Hi Adrian,
Why not using <@htmlTemplate.lookupField ? There are plenty of examples HTH Jacques Adrian Crum wrote: > Jacques, > > Coincidentally, I am trying to use the renderLookupField macro in a > Freemarker template. Do you have any idea what all of the macro > parameters are for? I am having a difficult time sorting out what > arguments to pass to get it to work. > > -Adrian > > > On 6/19/2011 9:59 PM, [hidden email] wrote: >> 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> |
Are you serious? That macro has the exact same parameters and they
aren't documented either. Actually, all that macro does is call the renderLookupField macro, so I don't understand why it's even there. I would prefer to use the same macro the widgets use for one very good reason that is made obvious in this commit: Those macros will be maintained, while the htmlTemplate macros will not. -Adrian On 6/20/2011 10:46 AM, Jacques Le Roux wrote: > Hi Adrian, > > Why not using <@htmlTemplate.lookupField ? There are plenty of examples > > HTH > > Jacques > > Adrian Crum wrote: >> Jacques, >> >> Coincidentally, I am trying to use the renderLookupField macro in a >> Freemarker template. Do you have any idea what all of the macro >> parameters are for? I am having a difficult time sorting out what >> arguments to pass to get it to work. >> >> -Adrian >> >> >> On 6/19/2011 9:59 PM, [hidden email] wrote: >>> 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> > > |
Administrator
|
Adrian Crum wrote:
> Are you serious? That macro has the exact same parameters and they > aren't documented either. Actually, all that macro does is call the > renderLookupField macro, so I don't understand why it's even there. No, it does some other important things, like setting default values (eg presentation="layer" width="" height="" position="topleft" fadeBackground="true"), etc. You should always use this macro if you don't want to experience issues. Because it's supposed to be the real root for lookup calls from ftl templates and bypassing it might cause issues in the future if we change parameters or their order, etc. > I would prefer to use the same macro the widgets use for one very good > reason that is made obvious in this commit: Those macros will be > maintained, while the htmlTemplate macros will not. This does not make sense, since <@htmlTemplate.lookupField calls <@renderLookupField, any changes in <@renderLookupField will be reflected in <@htmlTemplate.lookupField As you can see, for reasons explained above, the <@htmlTemplate.lookupField is the entry for lookups in ftl templates. And this is how it's supposed to be used, so far... Now for the documentation, most parameters are obvious if you look a bit at the existing examples. But yes, this could be better documented, I totally agree... Jacques > -Adrian > > On 6/20/2011 10:46 AM, Jacques Le Roux wrote: >> Hi Adrian, >> >> Why not using <@htmlTemplate.lookupField ? There are plenty of examples >> >> HTH >> >> Jacques >> >> Adrian Crum wrote: >>> Jacques, >>> >>> Coincidentally, I am trying to use the renderLookupField macro in a >>> Freemarker template. Do you have any idea what all of the macro >>> parameters are for? I am having a difficult time sorting out what >>> arguments to pass to get it to work. >>> >>> -Adrian >>> >>> >>> On 6/19/2011 9:59 PM, [hidden email] wrote: >>>> 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> |
On 6/20/2011 11:50 AM, Jacques Le Roux wrote:
> Adrian Crum wrote: >> Are you serious? That macro has the exact same parameters and they >> aren't documented either. Actually, all that macro does is call the >> renderLookupField macro, so I don't understand why it's even there. > > No, it does some other important things, like setting default values > (eg presentation="layer" width="" height="" position="topleft" > fadeBackground="true"), etc. You should always use this macro if you > don't want to experience issues. Because it's supposed to be the real > root for lookup calls from ftl templates and bypassing it might cause > issues in the future if we change parameters or their order, etc. > If those defaults were supplied in the renderLookupField macro, then we wouldn't need to have a macro calling a macro. All the htmlTemplate.ftl file does is cover up poor programming. >> I would prefer to use the same macro the widgets use for one very good >> reason that is made obvious in this commit: Those macros will be >> maintained, while the htmlTemplate macros will not. > > This does not make sense, since <@htmlTemplate.lookupField calls > <@renderLookupField, any changes in <@renderLookupField will be > reflected in <@htmlTemplate.lookupField > As you can see, for reasons explained above, the > <@htmlTemplate.lookupField is the entry for lookups in ftl templates. > And this is how it's supposed to be used, so far... So, I can call htmlTemplate.lookupField with lastViewName="MyLastView" and it will work? > > Now for the documentation, most parameters are obvious if you look a > bit at the existing examples. But yes, this could be better > documented, I totally agree... > > Jacques > > >> -Adrian >> >> On 6/20/2011 10:46 AM, Jacques Le Roux wrote: >>> Hi Adrian, >>> >>> Why not using <@htmlTemplate.lookupField ? There are plenty of examples >>> >>> HTH >>> >>> Jacques >>> >>> Adrian Crum wrote: >>>> Jacques, >>>> >>>> Coincidentally, I am trying to use the renderLookupField macro in a >>>> Freemarker template. Do you have any idea what all of the macro >>>> parameters are for? I am having a difficult time sorting out what >>>> arguments to pass to get it to work. >>>> >>>> -Adrian >>>> >>>> >>>> On 6/19/2011 9:59 PM, [hidden email] wrote: >>>>> 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> > > |
Administrator
|
Adrian Crum wrote:
> On 6/20/2011 11:50 AM, Jacques Le Roux wrote: >> Adrian Crum wrote: >>> Are you serious? That macro has the exact same parameters and they >>> aren't documented either. Actually, all that macro does is call the >>> renderLookupField macro, so I don't understand why it's even there. >> >> No, it does some other important things, like setting default values >> (eg presentation="layer" width="" height="" position="topleft" >> fadeBackground="true"), etc. You should always use this macro if you >> don't want to experience issues. Because it's supposed to be the real >> root for lookup calls from ftl templates and bypassing it might cause >> issues in the future if we change parameters or their order, etc. >> > > If those defaults were supplied in the renderLookupField macro, then we > wouldn't need to have a macro calling a macro. All the htmlTemplate.ftl > file does is cover up poor programming. I don't remember the exact reasons, but I guess it's history reasons. Moving from popup lookups to layered lookups has not been a walkover. I still think it was really worth it. We could change that if we think it's really worth it. I have not enough time for the moment, at least... >>> I would prefer to use the same macro the widgets use for one very good >>> reason that is made obvious in this commit: Those macros will be >>> maintained, while the htmlTemplate macros will not. >> >> This does not make sense, since <@htmlTemplate.lookupField calls >> <@renderLookupField, any changes in <@renderLookupField will be >> reflected in <@htmlTemplate.lookupField >> As you can see, for reasons explained above, the >> <@htmlTemplate.lookupField is the entry for lookups in ftl templates. >> And this is how it's supposed to be used, so far... > > So, I can call htmlTemplate.lookupField with lastViewName="MyLastView" > and it will work? I don't thinks so, there is not lastViewName parameter, what is it supposed to be? Why this question, do you think at something like formName? Then there are planty of examples of use, but I guess you would like to refer to a previous used form? Jacques >> >> Now for the documentation, most parameters are obvious if you look a >> bit at the existing examples. But yes, this could be better >> documented, I totally agree... >> >> Jacques >> >> >>> -Adrian >>> >>> On 6/20/2011 10:46 AM, Jacques Le Roux wrote: >>>> Hi Adrian, >>>> >>>> Why not using <@htmlTemplate.lookupField ? There are plenty of examples >>>> >>>> HTH >>>> >>>> Jacques >>>> >>>> Adrian Crum wrote: >>>>> Jacques, >>>>> >>>>> Coincidentally, I am trying to use the renderLookupField macro in a >>>>> Freemarker template. Do you have any idea what all of the macro >>>>> parameters are for? I am having a difficult time sorting out what >>>>> arguments to pass to get it to work. >>>>> >>>>> -Adrian >>>>> >>>>> >>>>> On 6/19/2011 9:59 PM, [hidden email] wrote: >>>>>> 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> |
On 6/20/2011 12:50 PM, Jacques Le Roux wrote:
> Adrian Crum wrote: >> On 6/20/2011 11:50 AM, Jacques Le Roux wrote: >>> Adrian Crum wrote: >>>> Are you serious? That macro has the exact same parameters and they >>>> aren't documented either. Actually, all that macro does is call the >>>> renderLookupField macro, so I don't understand why it's even there. >>> >>> No, it does some other important things, like setting default values >>> (eg presentation="layer" width="" height="" position="topleft" >>> fadeBackground="true"), etc. You should always use this macro if you >>> don't want to experience issues. Because it's supposed to be the real >>> root for lookup calls from ftl templates and bypassing it might cause >>> issues in the future if we change parameters or their order, etc. >>> >> >> If those defaults were supplied in the renderLookupField macro, then we >> wouldn't need to have a macro calling a macro. All the htmlTemplate.ftl >> file does is cover up poor programming. > > I don't remember the exact reasons, but I guess it's history reasons. > Moving from popup lookups to layered lookups has not been a walkover. > I still think it was really worth it. We could change that if we think > it's really worth it. I have not enough time for the moment, at least... > >>>> I would prefer to use the same macro the widgets use for one very good >>>> reason that is made obvious in this commit: Those macros will be >>>> maintained, while the htmlTemplate macros will not. >>> >>> This does not make sense, since <@htmlTemplate.lookupField calls >>> <@renderLookupField, any changes in <@renderLookupField will be >>> reflected in <@htmlTemplate.lookupField >>> As you can see, for reasons explained above, the >>> <@htmlTemplate.lookupField is the entry for lookups in ftl templates. >>> And this is how it's supposed to be used, so far... >> >> So, I can call htmlTemplate.lookupField with lastViewName="MyLastView" >> and it will work? > > I don't thinks so, there is not lastViewName parameter, what is it > supposed to be? Why this question, do you think at something like > formName? Then there are planty of examples of use, but I guess you > would like to refer to a previous used form? > You are missing the point. You asked me why I don't use the other macros. My answer was because the macros called by the widgets will be maintained, while the macros that call the macros will not, and this commit is an example. Because of this commit, the lastViewName parameter only works for the renderLookupField macro and not htmlTemplate.lookupField macro. In other words, this commit proves why I prefer to use the macros called by the widgets. > Jacques > > >>> >>> Now for the documentation, most parameters are obvious if you look a >>> bit at the existing examples. But yes, this could be better >>> documented, I totally agree... >>> >>> Jacques >>> >>> >>>> -Adrian >>>> >>>> On 6/20/2011 10:46 AM, Jacques Le Roux wrote: >>>>> Hi Adrian, >>>>> >>>>> Why not using <@htmlTemplate.lookupField ? There are plenty of >>>>> examples >>>>> >>>>> HTH >>>>> >>>>> Jacques >>>>> >>>>> Adrian Crum wrote: >>>>>> Jacques, >>>>>> >>>>>> Coincidentally, I am trying to use the renderLookupField macro in a >>>>>> Freemarker template. Do you have any idea what all of the macro >>>>>> parameters are for? I am having a difficult time sorting out what >>>>>> arguments to pass to get it to work. >>>>>> >>>>>> -Adrian >>>>>> >>>>>> >>>>>> On 6/19/2011 9:59 PM, [hidden email] wrote: >>>>>>> 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> > > |
In reply to this post by Adrian Crum-3
Adrian,
On Mon, Jun 20, 2011 at 11:32 AM, Adrian Crum < [hidden email]> wrote: > Are you serious? That macro has the exact same parameters and they aren't > documented either. Actually, all that macro does is call the > renderLookupField macro, so I don't understand why it's even there. > htmlTemplate.lookupField is there(I created it during ajax lookup implementation) to set some default values, otherwise you I had to call renderLookupField from other FTLs with 30 attributes. BUT I agree with you that it duplicates the code, could get easily outdated... I think default values should be set only in one place, preferably from renderLookupField macro itselft but not from MacroFormRenderer.java and htmlTemplate.ftl Bilgin > > I would prefer to use the same macro the widgets use for one very good > reason that is made obvious in this commit: Those macros will be maintained, > while the htmlTemplate macros will not. > > -Adrian > > > On 6/20/2011 10:46 AM, Jacques Le Roux wrote: > >> Hi Adrian, >> >> Why not using <@htmlTemplate.lookupField ? There are plenty of examples >> >> HTH >> >> Jacques >> >> Adrian Crum wrote: >> >>> Jacques, >>> >>> Coincidentally, I am trying to use the renderLookupField macro in a >>> Freemarker template. Do you have any idea what all of the macro >>> parameters are for? I am having a difficult time sorting out what >>> arguments to pass to get it to work. >>> >>> -Adrian >>> >>> >>> On 6/19/2011 9:59 PM, [hidden email] wrote: >>> >>>> Author: jleroux >>>> Date: Sun Jun 19 20:59:35 2011 >>>> New Revision: 1137433 >>>> >>>> URL: http://svn.apache.org/viewvc?**rev=1137433&view=rev<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<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<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<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> >>>> >>> >> >> |
On 6/20/2011 1:52 PM, Bilgin Ibryam wrote:
> Adrian, > > On Mon, Jun 20, 2011 at 11:32 AM, Adrian Crum< > [hidden email]> wrote: > >> Are you serious? That macro has the exact same parameters and they aren't >> documented either. Actually, all that macro does is call the >> renderLookupField macro, so I don't understand why it's even there. >> > htmlTemplate.lookupField is there(I created it during ajax lookup > implementation) to set some default values, otherwise you I had to call > renderLookupField from other FTLs with 30 attributes. > BUT I agree with you that it duplicates the code, could get easily > outdated... > I think default values should be set only in one place, preferably from > renderLookupField macro itselft but not from MacroFormRenderer.java and > htmlTemplate.ftl > Cool. That is what I'm working toward. If we can agree on the parameters and their types, then we can supply defaults in the macro. Tah dah! Problem solved. > Bilgin > > > >> I would prefer to use the same macro the widgets use for one very good >> reason that is made obvious in this commit: Those macros will be maintained, >> while the htmlTemplate macros will not. >> >> -Adrian >> >> >> On 6/20/2011 10:46 AM, Jacques Le Roux wrote: >> >>> Hi Adrian, >>> >>> Why not using<@htmlTemplate.lookupField ? There are plenty of examples >>> >>> HTH >>> >>> Jacques >>> >>> Adrian Crum wrote: >>> >>>> Jacques, >>>> >>>> Coincidentally, I am trying to use the renderLookupField macro in a >>>> Freemarker template. Do you have any idea what all of the macro >>>> parameters are for? I am having a difficult time sorting out what >>>> arguments to pass to get it to work. >>>> >>>> -Adrian >>>> >>>> >>>> On 6/19/2011 9:59 PM, [hidden email] wrote: >>>> >>>>> Author: jleroux >>>>> Date: Sun Jun 19 20:59:35 2011 >>>>> New Revision: 1137433 >>>>> >>>>> URL: http://svn.apache.org/viewvc?**rev=1137433&view=rev<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<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<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<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> >>>>> >>> |
Administrator
|
In reply to this post by Adrian Crum-3
Adrian Crum wrote:
> On 6/20/2011 12:50 PM, Jacques Le Roux wrote: >> Adrian Crum wrote: >>> On 6/20/2011 11:50 AM, Jacques Le Roux wrote: >>>> Adrian Crum wrote: >>>>> Are you serious? That macro has the exact same parameters and they >>>>> aren't documented either. Actually, all that macro does is call the >>>>> renderLookupField macro, so I don't understand why it's even there. >>>> >>>> No, it does some other important things, like setting default values >>>> (eg presentation="layer" width="" height="" position="topleft" >>>> fadeBackground="true"), etc. You should always use this macro if you >>>> don't want to experience issues. Because it's supposed to be the real >>>> root for lookup calls from ftl templates and bypassing it might cause >>>> issues in the future if we change parameters or their order, etc. >>>> >>> >>> If those defaults were supplied in the renderLookupField macro, then we >>> wouldn't need to have a macro calling a macro. All the htmlTemplate.ftl >>> file does is cover up poor programming. >> >> I don't remember the exact reasons, but I guess it's history reasons. >> Moving from popup lookups to layered lookups has not been a walkover. >> I still think it was really worth it. We could change that if we think >> it's really worth it. I have not enough time for the moment, at least... >> >>>>> I would prefer to use the same macro the widgets use for one very good >>>>> reason that is made obvious in this commit: Those macros will be >>>>> maintained, while the htmlTemplate macros will not. >>>> >>>> This does not make sense, since <@htmlTemplate.lookupField calls >>>> <@renderLookupField, any changes in <@renderLookupField will be >>>> reflected in <@htmlTemplate.lookupField >>>> As you can see, for reasons explained above, the >>>> <@htmlTemplate.lookupField is the entry for lookups in ftl templates. >>>> And this is how it's supposed to be used, so far... >>> >>> So, I can call htmlTemplate.lookupField with lastViewName="MyLastView" >>> and it will work? >> >> I don't thinks so, there is not lastViewName parameter, what is it >> supposed to be? Why this question, do you think at something like >> formName? Then there are planty of examples of use, but I guess you >> would like to refer to a previous used form? >> > > You are missing the point. You asked me why I don't use the other > macros. My answer was because the macros called by the widgets will be > maintained, while the macros that call the macros will not, and this > commit is an example. Because of this commit, the lastViewName parameter > only works for the renderLookupField macro and not > htmlTemplate.lookupField macro. In other words, this commit proves why I > prefer to use the macros called by the widgets. > Yes, sorry I was buzy on something else and missed the relation with the current thread. The other way is right also. I have seen cases where people were using the renderLookupField directly and we had changed something in htmlTemplate.lookupField macro they missed. Jacques >> Jacques >> >> >>>> >>>> Now for the documentation, most parameters are obvious if you look a >>>> bit at the existing examples. But yes, this could be better >>>> documented, I totally agree... >>>> >>>> Jacques >>>> >>>> >>>>> -Adrian >>>>> >>>>> On 6/20/2011 10:46 AM, Jacques Le Roux wrote: >>>>>> Hi Adrian, >>>>>> >>>>>> Why not using <@htmlTemplate.lookupField ? There are plenty of >>>>>> examples >>>>>> >>>>>> HTH >>>>>> >>>>>> Jacques >>>>>> >>>>>> Adrian Crum wrote: >>>>>>> Jacques, >>>>>>> >>>>>>> Coincidentally, I am trying to use the renderLookupField macro in a >>>>>>> Freemarker template. Do you have any idea what all of the macro >>>>>>> parameters are for? I am having a difficult time sorting out what >>>>>>> arguments to pass to get it to work. >>>>>>> >>>>>>> -Adrian >>>>>>> >>>>>>> >>>>>>> On 6/19/2011 9:59 PM, [hidden email] wrote: >>>>>>>> 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> |
Administrator
|
In reply to this post by Adrian Crum-3
From: "Adrian Crum" <[hidden email]>
> On 6/20/2011 1:52 PM, Bilgin Ibryam wrote: >> Adrian, >> >> On Mon, Jun 20, 2011 at 11:32 AM, Adrian Crum< >> [hidden email]> wrote: >> >>> Are you serious? That macro has the exact same parameters and they aren't >>> documented either. Actually, all that macro does is call the >>> renderLookupField macro, so I don't understand why it's even there. >>> >> htmlTemplate.lookupField is there(I created it during ajax lookup >> implementation) to set some default values, otherwise you I had to call >> renderLookupField from other FTLs with 30 attributes. >> BUT I agree with you that it duplicates the code, could get easily >> outdated... >> I think default values should be set only in one place, preferably from >> renderLookupField macro itselft but not from MacroFormRenderer.java and >> htmlTemplate.ftl >> > > Cool. That is what I'm working toward. If we can agree on the parameters and their types, then we can supply defaults in the > macro. Tah dah! Problem solved. There is also all these calls in OOTB FTL templates... Jacques > >> Bilgin >> >> >> >>> I would prefer to use the same macro the widgets use for one very good >>> reason that is made obvious in this commit: Those macros will be maintained, >>> while the htmlTemplate macros will not. >>> >>> -Adrian >>> >>> >>> On 6/20/2011 10:46 AM, Jacques Le Roux wrote: >>> >>>> Hi Adrian, >>>> >>>> Why not using<@htmlTemplate.lookupField ? There are plenty of examples >>>> >>>> HTH >>>> >>>> Jacques >>>> >>>> Adrian Crum wrote: >>>> >>>>> Jacques, >>>>> >>>>> Coincidentally, I am trying to use the renderLookupField macro in a >>>>> Freemarker template. Do you have any idea what all of the macro >>>>> parameters are for? I am having a difficult time sorting out what >>>>> arguments to pass to get it to work. >>>>> >>>>> -Adrian >>>>> >>>>> >>>>> On 6/19/2011 9:59 PM, [hidden email] wrote: >>>>> >>>>>> Author: jleroux >>>>>> Date: Sun Jun 19 20:59:35 2011 >>>>>> New Revision: 1137433 >>>>>> >>>>>> URL: http://svn.apache.org/viewvc?**rev=1137433&view=rev<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<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<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<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> >>>>>> >>>> |
Free forum by Nabble | Edit this page |