How to use labels that contains a period with in a ftl

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use labels that contains a period with in a ftl

Vikas Mayur-2
I come across to use a label checkhelper.select_shipping_destination defined
in OrderUiLabel in a ftl file.But this does not work the usual way
${uiLabelMap.checkhelper.select_shipping_destination}.

Is there a way to use these kind labels.

Thanks,
- Vikas
Reply | Threaded
Open this post in threaded view
|

Re: How to use labels that contains a period with in a ftl

David E Jones

Try:

${uiLabelMap.["checkhelper.select_shipping_destination"]}

But yeah, it is probably better to avoid periods in label names...

-David


On Jul 17, 2008, at 7:24 AM, Vikas Mayur wrote:

> I come across to use a label checkhelper.select_shipping_destination  
> defined
> in OrderUiLabel in a ftl file.But this does not work the usual way
> ${uiLabelMap.checkhelper.select_shipping_destination}.
>
> Is there a way to use these kind labels.
>
> Thanks,
> - Vikas

Reply | Threaded
Open this post in threaded view
|

Re: How to use labels that contains a period with in a ftl

Jacopo Cappellato-3
wow,

thanks David... I've learned something new today.

Jacopo

On Jul 17, 2008, at 3:31 PM, David E Jones wrote:

>
> Try:
>
> ${uiLabelMap.["checkhelper.select_shipping_destination"]}
>
> But yeah, it is probably better to avoid periods in label names...
>
> -David
>
>
> On Jul 17, 2008, at 7:24 AM, Vikas Mayur wrote:
>
>> I come across to use a label  
>> checkhelper.select_shipping_destination defined
>> in OrderUiLabel in a ftl file.But this does not work the usual way
>> ${uiLabelMap.checkhelper.select_shipping_destination}.
>>
>> Is there a way to use these kind labels.
>>
>> Thanks,
>> - Vikas
>


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to use labels that contains a period with in a ftl

Jacques Le Roux
Administrator
Voodoo :o)

Jacques

From: "Jacopo Cappellato" <[hidden email]>

> wow,
>
> thanks David... I've learned something new today.
>
> Jacopo
>
> On Jul 17, 2008, at 3:31 PM, David E Jones wrote:
>
>>
>> Try:
>>
>> ${uiLabelMap.["checkhelper.select_shipping_destination"]}
>>
>> But yeah, it is probably better to avoid periods in label names...
>>
>> -David
>>
>>
>> On Jul 17, 2008, at 7:24 AM, Vikas Mayur wrote:
>>
>>> I come across to use a label  
>>> checkhelper.select_shipping_destination defined
>>> in OrderUiLabel in a ftl file.But this does not work the usual way
>>> ${uiLabelMap.checkhelper.select_shipping_destination}.
>>>
>>> Is there a way to use these kind labels.
>>>
>>> Thanks,
>>> - Vikas
>>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to use labels that contains a period with in a ftl

Vikas Mayur-2
In reply to this post by David E Jones
Thanks David - but its not working at all. I am getting a parse exception
and freemarker editor is also showing an error.
- Vikas

On Thu, Jul 17, 2008 at 7:01 PM, David E Jones <[hidden email]>
wrote:

>
> Try:
>
> ${uiLabelMap.["checkhelper.select_shipping_destination"]}
>
> But yeah, it is probably better to avoid periods in label names...
>
> -David
>
>
>
> On Jul 17, 2008, at 7:24 AM, Vikas Mayur wrote:
>
>  I come across to use a label checkhelper.select_shipping_destination
>> defined
>> in OrderUiLabel in a ftl file.But this does not work the usual way
>> ${uiLabelMap.checkhelper.select_shipping_destination}.
>>
>> Is there a way to use these kind labels.
>>
>> Thanks,
>> - Vikas
>>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to use labels that contains a period with in a ftl

David E Jones

What is the parse error? Could you send over (using copy/paste) the  
exact text you used?

This definitely works when doing an #assign, and should work for  
string expansion in FTL as well...

-David


On Jul 17, 2008, at 7:46 AM, Vikas Mayur wrote:

> Thanks David - but its not working at all. I am getting a parse  
> exception
> and freemarker editor is also showing an error.
> - Vikas
>
> On Thu, Jul 17, 2008 at 7:01 PM, David E Jones <[hidden email]
> >
> wrote:
>
>>
>> Try:
>>
>> ${uiLabelMap.["checkhelper.select_shipping_destination"]}
>>
>> But yeah, it is probably better to avoid periods in label names...
>>
>> -David
>>
>>
>>
>> On Jul 17, 2008, at 7:24 AM, Vikas Mayur wrote:
>>
>> I come across to use a label checkhelper.select_shipping_destination
>>> defined
>>> in OrderUiLabel in a ftl file.But this does not work the usual way
>>> ${uiLabelMap.checkhelper.select_shipping_destination}.
>>>
>>> Is there a way to use these kind labels.
>>>
>>> Thanks,
>>> - Vikas
>>>
>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: How to use labels that contains a period with in a ftl

