Page 1 of 1
Extending the OrderStatus class
Posted: Wed Nov 07, 2012 8:34 am
by vibeesh
Hi,
I have a requirement to add one more status to the org.broadleafcommerce.core.order.service.type.OrderStatus .
We can extend the beans and services which has a bean id. How i can extend the org.broadleafcommerce.core.order.service.type.OrderStatus so that i can add one more status and which is available throughout the system. And i have to show it in the order status dropdown in the admin section.
Regards
Vibeesh
Re: Extending the OrderStatus class
Posted: Wed Nov 07, 2012 10:42 am
by phillipuniverse
First step is to do probably what you've already done, and subclass OrderStatus and add your new types:
Code: Select all
package com.mycompany.order.service.type
public class CustomOrderStatus extends OrderStatus {
private static final long serialVersionUID = 1L;
public static final OrderStatus CANCELLED = new OrderStatus("CANCELLED", "Cancelled");
}
If you already have a subclass of OrderImpl (perhaps MyCompanyOrderImpl) then you can just add in an @AdminPresentationOverride (works for 1.x and 2.x versions of BLC):
Code: Select all
@AdminPresentationOverrides({
@AdminPresentationOverride(name="status", value=@AdminPresentation(friendlyName = "Order Status", group = "Order", order=2, prominent=true, fieldType=SupportedFieldType.BROADLEAF_ENUMERATION, broadleafEnumeration="com.mycompany.order.service.type.CustomOrderStatus"))
});
public class MyCompanyOrderImpl extends OrderImpl {
...whatever custom code you have
}
If you
don't already have a subclass of Order and thus can't do the override this way, if you're on 2.0 or higher (highly recommended btw) then you can achieve this via XML. So in your applicationContext-admin.xml you would have this:
Code: Select all
<mo:override id="blMetadataOverrides">
<mo:overrideItem ceilingEntity="org.broadleafcommerce.core.order.domain.Order">
<mo:field name="status">
<mo:property name="broadleafEnumeration" value="com.mycompany.order.service.type.CustomOrderStatus" />
</mo:field>
</mo:overrideItem>
</mo:override>
In order to get the XML markup to validate correctly, you will also need to include the 'mo' xsd in your schemaLocations and define the mo: namespace. This is what you have to have in you <beans> root element (along with all of your other namespaces and schemaLocations that are already there):
Code: Select all
<beans xmlns="xmlns:mo="http://schema.broadleafcommerce.org/mo"
xsi:schemaLocation="http://schema.broadleafcommerce.org/mo
http://schema.broadleafcommerce.org/mo/mo-2.0.xsd">
So a complete <beans> element from applicationContext-admin.xml might look like this:
Code: Select all
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mo="http://schema.broadleafcommerce.org/mo"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://schema.broadleafcommerce.org/mo
http://schema.broadleafcommerce.org/mo/mo-2.0.xsd">
And just a note, the XML and annotation versions that I mentioned are equivalent.
Re: Extending the OrderStatus class
Posted: Fri Nov 09, 2012 1:53 am
by vibeesh
Thanks for your reply.
Re: Extending the OrderStatus class
Posted: Mon Nov 12, 2012 7:42 am
by renob
I tried to extended the ProductOptiontype class and add it to ProductOption.
It's working well with the xml file implementation, as you did.
Code: Select all
<mo:override id="blMetadataOverrides">
<mo:overrideItem ceilingEntity="org.broadleafcommerce.core.catalog.domain.ProductOption">
<mo:field name="type">
<mo:property name="broadleafEnumeration" value="fr.meteo.ecommerce.core.catalog.service.type.MFProductOptionType" />
</mo:field>
</mo:overrideItem>
</mo:override>
But I first try it with the annotation (@AdminPresentationOverride) with the code below:
Code: Select all
@AdminPresentationOverrides(
{
@AdminPresentationOverride(name="type", value=@AdminPresentation(friendlyName = "Type", fieldType=SupportedFieldType.BROADLEAF_ENUMERATION, broadleafEnumeration="fr.meteo.ecommerce.core.catalog.service.type.MFProductOptionType"))
}
)
And unfortunately I got a issue, do you have a solution to make it work with annotation, we prefere used annotations.
Error :
Code: Select all
[ERROR] 13:31:27 Log4JRemoteGwtLoggingServlet - 127.0.0.1:BLC Admin Uncaught exception:
java.lang.Throwable: (TypeError): enumerationValues is null
stack: org_broadleafcommerce_openadmin_client_datasource_dynamic_module_BasicClientEntityModule$7_visit__Lorg_broadleafcommerce_openadmin_client_dto_BasicFieldMetadata_2V@https://localhost:8444/admin/fr.meteo.ecommerce.gwt.frmeteoecommerceAdmin/5FADC5F4476786F0C8DCF66C874F2DA9.cache.html:33517
org_broadleafcommerce_openadmin_client_dto_BasicFieldMetadata_accept__Lorg_broadleafcommerce_openadmin_client_dto_visitor_MetadataVisitor_2V@https://localhost:8444/admin/fr.meteo.ecommerce.gwt.frmeteoecommerceAdmin/5FADC5F4476786F0C8DCF66C874F2DA9.cache.html:34052
org_broadleafcommerce_openadmin_client_datasource_dynamic_module_BasicClientEntityModule_$filterProperties__Lorg_broadleafcommerce_openadmin_client_datasource_dynamic_module_BasicClientEntityModule_2Lorg_broadleafcommerce_openadmin_client_dto_ClassMetadata_2_3Lorg_broadleafcommerce_openadmin_client_dto_MergedPropertyType_2Ljava_lang_Boolean_2Lorg_broadleafcommerce_openadmin_client_setup_PresenterSequenceSetupManager_2V@https://localhost:8444/admin/fr.meteo.ecommerce.gwt.frmeteoecommerceAdmin/5FADC5F4476786F0C8DCF66C874F2DA9.cache.html:29149
org_broadleafcommerce_openadmin_client_datasource_dynamic_module_BasicClientEntityModule$5_$onSuccess__Lorg_broadleafcommerce_openadmin_client_datasource_dynamic_module_BasicClientEntityModule$5_2Lorg_broadleafcommerce_openadmin_client_dto_DynamicResultSet_2V@https://localhost:8444/admin/fr.meteo.ecommerce.gwt.frmeteoecommerceAdmin/5FADC5F4476786F0C8DCF66C874F2DA9.cache.html:33293
org_broadleafcommerce_openadmin_client_datasource_dynamic_module_BasicClientEntityModule$5_onSuccess__Ljava_lang_Object_2V@https://localhost:8444/admin/fr.meteo.ecommerce.gwt.frmeteoecommerceAdmin/5FADC5F4476786F0C8DCF66C874F2DA9.cache.html:33327
com_google_gwt_user_client_rpc_impl_RequestCallbackAdapter_$onResponseReceived__Lcom_google_gwt_user_client_rpc_impl_RequestCallbackAdapter_2Lcom_google_gwt_http_client_Request_2Lcom_google_gwt_http_client_Response_2V@https://localhost:8444/admin/fr.meteo.ecommerce.gwt.frmeteoecommerceAdmin/5FADC5F4476786F0C8DCF66C874F2DA9.cache.html:10958
com_google_gwt_http_client_Request_$fireOnResponseReceived__Lcom_google_gwt_http_client_Request_2Lcom_google_gwt_http_client_RequestCallback_2V@https://localhost:8444/admin/fr.meteo.ecommerce.gwt.frmeteoecommerceAdmin/5FADC5F4476786F0C8DCF66C874F2DA9.cache.html:3046
com_google_gwt_http_client_RequestBuilder$1_onReadyStateChange__Lcom_google_gwt_xhr_client_XMLHttpRequest_2V@https://localhost:8444/admin/fr.meteo.ecommerce.gwt.frmeteoecommerceAdmin/5FADC5F4476786F0C8DCF66C874F2DA9.cache.html:3264
@https://localhost:8444/admin/fr.meteo.ecommerce.gwt.frmeteoecommerceAdmin/5FADC5F4476786F0C8DCF66C874F2DA9.cache.html:13348
com_google_gwt_core_client_impl_Impl_apply__Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2@https://localhost:8444/admin/fr.meteo.ecommerce.gwt.frmeteoecommerceAdmin/5FADC5F4476786F0C8DCF66C874F2DA9.cache.html:966
com_google_gwt_core_client_impl_Impl_entry0__Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2@https://localhost:8444/admin/fr.meteo.ecommerce.gwt.frmeteoecommerceAdmin/5FADC5F4476786F0C8DCF66C874F2DA9.cache.html:996
@https://localhost:8444/admin/fr.meteo.ecommerce.gwt.frmeteoecommerceAdmin/5FADC5F4476786F0C8DCF66C874F2DA9.cache.html:981
fileName: https://localhost:8444/admin/fr.meteo.ecommerce.gwt.frmeteoecommerceAdmin/5FADC5F4476786F0C8DCF66C874F2DA9.cache.html
lineNumber: 33517
at Unknown.anonymous(Unknown Source)
at Unknown.anonymous(Unknown Source)
at Unknown.anonymous(Unknown Source)
at Unknown.anonymous(Unknown Source)
at Unknown.anonymous(Unknown Source)
at Unknown.anonymous(Unknown Source)
at Unknown.anonymous(Unknown Source)
at Unknown.anonymous(Unknown Source)
at Unknown.anonymous(Unknown Source)
at Unknown.anonymous(Unknown Source)
at Unknown.anonymous(Unknown Source)
at Unknown.anonymous(Unknown Source)
at Unknown.anonymous(Unknown Source)
Thank
Re: Extending the OrderStatus class
Posted: Tue Nov 13, 2012 2:27 am
by phillipuniverse
Can you post the MFProductOptionType class? Does this extend from the Broadleaf ProductOptionType?
Specifically, the admin assumes that you have the following properties in this class:
- a static member called TYPES
- a method called getType
- a method called getFriendlyType()
If you're extending from a Broadleaf class then all of these requirements should be met. Let me know if this is the case and there is still a problem.
Re: Extending the OrderStatus class
Posted: Wed Nov 14, 2012 7:50 am
by vibeesh
I also getting the same exception.
@AdminPresentationOverrides(
{
@AdminPresentationOverride(name="status", value=@AdminPresentation(friendlyName = "Order Status",group = "Order", order=2, prominent=true, fieldType=SupportedFieldType.BROADLEAF_ENUMERATION,broadleafEnumeration="com.planetyoung.core.order.domain.PyOrderStatus"))
}
)
And my com.planetyoung.core.order.domain.PyOrderStatus contains
package com.planetyoung.core.order.domain;
import org.broadleafcommerce.core.order.service.type.OrderStatus;
public class PyOrderStatus extends OrderStatus {
private static final long serialVersionUID = 1L;
public static final OrderStatus SHIPPED = new OrderStatus("SHIPPED", "Shipped");
}
Please help
Re: Extending the OrderStatus class
Posted: Thu Nov 15, 2012 5:47 am
by renob
Yes, I extend the ProductOptionType so all the properties sould be in my class. But as vibeesh and I still have the issue with the Annotation @AdminPresentationOverride
My custom class :
Code: Select all
public class MFProductOptionType extends ProductOptionType {
private static final long serialVersionUID = 1L;
public static final MFProductOptionType CITY = new MFProductOptionType("CITY", "Ville");
public static final MFProductOptionType DEPARTEMENT = new MFProductOptionType("DEPARTEMENT", "Department");
public static final MFProductOptionType REPORT_TYPE = new MFProductOptionType("REPORT_TYPE", "Type de Bulletin");
public static final MFProductOptionType DIFFUSION_HOUR = new MFProductOptionType("DIFFUSION_HOUR", "Heure de diffusion");
}
Regards
Renaud
Re: Extending the OrderStatus class
Posted: Tue Dec 11, 2012 11:40 am
by denis
vibeesh wrote:I also getting the same exception.
@AdminPresentationOverrides(
{
@AdminPresentationOverride(name="status", value=@AdminPresentation(friendlyName = "Order Status",group = "Order", order=2, prominent=true, fieldType=SupportedFieldType.BROADLEAF_ENUMERATION,broadleafEnumeration="com.planetyoung.core.order.domain.PyOrderStatus"))
}
)
And my com.planetyoung.core.order.domain.PyOrderStatus contains
package com.planetyoung.core.order.domain;
import org.broadleafcommerce.core.order.service.type.OrderStatus;
public class PyOrderStatus extends OrderStatus {
private static final long serialVersionUID = 1L;
public static final OrderStatus SHIPPED = new OrderStatus("SHIPPED", "Shipped");
}
Please help
Same problem with OrderStatus and @AdminPresentationOverrides on BLC 2.1.0-SNAPSHOT, but it works fine with xml override.