Search in sources :

Example 1 with PropertyResolverConverter

use of org.apache.wicket.core.util.lang.PropertyResolverConverter in project midpoint by Evolveum.

the class LookupPropertyModel method setObject.

@Override
public void setObject(T object) {
    final String expression = propertyExpression();
    PropertyResolverConverter prc;
    prc = new PropertyResolverConverter(Application.get().getConverterLocator(), Session.get().getLocale());
    if (object instanceof String) {
        String label = (String) object;
        String key;
        if (StringUtils.isBlank(label)) {
            PropertyResolver.setValue(expression, getInnermostModelOrObject(), null, prc);
        } else {
            if (!isStrict || lookupTable == null) {
                // set default value from input and overwrite later if key is found
                PropertyResolver.setValue(expression, getInnermostModelOrObject(), label, prc);
            }
            if (lookupTable != null) {
                for (LookupTableRowType row : lookupTable.getRow()) {
                    if (label.equals(WebComponentUtil.getOrigStringFromPoly(row.getLabel()))) {
                        key = row.getKey();
                        PropertyResolver.setValue(expression, getInnermostModelOrObject(), key, prc);
                    }
                }
            }
        }
    } else if (object == null) {
        PropertyResolver.setValue(expression, getInnermostModelOrObject(), object, prc);
    }
}
Also used : PropertyResolverConverter(org.apache.wicket.core.util.lang.PropertyResolverConverter) LookupTableRowType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType)

Aggregations

LookupTableRowType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType)1 PropertyResolverConverter (org.apache.wicket.core.util.lang.PropertyResolverConverter)1