Overriding CMS properties

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Overriding CMS properties

Joris Meijer

Hi list,

 

For a customer I would like to override some properties in the CMS, e.g. the labels that are displayed whenever a required field is empty. I thought I could do this by copying the class (e.g. org.hippoecm.frontend.editor.validator.ValidationFeedback) along with the resource bundle, but this seems not to work.

 

What is the best way to achieve this?

 

Thanks in advance for any info.


Joris Meijer

This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Overriding CMS properties

Frank van Lankvelt
On Mon, Jan 21, 2013 at 12:20 PM, Meijer, Joris
<[hidden email]> wrote:

> Hi list,
>
>
>
> For a customer I would like to override some properties in the CMS, e.g. the
> labels that are displayed whenever a required field is empty. I thought I
> could do this by copying the class (e.g.
> org.hippoecm.frontend.editor.validator.ValidationFeedback) along with the
> resource bundle, but this seems not to work.
>
>
>
> What is the best way to achieve this?
>
>
this is not really a well-supported extension point of the cms; you'll
notice that it is not available in the hippo-cms-api module.

It's probably possible to implement this functionality by replacing
the ValidationPlugin.

Note that an alternative might be to define your own validators.  This
way, you won't need to override existing messages.
See http://www.onehippo.org/7_8/library/concepts/plugins/create-a-custom-field-validator.html
for details.

cheers, Frank

>
> Thanks in advance for any info.
>
>
> Joris Meijer
>
> This message contains information that may be privileged or confidential and
> is the property of the Capgemini Group. It is intended only for the person
> to whom it is addressed. If you are not the intended recipient, you are not
> authorized to read, print, retain, copy, disseminate, distribute, or use
> this message or any part thereof. If you receive this message in error,
> please notify the sender immediately and delete all copies of this message.
>
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Overriding CMS properties

Joris Meijer
Hi Frank,

Thanks for your hints. I added a "requiredfield" validator "RequiredFieldValidator" which performs a preValidation for type "Date". The funny thing is that the "validate" method is not called when the field is empty/null. This means I cannot override the error message(s) which I put in "validationTranslator/hippostd:translations/requiredfuild".

See my code in RequiredFieldValidator below:
-----------


public class RequiredFieldValidator extends AbstractCmsValidator {

    public RequiredFieldValidator(IPluginContext context, IPluginConfig config) {
        super(context, config);
    }

    @Override
    public void preValidation(IFieldValidator type) throws ValidationException {
        // only used to check date fields for non-emptyness
        if (!"Date".equals(type.getFieldType().getType())) {
            throw new ValidationException("Only use this validator for date fields");
        }
    }

    @Override
    public Set<Violation> validate(IFieldValidator fieldValidator, JcrNodeModel model, IModel childModel) throws ValidationException {
        Set<Violation> violations = new HashSet<Violation>();
        Date value = (Date) childModel.getObject();
        // field can not be empty
        if (value == null) {
            violations.add(fieldValidator.newValueViolation(childModel,getTranslation()));
        }
        return violations;
    }
}

What am I doing wrong?

Best regards,
Joris

_______________________________________________________________________
Joris Meijer
Consultant Online Technology | Capgemini Online


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Frank van Lankvelt
Sent: maandag 21 januari 2013 21:44
To: Hippo CMS 7 implementation list
Cc: [hidden email]
Subject: Re: [Hippo-cms7-user] Overriding CMS properties

On Mon, Jan 21, 2013 at 12:20 PM, Meijer, Joris <[hidden email]> wrote:

> Hi list,
>
>
>
> For a customer I would like to override some properties in the CMS,
> e.g. the labels that are displayed whenever a required field is empty.
> I thought I could do this by copying the class (e.g.
> org.hippoecm.frontend.editor.validator.ValidationFeedback) along with
> the resource bundle, but this seems not to work.
>
>
>
> What is the best way to achieve this?
>
>
this is not really a well-supported extension point of the cms; you'll notice that it is not available in the hippo-cms-api module.

It's probably possible to implement this functionality by replacing the ValidationPlugin.

Note that an alternative might be to define your own validators.  This way, you won't need to override existing messages.
See http://www.onehippo.org/7_8/library/concepts/plugins/create-a-custom-field-validator.html
for details.

cheers, Frank

>
> Thanks in advance for any info.
>
>
> Joris Meijer
>
> This message contains information that may be privileged or
> confidential and is the property of the Capgemini Group. It is
> intended only for the person to whom it is addressed. If you are not
> the intended recipient, you are not authorized to read, print, retain,
> copy, disseminate, distribute, or use this message or any part
> thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
>
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html