Extending Sku Entity
Posted: Wed Feb 06, 2013 1:02 pm
Hi,
I am trying to extend an BL Sku entity. I've created an interface(MySku) and extended the SkuImpl in MySkuImpl class and implemented MySku.
I've added this implementation class in persistence.xml and overrided Sku entity by in application context as
Now I am trying to access the rentalPrices field by Spring EL expression. in listProducItem.html. I get exception as below
Please help.
I am trying to extend an BL Sku entity. I've created an interface(MySku) and extended the SkuImpl in MySkuImpl class and implemented MySku.
Code: Select all
public interface MySku {
public void setRentalPrices(Map<Integer, BigDecimal> rentalPrices);
public Map<Integer, BigDecimal> getRentalPrices();
}
Code: Select all
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name="MY_SKU")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region="blStandardElements")
public class MySkuImpl extends SkuImpl implements MySku{
/**
*
*/
private static final long serialVersionUID = -518974372567977433L;
@Transient
protected static final Log LOG = LogFactory.getLog(TbrSkuImpl.class);
@Resource(name="myRentalEngine")
@Transient
protected IRentalEngine rentalEngine;
@Transient
protected Map<Integer, BigDecimal> rentalPrices = new HashMap<Integer, BigDecimal>();
@Override
public void setRetailPrice(Money retailPrice) {
super.setRetailPrice(retailPrice);
//Set Rental price after setting Retail Price
try {
rentalPrices = rentalEngine.calculateAllRentals(retailPrice.getAmount());
} catch (RentalServiceException e) {
LOG.warn("Error in rental price calculation for retail price: "+retailPrice.getAmount()+" "+e.getMessage());
//e.printStackTrace();
}
}
public void setRentalPrices(Map<Integer, BigDecimal> rentalPrices) {
this.rentalPrices = rentalPrices;
}
public Map<Integer, BigDecimal> getRentalPrices(){
return this.rentalPrices;
}
}
I've added this implementation class in persistence.xml and overrided Sku entity by in application context as
Code: Select all
<bean id="org.broadleafcommerce.core.catalog.domain.Sku" class="com.mycompany.core.catalog.domain.MySkuImpl" scope="prototype"/>
Now I am trying to access the rentalPrices field by Spring EL expression. in listProducItem.html. I get exception as below
Code: Select all
Field or property 'rentalPrices' cannot be found on object of type 'org.broadleafcommerce.core.catalog.domain.SkuImpl'
Please help.