Overriding AddressImpl
Posted: Sun Jul 06, 2014 4:27 pm
I am trying to override the address implementation in broadleaf so that I can add a field, in this case a string named province. I am doing this by building on top of the heat clinic example site. I am currently having very strange issues with the checkout whereby the address are returned with all fields being null, however when saving the shipping details the address reappears.
Here are my customisations to the Heat Clinic demo.
Core Changes
I have started by working in the core module creating an ER_Address interface that extends Address, and an ER_AddressImpl which extends AddressImpl and implements ER_Address.
ER_Address
ER_AddressImplementation
I then added the following entry to core:applicationContext-entity.xml
Site Changes
The next step is to work on the site module and this is where I currently come unstuck...
Firstly I edit the site:applicationContext-entity.xml file so it looks like this:
Next I extend the BillingInfoForm and the ShippingInfoForm adding in my address implementation like this:
Next I change the signatures on the controllers to use my Billing and Shipping forms. Then I extend the OnePageCheckoutProcessor and change all the instances of the forms to my implementation.
Any pointers on where I have gone wrong would be awesome!
Many thanks
Here are my customisations to the Heat Clinic demo.
Core Changes
I have started by working in the core module creating an ER_Address interface that extends Address, and an ER_AddressImpl which extends AddressImpl and implements ER_Address.
ER_Address
Code: Select all
public interface ER_Address extends Address{
public String getProvince();
public void setProvince(String province);
}
ER_AddressImplementation
Code: Select all
@Entity
@Table(name="ER_ADDRESS")
public class ER_AddressImpl extends AddressImpl implements ER_Address {
private String province;
@Override
public String getProvince() {
return province;
}
@Override
public void setProvince(String province) {
this.province = province;
}
}
I then added the following entry to core:applicationContext-entity.xml
Code: Select all
<bean id="org.broadleafcommerce.profile.core.domain.Address" class="com.eggretail.domin.ER_AddressImpl" scope="prototype"/>
Site Changes
The next step is to work on the site module and this is where I currently come unstuck...
Firstly I edit the site:applicationContext-entity.xml file so it looks like this:
Code: Select all
<bean id="org.broadleafcommerce.profile.core.domain.Address" class="com.eggretail.domin.ER_AddressImpl" scope="prototype">
<property name="country">
<bean class="org.broadleafcommerce.profile.core.domain.CountryImpl">
<property name="abbreviation" value="GB"/>
<property name="name" value="Great Britain"/>
</bean>
</property>
</bean>
Next I extend the BillingInfoForm and the ShippingInfoForm adding in my address implementation like this:
Code: Select all
public class ER_BillingInfoForm extends BillingInfoForm implements Serializable {
private ER_Address er_address = new ER_AddressImpl();
public ER_Address getAddress() {
return er_address;
}
public void setAddress(ER_Address address) {
this.er_address = address;
}
}
Next I change the signatures on the controllers to use my Billing and Shipping forms. Then I extend the OnePageCheckoutProcessor and change all the instances of the forms to my implementation.
Any pointers on where I have gone wrong would be awesome!
Many thanks