variable from groovy to ftl file

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

variable from groovy to ftl file

Patrick-4
I am modifying the order confirmation email, I've tracked it down to
the "orderstatus" screen.

<screen name="orderstatus"> <!-- truncated for brevity -->
  <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/order/OrderStatus.groovy"/>
  <html-template
location="component://ecommerce/webapp/ecommerce/order/orderstatus.ftl"/>
</screen>

basically OrderStatus.groovy loads up some variables which should be
available to the ftl file.

In the groovy file I've got this simple line
context.testname = "hello";

So then I try to access it in the FTL file. orderstatus.ftl with a simple
<#assign xx=testname>

But it says my variable is null.

Error on line 312, column 1 in
component://ecommerce/webapp/ecommerce/order/orderitems.ftl testname
is undefined. It cannot be assigned to xx The problematic instruction:
---------- ==> assignment: xx=testname [on line 312, column 1 in
component://ecommerce/webapp/ecommerce/order/orderitems

Seems like a pretty simple test, I must be missing something.  Any
tips are appreciated.
-patrick
Reply | Threaded
Open this post in threaded view
|

Re: variable from groovy to ftl file

BJ Freeman
try using "${testname}"

=========================
BJ Freeman
http://bjfreeman.elance.com
Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
Specialtymarket.com <http://www.specialtymarket.com/>

Systems Integrator-- Glad to Assist

Chat  Y! messenger: bjfr33man
Linkedin
<http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>


Patrick sent the following on 3/12/2010 3:09 PM:

> I am modifying the order confirmation email, I've tracked it down to
> the "orderstatus" screen.
>
> <screen name="orderstatus"> <!-- truncated for brevity -->
>   <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/order/OrderStatus.groovy"/>
>   <html-template
> location="component://ecommerce/webapp/ecommerce/order/orderstatus.ftl"/>
> </screen>
>
> basically OrderStatus.groovy loads up some variables which should be
> available to the ftl file.
>
> In the groovy file I've got this simple line
> context.testname = "hello";
>
> So then I try to access it in the FTL file. orderstatus.ftl with a simple
> <#assign xx=testname>
>
> But it says my variable is null.
>
> Error on line 312, column 1 in
> component://ecommerce/webapp/ecommerce/order/orderitems.ftl testname
> is undefined. It cannot be assigned to xx The problematic instruction:
> ---------- ==> assignment: xx=testname [on line 312, column 1 in
> component://ecommerce/webapp/ecommerce/order/orderitems
>
> Seems like a pretty simple test, I must be missing something.  Any
> tips are appreciated.
> -patrick
>


Reply | Threaded
Open this post in threaded view
|

Re: variable from groovy to ftl file

Patrick-4
that gives a parse error

Error rendering included template at location
[component://ecommerce/webapp/ecommerce/order/orderitems.ftl]:
freemarker.core.ParseException: Encountered "{" at line 309, column 14
in component://ecommerce/webapp/ecommerce/order/orderitems.ftl. Was
expecting one of: "in" ... ">" ...  ... "." ... "[" ... "(" ... "?"
... "!" ...  ... "??" ... "+" ... "-" ... "*" ... "/" ... "%" ... "!="
... "=" ... "==" ... ">=" ...  ... ">" ...  ...  ...  ... ".." ...
...  ... "," ...  ...  ...
 


On Fri, Mar 12, 2010 at 5:55 PM, BJ Freeman <[hidden email]> wrote:

> try using "${testname}"
>
> =========================
> BJ Freeman
> http://bjfreeman.elance.com
> Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
> Specialtymarket.com <http://www.specialtymarket.com/>
>
> Systems Integrator-- Glad to Assist
>
> Chat  Y! messenger: bjfr33man
> Linkedin
> <http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>
>
>
> Patrick sent the following on 3/12/2010 3:09 PM:
>> I am modifying the order confirmation email, I've tracked it down to
>> the "orderstatus" screen.
>>
>> <screen name="orderstatus"> <!-- truncated for brevity -->
>>   <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/order/OrderStatus.groovy"/>
>>   <html-template
>> location="component://ecommerce/webapp/ecommerce/order/orderstatus.ftl"/>
>> </screen>
>>
>> basically OrderStatus.groovy loads up some variables which should be
>> available to the ftl file.
>>
>> In the groovy file I've got this simple line
>> context.testname = "hello";
>>
>> So then I try to access it in the FTL file. orderstatus.ftl with a simple
>> <#assign xx=testname>
>>
>> But it says my variable is null.
>>
>> Error on line 312, column 1 in
>> component://ecommerce/webapp/ecommerce/order/orderitems.ftl testname
>> is undefined. It cannot be assigned to xx The problematic instruction:
>> ---------- ==> assignment: xx=testname [on line 312, column 1 in
>> component://ecommerce/webapp/ecommerce/order/orderitems
>>
>> Seems like a pretty simple test, I must be missing something.  Any
>> tips are appreciated.
>> -patrick
>>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: variable from groovy to ftl file

BJ Freeman
In reply to this post by BJ Freeman
yes I gave you part so you could find examples in code.
find other code in other ftls that show this or use the tutorial.
take a look at
/framework/webapp/src/org/ofbiz/webapp/ftl

=========================
BJ Freeman
http://bjfreeman.elance.com
Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
Specialtymarket.com <http://www.specialtymarket.com/>

Systems Integrator-- Glad to Assist

Chat  Y! messenger: bjfr33man
Linkedin
<http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>


Patrick sent the following on 3/12/2010 4:01 PM:

> that gives a parse error
>
> Error rendering included template at location
> [component://ecommerce/webapp/ecommerce/order/orderitems.ftl]:
> freemarker.core.ParseException: Encountered "{" at line 309, column 14
> in component://ecommerce/webapp/ecommerce/order/orderitems.ftl. Was
> expecting one of: "in" ... ">" ...  ... "." ... "[" ... "(" ... "?"
> ... "!" ...  ... "??" ... "+" ... "-" ... "*" ... "/" ... "%" ... "!="
> ... "=" ... "==" ... ">=" ...  ... ">" ...  ...  ...  ... ".." ...
> ...  ... "," ...  ...  ...
>  
>
>
> On Fri, Mar 12, 2010 at 5:55 PM, BJ Freeman <[hidden email]> wrote:
>> try using "${testname}"
>>
>> =========================
>> BJ Freeman
>> http://bjfreeman.elance.com
>> Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=93>
>> Specialtymarket.com <http://www.specialtymarket.com/>
>>
>> Systems Integrator-- Glad to Assist
>>
>> Chat  Y! messenger: bjfr33man
>> Linkedin
>> <http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro>
>>
>>
>> Patrick sent the following on 3/12/2010 3:09 PM:
>>> I am modifying the order confirmation email, I've tracked it down to
>>> the "orderstatus" screen.
>>>
>>> <screen name="orderstatus"> <!-- truncated for brevity -->
>>>   <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/order/OrderStatus.groovy"/>
>>>   <html-template
>>> location="component://ecommerce/webapp/ecommerce/order/orderstatus.ftl"/>
>>> </screen>
>>>
>>> basically OrderStatus.groovy loads up some variables which should be
>>> available to the ftl file.
>>>
>>> In the groovy file I've got this simple line
>>> context.testname = "hello";
>>>
>>> So then I try to access it in the FTL file. orderstatus.ftl with a simple
>>> <#assign xx=testname>
>>>
>>> But it says my variable is null.
>>>
>>> Error on line 312, column 1 in
>>> component://ecommerce/webapp/ecommerce/order/orderitems.ftl testname
>>> is undefined. It cannot be assigned to xx The problematic instruction:
>>> ---------- ==> assignment: xx=testname [on line 312, column 1 in
>>> component://ecommerce/webapp/ecommerce/order/orderitems
>>>
>>> Seems like a pretty simple test, I must be missing something.  Any
>>> tips are appreciated.
>>> -patrick
>>>
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: variable from groovy to ftl file

brajeshpatel
In reply to this post by Patrick-4
Hi Patrick,
it will work,

in groovy : context.testname = "hello";
in ftl: <#assign xx=testname />

I think you are putting in side of the condition that is not satisfy.




On Sat, Mar 13, 2010 at 4:39 AM, Patrick <[hidden email]>wrote:

> I am modifying the order confirmation email, I've tracked it down to
> the "orderstatus" screen.
>
> <screen name="orderstatus"> <!-- truncated for brevity -->
>  <script
> location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/order/OrderStatus.groovy"/>
>  <html-template
> location="component://ecommerce/webapp/ecommerce/order/orderstatus.ftl"/>
> </screen>
>
> basically OrderStatus.groovy loads up some variables which should be
> available to the ftl file.
>
> In the groovy file I've got this simple line
> context.testname = "hello";
>
> So then I try to access it in the FTL file. orderstatus.ftl with a simple
> <#assign xx=testname>
>
> But it says my variable is null.
>
> Error on line 312, column 1 in
> component://ecommerce/webapp/ecommerce/order/orderitems.ftl testname
> is undefined. It cannot be assigned to xx The problematic instruction:
> ---------- ==> assignment: xx=testname [on line 312, column 1 in
> component://ecommerce/webapp/ecommerce/order/orderitems
>
> Seems like a pretty simple test, I must be missing something.  Any
> tips are appreciated.
> -patrick
>



--
Thanks
Brajesh Patel

HotWax Media
http://www.hotwaxmedia.com
Reply | Threaded
Open this post in threaded view
|

Re: variable from groovy to ftl file

Ashish Vijaywargiya
In reply to this post by Patrick-4
<#assign> tag should be closed.

For ex:
<#assign xx=testname/>

--
Ashish

On Sat, Mar 13, 2010 at 4:39 AM, Patrick <[hidden email]> wrote:

> I am modifying the order confirmation email, I've tracked it down to
> the "orderstatus" screen.
>
> <screen name="orderstatus"> <!-- truncated for brevity -->
>  <script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/order/OrderStatus.groovy"/>
>  <html-template
> location="component://ecommerce/webapp/ecommerce/order/orderstatus.ftl"/>
> </screen>
>
> basically OrderStatus.groovy loads up some variables which should be
> available to the ftl file.
>
> In the groovy file I've got this simple line
> context.testname = "hello";
>
> So then I try to access it in the FTL file. orderstatus.ftl with a simple
> <#assign xx=testname>
>
> But it says my variable is null.
>
> Error on line 312, column 1 in
> component://ecommerce/webapp/ecommerce/order/orderitems.ftl testname
> is undefined. It cannot be assigned to xx The problematic instruction:
> ---------- ==> assignment: xx=testname [on line 312, column 1 in
> component://ecommerce/webapp/ecommerce/order/orderitems
>
> Seems like a pretty simple test, I must be missing something.  Any
> tips are appreciated.
> -patrick
>