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:au.org.theark.arkcalendar.component.dataentry.DropDownChoiceDataEntryPanel.java

License:Open Source License

@Override
protected void onBeforeRender() {
    /*// w  w  w  . ja  v a  2 s  .  c  o m
     * Can only call #getString(..) after adding the component to the page, otherwise it will cause 
     * a warning regardless of StringResourceModel().getString() or getLocalizer().getString(). 
     * Example warning is below:
     *  WARN  - Localizer                  - Tried to retrieve a localized string for a component that has not 
     *  yet been added to the page. This can sometimes lead to an invalid or no localized resource returned. 
     *  Make sure you are not calling Component#getString() inside your Component's constructor. 
     *  Offending component: [MarkupContainer [Component id = dataValueEntryPanel]]
     */
    if (this.missingValueVo != null) {
        // Load the text for the option "missing value" from resource properties
        String option = getLocalizer().getStringIgnoreSettings(dataValueDdc.getId() + ".missingValue", this,
                null, null);
        if (Strings.isEmpty(option)) {
            option = getLocalizer().getString("missingValue", this, "(missing value)");
        }
        this.missingValueVo.setValue(option);
    }
    super.onBeforeRender();
}

From source file:biz.turnonline.ecosystem.origin.frontend.myaccount.page.MyAccountBasics.java

License:Apache License

