Why are you using Static block. You can get your job done without it also.
Try this ..
public class BarStackedData
{
private static CategoryModel model;
private static DefaultCustomCommerceCartService defaultCustomCommerceCartService;
private static ProductService productService;
public static CategoryModel getCategoryModel()
{
model = new DefaultCategoryModel();
model.setValue(
"Low Stock",
"Puma T-Shirts",
new Long(defaultCustomCommerceCartService.getCustomAvailableStockLevel(productService.getProductForCode("30023506"),
null)));
model.setValue(
"Low Stock",
"Socks",
new Long(defaultCustomCommerceCartService.getCustomAvailableStockLevel(productService.getProductForCode("30023206"),
null)));
....... more code .....
return model;
}
// Getter Method
public DefaultCustomCommerceCartService getDefaultCustomCommerceCartService()
{
return defaultCustomCommerceCartService;
}
// Setter Method
public void setProductService(ProductService productService)
{
this.productService = productService;
}
}
Now register bean in spring.xml file
<bean id="barStackedData" class="com.java.project.BarStackedData" >
<property name="defaultCustomCommerceCartService" ref="defaultCustomCommerceCartService" />
<property name="productService" ref="productService" />
</bean>
As I saw in ZK Chart they are using Controller. Try getting bean through Registry.
public class BarStackedComposer extends SelectorComposer<Window>
{
@Wire
Charts chart;
BarStackedData barStackedData;
public void doAfterCompose(Window comp) throws Exception {
super.doAfterCompose(comp);
// get spring bean
barStackedData = (BarStackedData) Registry.getApplicationContext().getBean("barStackedData");
chart.setModel(BarStackedData.getCategoryModel());
chart.getYAxis().setMin(0);
chart.getYAxis().setTitle("Total fruit consumption");
chart.getLegend().setBackgroundColor("#FFFFFF");
chart.getLegend().setReversed(true);
chart.getPlotOptions().getSeries().setStacking("normal");
chart.getCredits().setEnabled(false);
}
}
Hope this will help you... enjoy :)