Bilgin Ibryam
In reply to this post by Vikas Mayur-2
On Thu, 2008-07-17 at 19:16 +0530, Vikas Mayur wrote:
> Thanks David - but its not working at all. I am getting a parse exception
> and freemarker editor is also showing an error.
> - Vikas
 
Try w/o dot:

${uiLabelMap["checkhelper.select_shipping_destination"]}

Bilgin

Reply | Threaded
Open this post in threaded view
|

Re: How to use labels that contains a period with in a ftl

Vikas Mayur-2
In reply to this post by David E Jones
I have used <td colspan="8"><h3>${uiLabelMap.[
"checkhelper.select_shipping_destination"]}</h3></td>

and following is the error log:

Error rendering included template at location
[component://order/webapp/ordermgr/return/quickReturn.ftl]:
freemarker.core.ParseException: Encountered "[" at line 70, column 48.
Was expecting one of:
    "false" ...
    "true" ...
    <LESS_THAN> ...
    <LESS_THAN_EQUALS> ...
    <ESCAPED_GT> ...
    <ESCAPED_GTE> ...
    "*" ...
    "**" ...
    "in" ...
    "as" ...
    "using" ...
    <ID> ...

Exception: freemarker.core.ParseException
Message: Encountered "[" at line 70, column 48.
Was expecting one of:
    "false" ...
    "true" ...
    <LESS_THAN> ...
    <LESS_THAN_EQUALS> ...
    <ESCAPED_GT> ...
    <ESCAPED_GTE> ...
    "*" ...
    "**" ...
    "in" ...
    "as" ...
    "using" ...
    <ID> ...

---- stack trace
---------------------------------------------------------------
freemarker.core.ParseException: Encountered "[" at line 70, column 48.
Was expecting one of:
    "false" ...
    "true" ...
    <LESS_THAN> ...
    <LESS_THAN_EQUALS> ...
    <ESCAPED_GT> ...
    <ESCAPED_GTE> ...
    "*" ...
    "**" ...
    "in" ...
    "as" ...
    "using" ...
    <ID> ...

freemarker.core.FMParser.generateParseException(FMParser.java:5244)
freemarker.core.FMParser.jj_consume_token(FMParser.java:5119)
freemarker.core.FMParser.DotVariable(FMParser.java:855)
freemarker.core.FMParser.AddSubExpression(FMParser.java:717)
freemarker.core.FMParser.PrimaryExpression(FMParser.java:273)
freemarker.core.FMParser.UnaryExpression(FMParser.java:319)
freemarker.core.FMParser.MultiplicativeExpression(FMParser.java:435)
freemarker.core.FMParser.AdditiveExpression(FMParser.java:385)
freemarker.core.FMParser.RangeExpression(FMParser.java:556)
freemarker.core.FMParser.RelationalExpression(FMParser.java:511)
freemarker.core.FMParser.EqualityExpression(FMParser.java:476)
freemarker.core.FMParser.AndExpression(FMParser.java:585)
freemarker.core.FMParser.OrExpression(FMParser.java:608)
freemarker.core.FMParser.Expression(FMParser.java:221)
freemarker.core.FMParser.StringOutput(FMParser.java:1048)
freemarker.core.FMParser.Content(FMParser.java:2531)
freemarker.core.FMParser.OptionalBlock(FMParser.java:2742)
freemarker.core.FMParser.Root(FMParser.java:2914)
freemarker.template.Template.<init>(Template.java:149)
freemarker.template.Template.<init>(Template.java:167)
org.ofbiz.base.util.template.FreeMarkerWorker.getTemplate(FreeMarkerWorker.java:271)
org.ofbiz.base.util.template.FreeMarkerWorker.renderTemplate(FreeMarkerWorker.java:162)
org.ofbiz.base.util.template.FreeMarkerWorker.renderTemplateAtLocation(FreeMarkerWorker.java:136)
org.ofbiz.widget.screen.HtmlWidget.renderHtmlTemplate(HtmlWidget.java:95)
org.ofbiz.widget.screen.HtmlWidget$HtmlTemplate.renderWidgetString(HtmlWidget.java:138)
org.ofbiz.widget.screen.HtmlWidget.renderWidgetString(HtmlWidget.java:67)
org.ofbiz.widget.screen.ModelScreenWidget$PlatformSpecific.renderWidgetString(ModelScreenWidget.java:996)
org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:141)
org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:228)
org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:141)
org.ofbiz.widget.screen.ModelScreenWidget$Container.renderWidgetString(ModelScreenWidget.java:294)
org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:141)
org.ofbiz.widget.screen.ModelScreenWidget$Container.renderWidgetString(ModelScreenWidget.java:294)
org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:141)
org.ofbiz.widget.screen.ModelScreenWidget$DecoratorSection.renderWidgetString(ModelScreenWidget.java:685)
org.ofbiz.widget.screen.ModelScreenWidget$SectionsRenderer.render(ModelScreenWidget.java:167)
org.ofbiz.widget.screen.ModelScreenWidget$DecoratorSectionInclude.renderWidgetString(ModelScreenWidget.java:716)
org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:141)
org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:228)
org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:141)
org.ofbiz.widget.screen.ModelScreenWidget$DecoratorSection.renderWidgetString(ModelScreenWidget.java:685)
org.ofbiz.widget.screen.ModelScreenWidget$SectionsRenderer.render(ModelScreenWidget.java:167)
org.ofbiz.widget.screen.ModelScreenWidget$DecoratorSectionInclude.renderWidgetString(ModelScreenWidget.java:716)
org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:141)
org.ofbiz.widget.screen.ModelScreenWidget$Container.renderWidgetString(ModelScreenWidget.java:294)
org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:141)
org.ofbiz.widget.screen.ModelScreenWidget$Container.renderWidgetString(ModelScreenWidget.java:294)
org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:141)
org.ofbiz.widget.screen.ModelScreenWidget$Container.renderWidgetString(ModelScreenWidget.java:294)
org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:141)
org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:228)
org.ofbiz.widget.screen.ModelScreen.renderScreenString(ModelScreen.java:393)
org.ofbiz.widget.screen.ModelScreenWidget$IncludeScreen.renderWidgetString(ModelScreenWidget.java:557)
org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:141)
org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:228)
org.ofbiz.widget.screen.ModelScreen.renderScreenString(ModelScreen.java:393)
org.ofbiz.widget.screen.ModelScreenWidget$DecoratorScreen.renderWidgetString(ModelScreenWidget.java:654)
org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:141)
org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:228)
org.ofbiz.widget.screen.ModelScreen.renderScreenString(ModelScreen.java:393)
org.ofbiz.widget.screen.ModelScreenWidget$DecoratorScreen.renderWidgetString(ModelScreenWidget.java:654)
org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:141)
org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:228)
org.ofbiz.widget.screen.ModelScreen.renderScreenString(ModelScreen.java:393)
org.ofbiz.widget.screen.ScreenRenderer.render(ScreenRenderer.java:129)
org.ofbiz.widget.screen.ScreenRenderer.render(ScreenRenderer.java:92)
org.ofbiz.widget.screen.ScreenWidgetViewHandler.render(ScreenWidgetViewHandler.java:96)
org.ofbiz.webapp.control.RequestHandler.renderView(RequestHandler.java:651)
org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:435)
org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:198)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:255)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
java.lang.Thread.run(Thread.java:613)


