Example usage for org.apache.wicket.util.string Strings isEmpty

List of usage examples for org.apache.wicket.util.string Strings isEmpty

Introduction

In this page you can find the example usage for org.apache.wicket.util.string Strings isEmpty.

Prototype

public static boolean isEmpty(final CharSequence string) 

Source Link

Document

Checks whether the string is considered empty.

Usage

From source file:jp.xet.baseunits.wicket.CalendarDateConverter.java

License:Apache License

@Override
public CalendarDate convertToObject(String value, Locale locale) {
    if (Strings.isEmpty(value)) {
        return null;
    }//from  w ww  .  j a  va 2s .co  m

    try {
        return CalendarDate.parse(value, datePattern);
    } catch (ParseException e) {
        throw newConversionException("Cannot convert '" + value + "' to CalendarDate", value, locale);
    }
}

From source file:jp.xet.baseunits.wicket.CalendarMonthConverter.java

License:Apache License

@Override
public CalendarMonth convertToObject(String value, Locale locale) {
    if (Strings.isEmpty(value)) {
        return null;
    }// ww  w .  j a v a 2  s.  c om

    try {
        return CalendarMonth.parse(value, datePattern);
    } catch (ParseException e) {
        throw newConversionException("Cannot convert '" + value + "' to CalendarMonth", value, locale);
    }
}

From source file:jp.xet.baseunits.wicket.TimeOfDayConverter.java

License:Apache License

@Override
public TimeOfDay convertToObject(String value, Locale locale) {
    if (Strings.isEmpty(value)) {
        return null;
    }//from  w  w w .ja va2s.  com

    try {
        return TimeOfDay.parse(value, timePattern);
    } catch (ParseException e) {
        throw newConversionException("Cannot convert '" + value + "' to TimeOfDay", value, locale);
    }
}

From source file:jp.xet.baseunits.wicket.TimePointConverter.java

License:Apache License

@Override
public TimePoint convertToObject(String value, Locale locale) {
    if (Strings.isEmpty(value)) {
        return null;
    }//from  w w w .  j a  v  a 2s.c om

    try {
        return TimePoint.parse(value, datePattern, timeZone);
    } catch (ParseException e) {
        throw newConversionException("Cannot convert '" + value + "' to TimePoint", value, locale);
    }
}

From source file:jp.xet.baseunits.wicket.TimePointOfDayConverter.java

License:Apache License

@Override
public TimePointOfDay convertToObject(String value, Locale locale) {
    if (Strings.isEmpty(value)) {
        return null;
    }/*ww  w.  ja v a 2 s .  c  o m*/

    try {
        return TimePointOfDay.parse(value, timePattern, timeZone);
    } catch (ParseException e) {
        throw newConversionException("Cannot convert '" + value + "' to TimePointOfDay", value, locale);
    }
}

From source file:jp.xet.uncommons.wicket.behavior.CanonicalRefBehavior.java

License:Apache License

@Override
public void renderHead(Component component, IHeaderResponse response) {
    String canonicalUrl = canonicalUrlModel.getObject();
    if (Strings.isEmpty(canonicalUrl) == false) {
        response.renderString(String.format(FORMAT, Strings.escapeMarkup(canonicalUrl)));
    }//  w w  w.  ja  va2 s .  c o m
}

From source file:jp.xet.uncommons.wicket.google.analytics.GoogleAnalyticsScriptPanel.java

License:Apache License

/**
 * ??//from   w  w  w .java 2 s  . c o  m
 * 
 * @param id The non-null id of this component
 * @param urlModel Model of URL
 * @param accountNameModel Model of tracking ID
 * @param domainNameModel Model of domain name
 */
public GoogleAnalyticsScriptPanel(String id, final IModel<String> urlModel,
        final IModel<String> accountNameModel, final IModel<String> domainNameModel) {
    super(id, urlModel);
    add(new Label("accountName", accountNameModel) {

        @Override
        protected void onConfigure() {
            super.onConfigure();
            if (accountNameModel == null) {
                setVisibilityAllowed(false);
            } else {
                setVisibilityAllowed(Strings.isEmpty(accountNameModel.getObject()) == false);
            }
        }
    }.setRenderBodyOnly(true));
    add(new Label("trackingUrl", urlModel) {

        @Override
        protected void onConfigure() {
            super.onConfigure();
            if (urlModel == null) {
                setVisibilityAllowed(false);
            } else {
                setVisibilityAllowed(Strings.isEmpty(urlModel.getObject()) == false);
            }
        }
    }.setRenderBodyOnly(true));
    add(new Label("domainName", domainNameModel) {

        @Override
        protected void onConfigure() {
            super.onConfigure();
            if (domainNameModel == null) {
                setVisibilityAllowed(false);
            } else {
                setVisibilityAllowed(Strings.isEmpty(domainNameModel.getObject()) == false);
            }
        }
    }.setRenderBodyOnly(true));
}

