Page 1 of 1

How do customize AdminLoginController class ?

Posted: Wed Jun 03, 2015 4:47 am
by subhan
If we want to change logic of (org.broadleafcommerce.openadmin.web.controller) AdminLoginController class which is exist in broadleaf-open-admin-platform-3.1.13-GA.jar then what should i do?
If NewAdminLoginController extends AdminLoginController{ ..} then where should i place new class and where changes required with new class name ?
Please help me ..
Thanks
Subhan

Re: How do customize AdminLoginController class ?

Posted: Mon Jun 15, 2015 5:16 am
by rudy
1. Extend

Code: Select all

AdminLoginController
as NewAdminLoginController.
2. In applicationContext-servlet-admin.xml, add a bean override for AdminLoginController's bean id.
Your bean-id should refer to your new class: NewAdminLoginController.
e.g.
Your bean id would be blAdminLoginController as AdminLoginController has the annotation

Code: Select all

@Controller("blAdminLoginController")

Therefore, in applicationContext-servlet-admin.xml, your bean entry should look like

Code: Select all

<bean id="blAdminLoginController" class="package-path-to-NewAdminLoginController" />

3.Ensure that your class does NOT have @Controller or a class level @RequestMapping annotation
4.Override the method you need, keeping all parameter-level annotations (such as @PathVariable)
5.Perform whatever logic you need.
Typically, this might involve a call to the super method, doing some extra stuff, and returning what super returned.

Let me know in case of any problems.