- Vikas

On Thu, Jul 17, 2008 at 7:21 PM, David E Jones <[hidden email]>
wrote:

>
> What is the parse error? Could you send over (using copy/paste) the exact
> text you used?
>
> This definitely works when doing an #assign, and should work for string
> expansion in FTL as well...
>
> -David
>
>
>
> On Jul 17, 2008, at 7:46 AM, Vikas Mayur wrote:
>
>  Thanks David - but its not working at all. I am getting a parse exception
>> and freemarker editor is also showing an error.
>> - Vikas
>>
>> On Thu, Jul 17, 2008 at 7:01 PM, David E Jones <[hidden email]>
>> wrote:
>>
>>
>>> Try:
>>>
>>> ${uiLabelMap.["checkhelper.select_shipping_destination"]}
>>>
>>> But yeah, it is probably better to avoid periods in label names...
>>>
>>> -David
>>>
>>>
>>>
>>> On Jul 17, 2008, at 7:24 AM, Vikas Mayur wrote:
>>>
>>> I come across to use a label checkhelper.select_shipping_destination
>>>
>>>> defined
>>>> in OrderUiLabel in a ftl file.But this does not work the usual way
>>>> ${uiLabelMap.checkhelper.select_shipping_destination}.
>>>>
>>>> Is there a way to use these kind labels.
>>>>
>>>> Thanks,
>>>> - Vikas
>>>>
>>>>
>>>
>>>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to use labels that contains a period with in a ftl