public MyAccountBasics() {
    add(new FirebaseAppInit(firebaseConfig));

    final MyAccountModel accountModel = new MyAccountModel();
    final IModel<Map<String, Country>> countriesModel = new CountriesModel();

    setModel(accountModel);/* w  w w  .  j  a  va 2s. com*/

    // form
    Form<Account> form = new Form<Account>("form", accountModel) {
        private static final long serialVersionUID = -938924956863034465L;

        @Override
        protected void onSubmit() {
            Account account = getModelObject();
            send(getPage(), Broadcast.BREADTH, new AccountUpdateEvent(account));
        }
    };
    add(form);

    PropertyModel<Boolean> companyModel = new PropertyModel<>(accountModel, "company");
    form.add(new CompanyPersonSwitcher("isCompanyRadioGroup", companyModel));

    // account email fieldset
    form.add(new Label("email", new PropertyModel<>(accountModel, "email")));

    // company basic info
    final CompanyBasicInfo<Account> basicInfo = new CompanyBasicInfo<Account>("companyData", accountModel) {
        private static final long serialVersionUID = -2992960490517951459L;

        @Override
        protected DropDownChoice<LegalForm> provideLegalForm(String componentId) {
            LegalFormListModel choices = new LegalFormListModel();
            return new IndicatingAjaxDropDown<>(componentId,
                    new LegalFormCodeModel(accountModel, "legalForm", choices), choices,
                    new LegalFormRenderer());
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            Account account = getModelObject();
            this.setVisible(account.getCompany());
        }
    };
    form.add(basicInfo);

    // company basic info panel behaviors
    basicInfo.addLegalForm(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = 6948210639258798921L;

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

    basicInfo.addVatId(new Behavior() {
        private static final long serialVersionUID = 100053137512632023L;

        @Override
        public void onConfigure(Component component) {
            super.onConfigure(component);
            Account account = basicInfo.getModelObject();
            boolean visible;
            if (account == null || account.getBusiness() == null) {
                visible = true;
            } else {
                Boolean vatPayer = account.getBusiness().getVatPayer();
                visible = vatPayer == null ? Boolean.FALSE : vatPayer;
            }

            component.setVisible(visible);
        }
    });

    final TextField taxId = basicInfo.getTaxId();
    final TextField vatId = basicInfo.getVatId();
    final CheckBox vatPayer = basicInfo.getVatPayer();

    basicInfo.addVatPayer(new AjaxFormSubmitBehavior(OnChangeAjaxBehavior.EVENT_NAME) {
        private static final long serialVersionUID = -1238082494184937003L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            Account account = (Account) basicInfo.getDefaultModelObject();
            String rawTaxIdValue = taxId.getRawInput();
            AccountBusiness business = account.getBusiness();

            if (rawTaxIdValue != null && Strings.isEmpty(business == null ? null : business.getVatId())) {
                // VAT country prefix proposal
                String country = business == null ? "" : business.getDomicile();
                country = country.toUpperCase();
                //noinspection unchecked
                vatId.getModel().setObject(country + rawTaxIdValue);
            }

            // must be set manually as getDefaultProcessing() returns false
            vatPayer.setModelObject(!(business == null ? Boolean.FALSE : business.getVatPayer()));

            if (target != null) {
                target.add(vatId.getParent());
            }
        }

        @Override
        public boolean getDefaultProcessing() {
            return false;
        }
    });

    // personal data panel
    PersonalDataPanel<Account> personalData = new PersonalDataPanel<Account>("personalData", accountModel) {
        private static final long serialVersionUID = -2808922906891760016L;

        @Override
        protected void onConfigure() {
            super.onConfigure();
            Account account = getModelObject();
            this.setVisible(!account.getCompany());
        }
    };
    form.add(personalData);

    // personal address panel
    PersonalAddressPanel<Account> address = new PersonalAddressPanel<Account>("personalAddress", accountModel) {
        private static final long serialVersionUID = 3481146248010938807L;

        @Override
        protected DropDownChoice<Country> provideCountry(String componentId) {
            return new IndicatingAjaxDropDown<>(componentId,
                    new PersonalAddressCountryModel(accountModel, countriesModel), new CountryRenderer(),
                    countriesModel);
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            Account account = getModelObject();
            this.setVisible(!account.getCompany());
        }
    };
    form.add(address);

    address.addCountry(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = -1016447969591778948L;

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

    // company address panel
    CompanyAddressPanel<Account> companyAddress;
    companyAddress = new CompanyAddressPanel<Account>("companyAddress", accountModel, false, false) {
        private static final long serialVersionUID = -6760545061622186549L;

        @Override
        protected DropDownChoice<Country> provideCountry(String componentId) {
            return new IndicatingAjaxDropDown<>(componentId,
                    new CompanyDomicileModel(accountModel, countriesModel), new CountryRenderer(),
                    countriesModel);
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            Account account = getModelObject();
            this.setVisible(account.getCompany());
        }
    };
    form.add(companyAddress);

    companyAddress.addCountry(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = -5476413125490349124L;

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

    IModel<AccountPostalAddress> postalAddressModel = new PropertyModel<>(accountModel, "postalAddress");
    IModel<Boolean> hasAddress = new PropertyModel<>(accountModel, "hasPostalAddress");
    PostalAddressPanel<AccountPostalAddress> postalAddress;
    postalAddress = new PostalAddressPanel<AccountPostalAddress>("postal-address", postalAddressModel,
            hasAddress) {
        private static final long serialVersionUID = -930960688138308527L;

        @Override
        protected DropDownChoice<Country> provideCountry(String componentId) {
            return new IndicatingAjaxDropDown<>(componentId,
                    new PostalAddressCountryModel(accountModel, countriesModel), new CountryRenderer(),
                    countriesModel);
        }
    };
    form.add(postalAddress);

    postalAddress.addStreet(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = 4050800366443676166L;

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

    PropertyModel<Object> billingContactModel = PropertyModel.of(accountModel, "billingContact");
    form.add(new SimplifiedContactFieldSet<>("contact", billingContactModel));
    // save button
    form.add(new IndicatingAjaxButton("save", new I18NResourceModel("button.save"), form));
}

From source file:by.parfen.disptaxi.webapp.etc.AutoComplitePage.java

License:Apache License

/**
 * Constructor./*  w w w  .  j  a  v  a2  s.  c o m*/
 */
public AutoComplitePage() {
    Injector.get().inject(this);

    sampleEvent = new SampleEvent();
    // selectedCity = cityService.get(15L);
    sampleEvent.setCityById(60L);
    streetsList = sampleEvent.getStreets();
    // pointsList = sampleEvent.getPointsList();

    final FeedbackPanel feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);
    add(feedback);

    Form<Void> form = new Form<Void>("form");
    add(form);

    final AutoCompleteTextField<String> field = new AutoCompleteTextField<String>("acStreet",
            new Model<String>("")) {
        @Override
        protected Iterator<String> getChoices(String input) {
            if (Strings.isEmpty(input)) {
                List<String> emptyList = Collections.emptyList();
                return emptyList.iterator();
            }

            List<String> choices = new ArrayList<String>(MAX_AUTO_COMPLETE_ELEMENTS);

            for (final Street streetItem : streetsList) {
                final String streetName = streetItem.getName();

                if (streetName.toUpperCase().startsWith(input.toUpperCase())) {
                    choices.add(streetName);
                    if (choices.size() == MAX_AUTO_COMPLETE_ELEMENTS) {
                        break;
                    }
                }
            }

            return choices.iterator();
        }
    };

    final AutoCompleteTextField<String> fieldPoint = new AutoCompleteTextField<String>("acPoint",
            new Model<String>("")) {
        @Override
        protected Iterator<String> getChoices(String input) {
            if (Strings.isEmpty(input)) {
                List<String> emptyList = Collections.emptyList();
                return emptyList.iterator();
            }

            List<String> choices = new ArrayList<String>(MAX_AUTO_COMPLETE_ELEMENTS);

            for (final Point pointItem : sampleEvent.getPointsList()) {
                final String pointName = pointItem.getName();

                if (pointName.toUpperCase().startsWith(input.toUpperCase())) {
                    choices.add(pointName);
                    if (choices.size() == MAX_AUTO_COMPLETE_ELEMENTS) {
                        break;
                    }
                }
            }

            return choices.iterator();
        }
    };

    final ItemPanel itemPanel = new ItemPanel("itemPanel");
    add(itemPanel);

    add(new Link<Void>("linkItemInfo") {

        @Override
        public void onClick() {
            info("onSubmit");
            info(itemPanel.getItemInfo());
        }

    });

    final Label label = new Label("label", form.getDefaultModel()) {

        @Override
        public void onEvent(IEvent<?> event) {
            Object payload = event.getPayload();
            if (payload instanceof SampleEvent) {
                SampleEvent sampelEvent = (SampleEvent) payload;
                setDefaultModel(Model
                        .of(sampelEvent.getSelectedStreetName() + ", " + sampelEvent.getSelectedPointName()));
                sampelEvent.getTarget().add(this);
            }
        }

    };

    label.setOutputMarkupId(true);
    add(label);

    form.add(field);
    form.add(fieldPoint);

    field.add(new AjaxFormSubmitBehavior(form, "onchange") {
        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            sampleEvent.setTarget(target);
            sampleEvent.setSelectedStreetName(field.getDefaultModelObjectAsString());
            sampleEvent.setSelectedPointName("");
            send(getPage(), Broadcast.BREADTH, sampleEvent);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
        }
    });

    fieldPoint.add(new AjaxFormSubmitBehavior(form, "onchange") {
        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            sampleEvent.setTarget(target);
            sampleEvent.setSelectedPointName(fieldPoint.getDefaultModelObjectAsString());
            send(getPage(), Broadcast.BREADTH, sampleEvent);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
        }
    });
}

