Hi Erik,
I believe all this should work.
I'd simplify the process by:
1) adding : @Inject ComponentFactoryRegistrar componentFactoryRegistrar;
to MyWicketApplication.java
2) in MyWicketApplication#init() {super.init();
componentFactoryRegistrar.replace(...); ...}
Put some breakpoints in the related methods and see whether they are called.
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
On Fri, Jan 2, 2015 at 6:40 PM, Erik de Hair <[email protected]> wrote:
> Hi,
>
> I tried to replace a component (just to try this out) but got stuck. As a
> first step I copied the ReferencePanelFactory (as
> PortalReferencePanelFactory, still using the ReferencePanal from Isis) and
> created a ComponenFactoryRegistrarDefault as
> PortalComponentFactoryRegistrar like documented at [1]. Then I configured
> the ComponenFactoryRegistrarDefault in the Wicket Application. As a
> result I get the message "??? ScalarModel objectAdapter oid: null" for each
> property when running the application.
>
> Here's my code:
>
> public class PortalReferencePanelFactory extends ComponentFactoryAbstract
> {
> private static final long serialVersionUID = 1L;
>
> public PortalReferencePanelFactory() {
> super(ComponentType.SCALAR_NAME_AND_VALUE, ReferencePanel.class);
> }
>
> @Override
> public ApplicationAdvice appliesTo(final IModel<?> model) {
> if (!(model instanceof ScalarModel)) {
> return ApplicationAdvice.DOES_NOT_APPLY;
> }
> final ScalarModel scalarModel = (ScalarModel) model;
> final ObjectSpecification specification = scalarModel.
> getTypeOfSpecification();
> return appliesIf(!specification.containsFacet(ValueFacet.class));
> }
>
> @Override
> public Component createComponent(final String id, final IModel<?>
> model) {
> final ScalarModel scalarModel = (ScalarModel) model;
> return new ReferencePanel(id, scalarModel);
> }
> }
>
> @Singleton
> public class PortalComponentFactoryRegistrar extends
> ComponentFactoryRegistrarDefault
> {
> @Override
> public void addComponentFactories(ComponentFactoryList
> componentFactories) {
> super.addComponentFactories(componentFactories);
> componentFactories.replace(new PortalReferencePanelFactory());
> }
> }
>
> Should this be working?
>
> Thanks,
> Erik
>
> [1] http://isis.apache.org/components/viewers/wicket/
> customizing-the-viewer.html
>