Adrian,

On Mon, Jun 20, 2011 at 11:32 AM, Adrian Crum <
[email protected]> 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, [email protected] 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 + "&amp;_LAST_VIEW_NAME_=" +
>>>> parameters._LAST_VIEW_NAME_ />
>>>> -<#else>
>>>> -<#local ajaxUrl = ajaxUrl + "&amp;_LAST_VIEW_NAME_=main"/>
>>>> -</#if>
>>>> +<#local ajaxUrl = ajaxUrl + "&amp;_LAST_VIEW_NAME_=" + lastViewName />
>>>> <#if !ajaxUrl?contains("**searchValueFieldName=")>
>>>> <#if descriptionFieldName?has_**content&&  showDescription == "true">
>>>> <#local ajaxUrl = ajaxUrl + "&amp;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 + "&amp;_LAST_VIEW_NAME_=" +
>>>> parameters._LAST_VIEW_NAME_ />
>>>> -<#elseif ajaxUrl?index_of("_LAST_VIEW_**NAME_")<  0>
>>>> -<#local ajaxUrl = ajaxUrl + "&amp;_LAST_VIEW_NAME_=main"/>
>>>> +<#if ajaxUrl?index_of("_LAST_VIEW_**NAME_")<  0>
>>>> +<#local ajaxUrl = ajaxUrl + "&amp;_LAST_VIEW_NAME_=" + lastViewName />
>>>> </#if>
>>>> <script language="JavaScript" type="text/javascript">**
>>>> ajaxAutoCompleter('${ajaxUrl}'**, ${showDescription},
>>>>  ${defaultMinLength!2}, ${defaultDelay!300});</script>**<#t/> </#if>
>>>>
>>>
>>
>>

Reply via email to