From source file:by.parfen.disptaxi.webapp.etc.ChoicePage.java

License:Apache License

/**
 * Constructor./* w ww  .j a v  a  2 s .  c  o m*/
 */
public ChoicePage() {
    final City city = cityService.get(15L);
    List<Street> streetsList;
    streetsList = streetService.getAllByCity(city);
    for (Street streetItem : streetsList) {
        List<Point> pointsList = pointService.getAllByStreet(streetItem);
        List<String> pointNames = new ArrayList<String>();
        for (Point pointItem : pointsList) {
            pointNames.add(pointItem.getName());
        }
        pointsMap.put(streetItem.getName(), pointNames);
    }
    // pointsMap.put("", Arrays.asList("12", "22", "34"));
    // pointsMap.put("", Arrays.asList("2", "4", "45", "13", "78"));
    // pointsMap.put("", Arrays.asList("10", "12", "22", "4", "6"));

    IModel<List<? extends String>> makeChoices = new AbstractReadOnlyModel<List<? extends String>>() {
        @Override
        public List<String> getObject() {
            return new ArrayList<String>(pointsMap.keySet());
        }

    };

    IModel<List<? extends String>> modelChoices = new AbstractReadOnlyModel<List<? extends String>>() {
        @Override
        public List<String> getObject() {
            List<String> points = pointsMap.get(selectedStreetName);
            if (points == null) {
                points = Collections.emptyList();
            }
            return points;
        }

    };

    Form<Void> form = new Form<Void>("form");
    add(form);

    final DropDownChoice<String> streets = new DropDownChoice<String>("streets",
            new PropertyModel<String>(this, "selectedStreetName"), makeChoices);

    final DropDownChoice<String> points = new DropDownChoice<String>("points", new Model<String>(),
            modelChoices);
    points.setOutputMarkupId(true);

    form.add(streets);
    form.add(points);

    final FeedbackPanel feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);
    add(feedback);

    form.add(new AjaxButton("go") {
        @Override
        protected void onAfterSubmit(AjaxRequestTarget target, Form<?> form) {
            super.onAfterSubmit(target, form);
            info(" : " + streets.getModelObject() + " "
                    + points.getModelObject());
            target.add(feedback);
        }
    });

    streets.add(new AjaxFormComponentUpdatingBehavior("change") {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(points);
        }
    });

    Form<Void> ajaxForm = new Form<Void>("ajaxForm");
    add(ajaxForm);

    final AutoCompleteTextField<String> field = new AutoCompleteTextField<String>("ac", new Model<String>("")) {
        @Override
        protected Iterator<String> getChoices(String input) {
            if (Strings.isEmpty(input)) {
                List<String> emptyList = Collections.emptyList();
                return emptyList.iterator();
            }

            List<String> choices = new ArrayList<String>(10);

            List<Street> streetsList = streetService.getAllByCity(city);

            for (final Street streetItem : streetsList) {
                final String streetName = streetItem.getName();

                if (streetName.toUpperCase().startsWith(input.toUpperCase())) {
                    choices.add(streetName);
                    if (choices.size() == 10) {
                        break;
                    }
                }
            }

            return choices.iterator();
        }
    };

    ajaxForm.add(field);

    final Label label = new Label("selectedValue", field.getDefaultModel());
    label.setOutputMarkupId(true);
    ajaxForm.add(label);

    field.add(new AjaxFormSubmitBehavior(ajaxForm, "onchange") {
        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            target.add(label);
            List<Street> streetList = streetService.getAllByCityAndName(city,
                    label.getDefaultModelObjectAsString());
            if (streetList.size() == 1) {
                setSelectedStreet(streetList.get(0));
            }
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
        }
    });
}

