• Welcome to KonaKart Community Forum. Please login or sign up.
 

Customizing the ProductMgr

Started by superbear, January 12, 2012, 10:35:15 am

Previous topic - Next topic

superbear

Dear KonaKart developers,

I want to add some extra functionality to the com.konakart.al.ProductMgr. Now I want to access my modified version of the ProductMgr (com.konakart.bl.MyProductMgr) from the jsp files. How can I access the modified Manager class? I thought instead of com.konakart.al.ProductMgr, my bl Version gets used, but as the al and bl versions do not share the same interface, this leads to a class cast exception:

<bean:define id="myProdMgr" name="kkEng" property="productMgr" type="com.konakart.bl.MyProductMgr"/>

As konakart tries to cast com.konakart.al.ProductMgr to com.konakart.bl.MyProductMgr

superbear

After some googling, I now found out, that in order to change the al.ProductMgr I have to write a Custom KKAppEng.
After doing so, setting the KKAppEng class in the properties (konakart.properties, konakart_gwt.properties) and overwriting the getProductMgr() method I still get class cast exceptions in my JSP whily doing the bean:definition like this:

<bean:define id="myProdMgr" name="kkEng" property="productMgr" type="com.konakart.al.MyProductManager"/>

PS: why can't I edit or delete my posts?

superbear

So I got my setup nearly running.

I modified the getKKAppEng method of com.konakart.actions.BaseAction to return MyKKAppEng wich is my custom implementation extending KKAppEng.

Now the class MyKKAppEng looks like follows:
public class MyKKAppEng extends KKAppEng {

public MyKKAppEng(EngineConfigIf arg0) throws KKException,
KKAppException, IllegalArgumentException, ClassNotFoundException,
InstantiationException, IllegalAccessException,
InvocationTargetException {
super(arg0);
}

public MyKKAppEng(StoreInfo storeInfo) throws KKAppException {
super(storeInfo);
}

@Override
public MyProductManager getProductMgr() {
try {
return new MyProductManager(this.getEng(), this);
} catch (KKException e) {
e.printStackTrace();
}
return null;
}


}


whereas the MyProductManager class looks like this:
public class MyProductManager extends ProductMgr {

private ProductIf[] mySpecialProducts;

public MyProductManager(KKEngIf kkEng, MyKKAppEng kkAppEng)
throws KKException {
super(kkEng, kkAppEng);
}


public void setMySpecialProducts(ProductIf[] specialProducts) {
this.mySpecialProducts = specialProducts;
}

public ProductIf[] getMySpecialProducts() {
if (mySpecialProducts == null) {
mySpecialProducts = new ProductIf[0];
}
return mySpecialProducts;
}

}


everything works now, accept it seems that I instantiate the MyProductManager class wrongly. When I try to view a product I get the following message:
QuoteDetails of this product cannot be found. It may be out of stock.


Can anybody of the Konakart team tell me how the original ProductMgr gets instantiated in the getProductMgr() method? So that I can do the same for my custom ProductMgr.
I need this customization for my diploma thesis and I realy need to get this going.