On 24 November 2015 at 12:49, Kevin Meyer <[email protected]> wrote:

>
> >>
> >>
> >> @Override
> >> protected ApplicationAdvice appliesTo(IModel<?> model) { if (model
> >> instanceof ScalarModel) { Object obj = model.getObject();
> >> if (obj != null) { if (obj instanceof PojoAdapter) { PojoAdapter po =
> >> (PojoAdapter) obj;
> >>
> >> ... snip ...
> >>
> > Your PanelFactory is looking for the @Html annotation on a class
> > definition, not on a field definition.
> >
>
>
> Is that really the case?  With the model being ScalarModel (and I think in
> the factory I'm installing the component with SCALAR_NAME_AND_VALUE).
>
> When I debug, the obj that's coming in (above) is the String that holds
> the property in question.
>
>
The object is indeed a string.  The ScalarModel basically is the pair of a
property and its value, or a parameter and its value.  The "kind" of the
ScalarModel determines this.

If you trace through ComponentScalarFactoryAbstract, have a look at how
scalarModel.hasChoices() works for example... basically we look at the
facet on either the property or the parameter, NOT on the facet of the
value of the class (ie the string).

    @Override
    public ApplicationAdvice appliesTo(final IModel<?> model) {
        if (!(model instanceof ScalarModel)) {
            return ApplicationAdvice.DOES_NOT_APPLY;
        }
        final ScalarModel scalarModel = (ScalarModel) model;
        if(!scalarModel.isScalarTypeAnyOf(scalarTypes)) {
            return ApplicationAdvice.DOES_NOT_APPLY;
        }
        final boolean hasNoChoices = !scalarModel.hasChoices();
        return appliesIf(hasNoChoices);
    }


In the domain object code if we have:

@Html
String html;

then the facet represents the @Html annotation on the property (or
parameter) "String html", not on "String" itself.

Hope that makes some sort of sense...

Cheers
Dan



>

Reply via email to