From source file:com.aplombee.navigator.ItemsNavigatorBase.java

License:Apache License

@Override
protected void onInitialize() {
    super.onInitialize();
    add(more = newMore());//from  w ww.  jav  a 2  s .co  m
    if (!Strings.isEmpty(getCssClass())) {
        AttributeModifier cssClassModifier = new AttributeModifier("class", getCssClass());
        more.add(cssClassModifier);
    }
}

From source file:com.asptt.plongee.resa.ui.web.wicket.page.admin.GererAdherents.java

public List<Adherent> getMatchingAdherents(String search) {
    if (Strings.isEmpty(search)) {
        List<Adherent> emptyList = Collections.emptyList();
        return emptyList;
    }/*  w w w.ja va  2s  .c om*/

    if (list == null) {
        list = getResaSession().getAdherentService().rechercherAdherentsActifs();
    }

    ArrayList<Adherent> newList = new ArrayList<Adherent>();
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).getNom().startsWith(search.toUpperCase())) {
            newList.add(list.get(i));
        }
    }
    return newList;
}

From source file:com.asptt.plongee.resa.ui.web.wicket.page.inscription.InscriptionFilleulPlongeePage.java

public List<Adherent> getMatchingAdherents(String search) {
    if (Strings.isEmpty(search)) {
        List<Adherent> emptyList = Collections.emptyList();
        return emptyList;
    }/*from w ww.  ja v a  2  s. co m*/

    if (list == null) {
        list = getResaSession().getAdherentService().rechercherExternes();
    }

    ArrayList<Adherent> newList = new ArrayList<Adherent>();
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).getNom().startsWith(search.toUpperCase())) {
            newList.add(list.get(i));
        }
    }
    return newList;
}

From source file:com.asptt.plongee.resa.ui.web.wicket.page.secretariat.DesInscriptionPlongeePage.java

public List<Adherent> getMatchingAdherents(String search) {
    if (Strings.isEmpty(search)) {
        List<Adherent> emptyList = Collections.emptyList();
        return emptyList;
    }/*from   ww  w  . ja v  a  2 s  .  c  om*/

    // Dans le cas de la desinscription, la list de recherche
    // est compose des adhrents actifs et des externes ( priori ils
    // existent dans ce cas)
    List<Adherent> list = getResaSession().getAdherentService().rechercherAdherentsActifs();
    list.addAll(getResaSession().getAdherentService().rechercherExternes());

    ArrayList<Adherent> newList = new ArrayList<Adherent>();
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).getNom().startsWith(search.toUpperCase())) {
            newList.add(list.get(i));
        }
    }
    return newList;
}

From source file:com.asptt.plongee.resa.wicket.page.admin.fichesecurite.ChercherPlongeur.java

public List<Adherent> getMatchingAdherents(String search) {
    if (Strings.isEmpty(search)) {
        List<Adherent> emptyList = Collections.emptyList();
        return emptyList;
    }/*from w w  w .  ja v a  2  s .co  m*/

    if (list == null) {
        list = ResaSession.get().getAdherentService().rechercherAdherentsEtExts();
    }

    ArrayList<Adherent> newList = new ArrayList<Adherent>();
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).getNom().startsWith(search.toUpperCase())) {
            newList.add(list.get(i));
        }
    }
    return newList;
}

From source file:com.asptt.plongee.resa.wicket.page.admin.fichesecurite.SaisieFSAjoutPlongeurPanel.java

public List<Adherent> getMatchingAdherents(String search) {
    if (Strings.isEmpty(search)) {
        List<Adherent> emptyList = Collections.emptyList();
        return emptyList;
    }/*from  w  ww  .  j a  va2s.com*/

    if (list == null) {
        list = ResaSession.get().getAdherentService().rechercherPlongeurs();
    }

    ArrayList<Adherent> newList = new ArrayList<Adherent>();
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).getNom().startsWith(search.toUpperCase())) {
            newList.add(list.get(i));
        }
    }
    return newList;
}