Page 1 of 1

Override the existing handler

Posted: Tue Feb 05, 2013 6:12 am
by julia
Hello,

I would like to override the existing StaticAssetCustomPersistenceHandler class because I want to load the assets by the file extension when I click the filter button. I don't want to add any parameter. Actually, I would like to override the fetch method and I would like to write the criteria query to retrieve from database.

I don't know this is the best way. Is there any other way?

Thanks
julia

Re: Override the existing handler

Posted: Fri Mar 08, 2013 1:32 pm
by jefffischer
Probably the best way is something like this. The top filter list removes the existing persistence handler, and the bottom list adds your persistence handler.

Code: Select all

<bean id="blCustomPersistenceHandlerFilters" class="org.springframework.beans.factory.config.ListFactoryBean" scope="prototype">
        <property name="sourceList">
            <list>
                <bean class="org.broadleafcommerce.openadmin.server.service.handler.DefaultCustomPersistenceHandlerFilter">
                    <property name="filterCustomPersistenceHandlerClassnames">
                        <list>
                            <value>org.broadleafcommerce.cms.admin.server.handler.StaticAssetCustomPersistenceHandler</value>
                        </list>
                    </property>
                </bean>
            </list>
        </property>
    </bean>

    <bean id="blCustomPersistenceHandlers" class="org.springframework.beans.factory.config.ListFactoryBean" scope="prototype">
        <property name="sourceList">
            <list>
                <bean class="your.persistence.handler"/>
            </list>
        </property>
    </bean>