Vikas Mayur-2
In reply to this post by Bilgin Ibryam
Hi Bilgin,
As per your suggestion - I tried with
1) ${uiLabelMap["checkhelperselect_shipping_destination"]} - > Results in
the same error
2) ${uiLabelMap.checkhelperselect_shipping_destination} --> Screen does not
break this time but label is rendered as it is
(checkhelperselect_shipping_destination).

Is that what you mean here. If not - please send over an example.

Thanks,
- Vikas



On Thu, Jul 17, 2008 at 7:26 PM, Bilgin Ibryam <[hidden email]> wrote:

> On Thu, 2008-07-17 at 19:16 +0530, Vikas Mayur wrote:
> > Thanks David - but its not working at all. I am getting a parse exception
> > and freemarker editor is also showing an error.
> > - Vikas
>
> Try w/o dot:
>
> ${uiLabelMap["checkhelper.select_shipping_destination"]}
>
> Bilgin
>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to use labels that contains a period with in a ftl

Bilgin Ibryam
Sorry for not being clear.
This one works for me:

${uiLabelMap["checkhelper.select_shipping_destination"]}

Bilgin


Reply | Threaded
Open this post in threaded view
|

Re: How to use labels that contains a period with in a ftl

Ashish Vijaywargiya
Yes Bilgin you are right.
Vikas has gone so I am confirming you that its working :-).
Thanks Buddy.


On Thu, Jul 17, 2008 at 7:42 PM, Bilgin Ibryam <[hidden email]> wrote:

> Sorry for not being clear.
> This one works for me:
>
> ${uiLabelMap["checkhelper.select_shipping_destination"]}
>
> Bilgin
>
>
>


--
Ashish Vijaywargiya
Indore, India
http://en.wikipedia.org/wiki/Indore
Reply | Threaded
Open this post in threaded view
|

Re: How to use labels that contains a period with in a ftl

Vikas Mayur-2
In reply to this post by Bilgin Ibryam
Thanks Bilgin and others,
It worked like a charm. Its a definitely an interesting learning .....

- Vikas


On Thu, Jul 17, 2008 at 7:42 PM, Bilgin Ibryam <[hidden email]> wrote:

> Sorry for not being clear.
> This one works for me:
>
> ${uiLabelMap["checkhelper.select_shipping_destination"]}
>
> Bilgin
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to use labels that contains a period with in a ftl

David E Jones

Yes, thanks Bilgin. In my haste the other morning I totally forgot to  
whack that period when adding the square braces.

BTW, there are quite a few examples of this in various FTL files,  
especially when using the Static["org.ofbiz...."].staticMethod() type  
of pattern. There are also some pretty good docs on this topic on the  
freemarker.org site.

-David


On Jul 18, 2008, at 1:54 AM, Vikas Mayur wrote:

> Thanks Bilgin and others,
> It worked like a charm. Its a definitely an interesting learning .....
>
> - Vikas
>
>
> On Thu, Jul 17, 2008 at 7:42 PM, Bilgin Ibryam  
> <[hidden email]> wrote:
>
>> Sorry for not being clear.
>> This one works for me:
>>
>> ${uiLabelMap["checkhelper.select_shipping_destination"]}
>>
>> Bilgin
>>
>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: How to use labels that contains a period with in a ftl

Jacques Le Roux
Administrator
David,

Thanks for the reminder, yes simple actually (not voodoo ;o) : it's a map ultimately.
http://freemarker.org/docs/app_faq.html#faq_question_13

Jacques

From: "David E Jones" <[hidden email]>

>
> Yes, thanks Bilgin. In my haste the other morning I totally forgot to  
> whack that period when adding the square braces.
>
> BTW, there are quite a few examples of this in various FTL files,  
> especially when using the Static["org.ofbiz...."].staticMethod() type  
> of pattern. There are also some pretty good docs on this topic on the  
> freemarker.org site.
>
> -David
>
>
> On Jul 18, 2008, at 1:54 AM, Vikas Mayur wrote:
>
>> Thanks Bilgin and others,
>> It worked like a charm. Its a definitely an interesting learning .....
>>
>> - Vikas
>>
>>
>> On Thu, Jul 17, 2008 at 7:42 PM, Bilgin Ibryam  
>> <[hidden email]> wrote:
>>
>>> Sorry for not being clear.
>>> This one works for me:
>>>
>>> ${uiLabelMap["checkhelper.select_shipping_destination"]}
>>>
>>> Bilgin
>>>
>>>
>>>
>