From source file:jp.xet.uncommons.wicket.gp.SizedImage.java

License:Apache License

@Override
protected void onComponentTag(ComponentTag tag) {
    super.onComponentTag(tag);

    tag.put("width", width);
    tag.put("height", height);
    if (Strings.isEmpty(alt) == false) {
        CharSequence escapedAlt = Strings.escapeMarkup(alt);
        tag.put("alt", escapedAlt);
        tag.put("title", escapedAlt);
    }/* ww w.j  av a2s .  c o m*/
}

From source file:lt.inventi.wicket.component.repeater.EmptyContainer.java

License:Apache License

private static boolean empty(Object obj) {
    boolean empty = false;
    if (null == obj) {
        empty = true;/*from   w  w w  . ja v  a 2  s .  co m*/
    } else if (obj instanceof Boolean) {
        empty = !(Boolean) obj;
    } else if (obj instanceof Collection) {
        empty = ((Collection<?>) obj).size() == 0;
    } else if (obj instanceof String) {
        empty = Strings.isEmpty((String) obj);
    } else if (obj.getClass().isArray()) {
        empty = ((Object[]) obj).length == 0;
    }
    return empty;
}

From source file:name.marcelomorales.siqisiqi.examples.crud.parameters.ListParameters.java

License:Apache License

public ListParameters() {

    add(table = new AjaxFallbackDefaultDataTable<>("parameters", new ArrayList<IColumn<Parameter, String>>() {
        {//w w w.  j a  v a 2 s .c o m
            add(new PropertyColumn<Parameter, String>(Model.of("Name"), "name"));
        }
    }, new SortableDataProvider<Parameter, String>() {

        @Override
        public Iterator<? extends Parameter> iterator(long first, long count) {
            return parametersEdit.list(null, first, count).iterator();
        }

        @Override
        public long size() {
            return parametersEdit.count(null);
        }

        @Override
        public IModel<Parameter> model(Parameter object) {
            return Model.of(object);
        }
    }, 10).setOutputMarkupId(true));

    add(queryForm = new Form<String>("query param form", Model.of("")) {

        private final Component queryParamValueLabel;

        {
            setOutputMarkupId(true);

            add(queryParamValueLabel = new Label("value", new AbstractReadOnlyModel<Object>() {

                @Override
                public Object getObject() {
                    final String formModelObject = getModelObject();
                    if (Strings.isEmpty(formModelObject)) {
                        return "";
                    }

                    try {
                        return parametersEdit.getString(formModelObject);
                    } catch (ExecutionException e) {
                        return "Error: " + e.getMessage();
                    }
                }
            }).setOutputMarkupId(true));

            add(new TextField<>("param", getModel()).setOutputMarkupId(true).add(new OnChangeAjaxBehavior() {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    target.add(queryParamValueLabel);
                }
            }));
        }
    });

    add(new Form<ArrayList<String>>("set parameter form", new Model<>(Lists.newArrayList("", ""))) {

        {
            setOutputMarkupId(true);

            add(new TextField<>("param name", new PropertyModel<>(getModel(), "0"))
                    .add(StringValidator.maximumLength(200)).setOutputMarkupId(true));
            add(new TextField<>("param value", new PropertyModel<>(getModel(), "1"))
                    .add(StringValidator.maximumLength(2000)).setOutputMarkupId(true));

            add(new AjaxButton("submit", this) {

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    ArrayList<String> strings = (ArrayList<String>) form.getModelObject();

                    Parameter parameter = new Parameter();
                    parameter.setName(strings.get(0));

                    parametersEdit.customize(parameter, strings.get(1));

                    target.add(form);
                    target.add(queryForm);
                    target.add(table);
                }
            });

        }
    });
}