Page 1 of 2
PriceTextDisplayProcessor
Posted: Mon Mar 04, 2013 11:20 am
by sunil
Hi All
can some one provide me help how I used the MergeContextLoaderListener works. I want to add and change the behaviour of price according to Indian currency.I want to change the functionality of PriceTextDisplayProcessor been.
I also read and see the video of Kelly
Please help
Thanks
Re: PriceTextDisplayProcessor
Posted: Tue Mar 05, 2013 4:06 pm
by phillipuniverse
Add this to one of your application contexts that is referenced in the patchConfigLocations context-param in your web.xml:
Code: Select all
<bean id="blPriceTextDisplayProcessor" class="com.yourcompany.web.processor.YourCustomPriceTextDisplayProcessor" />
Re: PriceTextDisplayProcessor
Posted: Wed Mar 06, 2013 2:48 am
by gk12
Its not working...!
I added the following to site/../WEB-INF/applicationContext.xml and still getting the default currency.
Code: Select all
<bean id="blPriceTextDisplayProcessor" class="com.mysite.core.web.processor.PriceTextDisplayProcessor" />
Re: PriceTextDisplayProcessor
Posted: Wed Mar 06, 2013 11:12 am
by phillipuniverse
Set a breakpoint in your PriceTextDisplayProcessor. Does that breakpoint get hit?
Re: PriceTextDisplayProcessor
Posted: Wed Mar 06, 2013 11:12 am
by phillipuniverse
I also assume that you did a restart after changing applicationContext.xml
Re: PriceTextDisplayProcessor
Posted: Wed Mar 06, 2013 1:15 pm
by jfridye
Here's an example where you configure your custom processor as a part of your custom dialect. Your custom dialect will be added to the bean "blWebTemplateEngine". The location inside your applicationContext.xml inside your site project is fine.
Code: Select all
<bean id="yourCustomDialect" class="com.mycompany.web.dialect.CustomDialect">
<property name="processors">
<set>
<ref bean="yourCustomProcessor" />
</set>
</property>
</bean>
<bean id="blWebTemplateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
<property name="dialects">
<set>
<ref bean="yourCustomDialect" />
</set>
</property>
</bean>
Re: PriceTextDisplayProcessor
Posted: Wed Mar 06, 2013 2:49 pm
by phillipuniverse
jfridye: this is a slightly different use case. Sunil is trying to override the PriceTextDisplayProcessor that we provide in the framework (via the blPriceTextDisplayProcessor bean). Sunil shouldn't need to add anything to the dialect; this should be as straightforward as overriding the bean definition.
Re: PriceTextDisplayProcessor
Posted: Wed Mar 06, 2013 3:05 pm
by jfridye
Ah, yes then in this case you would do as @phillipuniverse says.
Re: PriceTextDisplayProcessor
Posted: Sat Mar 09, 2013 11:38 am
by sunil
I am able to do it as specified. But in javascript still $ is appending as shown below in demo site:-
Code: Select all
function updatePriceDisplay() {
var productOptions = getProductOptionData();
var selectedProductOptions = [];
for (var i = 0; i < productOptions.length; i++) {
selectedProductOptions.push(productOptions[i].selectedValue); // add selected value to array
}
var productOptionPricing = getPricingData();
var price;
for (var i = 0; i < productOptionPricing.length; i++) {
var pricing = productOptionPricing[i];
if ($(pricing.selectedOptions).not(selectedProductOptions).length == 0 && $(selectedProductOptions).not(pricing.selectedOptions).length == 0) {
[b]price = '$' + pricing.price;[/b]
break;
}
So if in future someone wants to use demo site as a customization starting point above method should also be updated thanks
Re: PriceTextDisplayProcessor
Posted: Fri Mar 15, 2013 7:06 am
by gk12
Yes, I did restart after adding to applicationContext.xml
I tested with breakpoint and It's not hitting custom PriceTextDisplayProcessor.