Revision history [back]

click to hide/show revision 1
initial version

answered 2015-08-26 11:25:53 +0800

chillworld gravatar image chillworld flag of Belgium

https://github.com/chillw...

I have a small workaround for this problem.

If you use a validator you can doe this :

Java:

private final Validator emptyCKEditorValidator = new AbstractValidator() {

    @Override
    public void validate(ValidationContext ctx) {
        String val = (String) ctx.getProperty().getValue();
        if (val == null || "".equals(val.trim())) {
            Clients.wrongValue(ctx.getBindContext().getComponent(), Messages.get(MZul.EMPTY_NOT_ALLOWED));
            addInvalidMessage(ctx, "");
        }
    }
};

Zul :

<ckeditor customConfigurationsPath="/js/ckeditor-config.js" value="@bind(fx.description) @validator(vm.emptyCKEditorValidator)" height="250px" />

This will trigger when fx will be saved.

Small explication :

The Clients.wrongValue(Component,String) will set the popup for the CKEditor.
The Messages.get(MZul.EMPTY_NOT_ALLOWED) will get the I18N from zul-x.x.x.x.jar.
If you use the MZul class, it's a little more readable then if you use the code directly from the msgzul.properties file.
So, this means that I have I18N activated for this and have the same message as constraint="no empty".

I still do the addInvalidMessage(ctx,"") because otherwise it will trigger the save command.

Greetz chill.

I have a small workaround for this problem.

If you use a validator you can doe do this :

Java:

private final Validator emptyCKEditorValidator = new AbstractValidator() {

    @Override
    public void validate(ValidationContext ctx) {
        String val = (String) ctx.getProperty().getValue();
        if (val == null || "".equals(val.trim())) {
            Clients.wrongValue(ctx.getBindContext().getComponent(), Messages.get(MZul.EMPTY_NOT_ALLOWED));
            addInvalidMessage(ctx, "");
        }
    }
};

Zul :

<ckeditor customConfigurationsPath="/js/ckeditor-config.js" value="@bind(fx.description) @validator(vm.emptyCKEditorValidator)" height="250px" />

This will trigger when fx will be saved.

Small explication :

The Clients.wrongValue(Component,String) will set the popup for the CKEditor.
The Messages.get(MZul.EMPTY_NOT_ALLOWED) will get the I18N from zul-x.x.x.x.jar.
If you use the MZul class, it's a little more readable then if you use the code directly from the msgzul.properties file.
So, this means that I have I18N activated for this and have the same message as constraint="no empty".

I still do the addInvalidMessage(ctx,"") because otherwise it will trigger the save command.

Greetz chill.

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More