List of usage examples for org.apache.wicket.markup.html.panel FeedbackPanel FeedbackPanel
public FeedbackPanel(final String id, IFeedbackMessageFilter filter)
From source file:almira.sample.web.IndexPage.java
License:Apache License
/** * Constructor./*w w w.ja v a2 s .com*/ */ public IndexPage() { super(); final Catapult catapult = new Catapult(); final CompoundPropertyModel<Catapult> model = new CompoundPropertyModel<Catapult>(catapult); CATAPULT_CREATION_FORM.setModel(model); add(CATAPULT_CREATION_FORM); // add feedback panel to display any feedback messages for this form add(new FeedbackPanel("feedback", new ContainerFeedbackMessageFilter(CATAPULT_CREATION_FORM))); }
From source file:ar.edu.udc.cirtock.view.intranet.negocio.FormularioInsumo.java
License:Apache License
public FormularioInsumo(final PageParameters parameters) { super(parameters); add(new FeedbackPanel("feedbackErrors", new ExactLevelFeedbackMessageFilter(FeedbackMessage.ERROR))); formulario = new Form("formulario_insumo"); nombre = new RequiredTextField<String>("nombre", new Model()); nombre.add(new IValidator<String>() { @Override/*from ww w . j a v a2 s . com*/ public void validate(IValidatable<String> validatable) { String nombre = validatable.getValue().trim().toUpperCase(); if (!nombre.matches("^[\\w\\s]{3,20}$")) { ValidationError error = new ValidationError(); error.setMessage("El campo 'nombre' no es valido"); validatable.error(error); } } }); formulario.add(nombre); descripcion = new RequiredTextField<String>("descripcion", new Model()); descripcion.add(new IValidator<String>() { @Override public void validate(IValidatable<String> validatable) { String descripcion = validatable.getValue().trim().toUpperCase(); if (!descripcion.matches("^[A-Za-z ]{3,50}$")) { ValidationError error = new ValidationError(); error.setMessage("El campo 'descripcion' no es valido"); validatable.error(error); } } }); formulario.add(descripcion); cantidad = new NumberTextField<Integer>("cantidad", new Model()); cantidad.setType(Integer.class); cantidad.add(new IValidator<Integer>() { @Override public void validate(IValidatable<Integer> validatable) { Integer cantidad = validatable.getValue(); if (cantidad < 0) { ValidationError error = new ValidationError(); error.setMessage("El campo 'cantidad' no es valido"); validatable.error(error); } } }); formulario.add(cantidad); formulario.add(new Button("enviar") { /** * */ private static final long serialVersionUID = 1L; public void onSubmit() { String desc = (String) descripcion.getModelObject(); String nomb = (String) nombre.getModelObject(); Integer cant = cantidad.getModelObject(); Connection conn = null; try { conn = CirtockConnection.getConection("cirtock", "cirtock", "cirtock"); Insumo ins = new Insumo(); ins.setDescripcion(desc); ins.setNombre(nomb); ins.setCantidad(cant); ins.insert("", conn); } catch (CirtockException e) { System.out.println("Error al acceder a la base de datos"); } finally { try { conn.close(); } catch (SQLException e) { ; } } setResponsePage(InsumoPage.class); }; }); add(formulario); }
From source file:com.cubeia.backoffice.web.wallet.EditCurrencies.java
License:Open Source License
/** * Constructor that is invoked when page is invoked without a session. * *///from ww w .j a va2 s. co m @SuppressWarnings("serial") public EditCurrencies() { add(new FeedbackPanel("feedback", new ComponentFeedbackMessageFilter(EditCurrencies.this))); IModel<List<Currency>> currencyModel = new LoadableDetachableModel<List<Currency>>() { @Override protected List<Currency> load() { CurrencyListResult supportedCurrencies = walletService.getSupportedCurrencies(); if (supportedCurrencies == null) { return Collections.<Currency>emptyList(); } ArrayList<Currency> curs = new ArrayList<Currency>(supportedCurrencies.getCurrencies()); log.debug("got currencies: {}", curs); Collections.sort(curs, new Comparator<Currency>() { @Override public int compare(Currency o1, Currency o2) { return o1.getCode().compareTo(o2.getCode()); } }); return curs; } }; add(new ListView<Currency>("currencies", currencyModel) { @Override protected void populateItem(ListItem<Currency> item) { final Currency c = item.getModelObject(); item.add(new Label("code", Model.of(c.getCode()))); item.add(new Label("digits", Model.of(c.getFractionalDigits()))); item.add(new Link<String>("removeLink") { @Override public void onClick() { log.debug("removing currency: {}", c); walletService.removeCurrency(c.getCode()); } }.add(new ConfirmOnclickAttributeModifier("Really remove this currency?"))); } }); final CompoundPropertyModel<Currency> newCurrencyModel = new CompoundPropertyModel<Currency>( new Currency(null, 2)); Form<Currency> addForm = new Form<Currency>("addForm", newCurrencyModel) { @Override protected void onSubmit() { Currency cur = getModelObject(); log.debug("submit: {}", cur); try { walletService.addCurrency(cur); } catch (Exception e) { error("Error creating currency: " + e.getMessage()); return; } info("Added currency " + cur.getCode() + " with " + cur.getFractionalDigits() + " fractional digits"); newCurrencyModel.setObject(new Currency(null, 2)); } }; addForm.add(new RequiredTextField<String>("code", newCurrencyModel.<String>bind("code")) .add(StringValidator.exactLength(3))); addForm.add(new RequiredTextField<Integer>("digits", newCurrencyModel.<Integer>bind("fractionalDigits")) .add(new RangeValidator<Integer>(0, 8))); addForm.add(new FeedbackPanel("feedback", new ContainerFeedbackMessageFilter(addForm))); addForm.add(new WebMarkupContainer("submitButton") .add(new ConfirmOnclickAttributeModifier("Are you sure you want to add this currency?"))); add(addForm); }
From source file:com.cubeia.games.poker.admin.wicket.pages.wallet.EditCurrencies.java
License:Open Source License
/** * Constructor that is invoked when page is invoked without a session. * *///w w w . j a v a2 s. com @SuppressWarnings("serial") public EditCurrencies(PageParameters parameters) { super(parameters); add(new FeedbackPanel("feedback", new ComponentFeedbackMessageFilter(EditCurrencies.this))); IModel<List<Currency>> currencyModel = new LoadableDetachableModel<List<Currency>>() { @Override protected List<Currency> load() { CurrencyListResult supportedCurrencies = walletService.getSupportedCurrencies(); if (supportedCurrencies == null) { return Collections.<Currency>emptyList(); } ArrayList<Currency> curs = new ArrayList<Currency>(supportedCurrencies.getCurrencies()); log.debug("got currencies: {}", curs); Collections.sort(curs, new Comparator<Currency>() { @Override public int compare(Currency o1, Currency o2) { return o1.getCode().compareTo(o2.getCode()); } }); return curs; } }; add(new ListView<Currency>("currencies", currencyModel) { @Override protected void populateItem(ListItem<Currency> item) { final Currency c = item.getModelObject(); item.add(new Label("code", Model.of(c.getCode()))); item.add(new Label("digits", Model.of(c.getFractionalDigits()))); item.add(new Link<String>("removeLink") { @Override public void onClick() { log.debug("removing currency: {}", c); walletService.removeCurrency(c.getCode()); } }.add(new ConfirmOnclickAttributeModifier("Really remove this currency?"))); } }); final CompoundPropertyModel<Currency> newCurrencyModel = new CompoundPropertyModel<Currency>( new Currency(null, 2)); Form<Currency> addForm = new Form<Currency>("addForm", newCurrencyModel) { @Override protected void onSubmit() { Currency cur = getModelObject(); log.debug("submit: {}", cur); try { walletService.addCurrency(cur); } catch (Exception e) { error("Error creating currency: " + e.getMessage()); return; } info("Added currency " + cur.getCode() + " with " + cur.getFractionalDigits() + " fractional digits"); newCurrencyModel.setObject(new Currency(null, 2)); } }; addForm.add(new RequiredTextField<String>("code", newCurrencyModel.<String>bind("code")) .add(StringValidator.exactLength(3))); addForm.add(new RequiredTextField<Integer>("digits", newCurrencyModel.<Integer>bind("fractionalDigits")) .add(new RangeValidator<Integer>(0, 8))); addForm.add(new FeedbackPanel("feedback", new ContainerFeedbackMessageFilter(addForm))); addForm.add(new WebMarkupContainer("submitButton") .add(new ConfirmOnclickAttributeModifier("Are you sure you want to add this currency?"))); add(addForm); }
From source file:com.evolveum.midpoint.gui.impl.component.form.TriStateFormGroup.java
License:Apache License
private void initLayout(IModel<String> label, final String tooltipKey, boolean isTooltipInModal, String labelCssClass, String textCssClass, boolean required, boolean isSimilarAsPropertyPanel) { WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER); add(labelContainer);/*from w w w . java2s . c o m*/ Label l = new Label(ID_LABEL, label); if (StringUtils.isNotEmpty(labelCssClass)) { labelContainer.add(AttributeAppender.prepend("class", labelCssClass)); } if (isSimilarAsPropertyPanel) { labelContainer.add(AttributeAppender.prepend("class", " col-xs-2 prism-property-label ")); } else { labelContainer.add(AttributeAppender.prepend("class", " control-label ")); } labelContainer.add(l); Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>()); tooltipLabel.add(new AttributeAppender("data-original-title", new IModel<String>() { @Override public String getObject() { return getString(tooltipKey); } })); tooltipLabel.add(new InfoTooltipBehavior(isTooltipInModal)); tooltipLabel.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return tooltipKey != null; } }); tooltipLabel.setOutputMarkupId(true); tooltipLabel.setOutputMarkupPlaceholderTag(true); labelContainer.add(tooltipLabel); WebMarkupContainer requiredContainer = new WebMarkupContainer(ID_REQUIRED); requiredContainer.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return required; } }); labelContainer.add(requiredContainer); WebMarkupContainer propertyLabel = new WebMarkupContainer(ID_PROPERTY_LABEL); WebMarkupContainer rowLabel = new WebMarkupContainer(ID_ROW); WebMarkupContainer valueWrapper = new WebMarkupContainer(ID_VALUE_WRAPPER); if (StringUtils.isNotEmpty(textCssClass)) { valueWrapper.add(AttributeAppender.prepend("class", textCssClass)); } if (isSimilarAsPropertyPanel) { propertyLabel.add(AttributeAppender.prepend("class", " col-md-10 prism-property-value ")); rowLabel.add(AttributeAppender.prepend("class", " row ")); } propertyLabel.add(rowLabel); rowLabel.add(valueWrapper); add(propertyLabel); TriStateComboPanel triStateCombo = new TriStateComboPanel(ID_VALUE, getModel()); ; valueWrapper.add(triStateCombo); FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(triStateCombo.getBaseFormComponent())); feedback.setOutputMarkupId(true); valueWrapper.add(feedback); }
From source file:com.evolveum.midpoint.web.component.data.TableConfigurationPanel.java
License:Apache License
private void initPopoverLayout() { WebMarkupContainer popover = new WebMarkupContainer(ID_POPOVER); popover.setOutputMarkupId(true);//from w w w. j ava 2s . c o m add(popover); Form form = new Form(ID_FORM); popover.add(form); AjaxSubmitButton button = new AjaxSubmitButton(ID_BUTTON) { @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(TableConfigurationPanel.this .get(createComponentPath(ID_POPOVER, ID_FORM, "inputFeedback"))); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { pageSizeChanged(target); } }; form.add(button); TextField input = new TextField(ID_INPUT, createInputModel()); input.add(new RangeValidator(5, 100)); input.setLabel(createStringResource("PageSizePopover.title")); input.add(new SearchFormEnterBehavior(button)); input.setType(Integer.class); input.setOutputMarkupId(true); FeedbackPanel feedback = new FeedbackPanel("inputFeedback", new ComponentFeedbackMessageFilter(input)); feedback.setOutputMarkupId(true); form.add(feedback); form.add(input); }
From source file:com.evolveum.midpoint.web.component.form.DateFormGroup.java
License:Apache License
private void initLayout(IModel<String> label, String labelSize, String textSize, boolean required) { Label l = new Label(ID_LABEL, label); if (StringUtils.isNotEmpty(labelSize)) { l.add(AttributeAppender.prepend("class", labelSize)); }// w w w . j a v a 2s.c o m add(l); WebMarkupContainer dateWrapper = new WebMarkupContainer(ID_DATE_WRAPPER); if (StringUtils.isNotEmpty(textSize)) { dateWrapper.add(AttributeAppender.prepend("class", textSize)); } add(dateWrapper); DateInput date = new DateInput(ID_DATE, new XmlGregorianCalendarModel(getModel())); date.setRequired(required); date.setLabel(label); dateWrapper.add(date); FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(date)); dateWrapper.add(feedback); }
From source file:com.evolveum.midpoint.web.component.form.DropDownFormGroup.java
License:Apache License
private void initLayout(IModel<List<T>> choices, IChoiceRenderer renderer, IModel<String> label, String labelSize, String textSize, boolean required) { Label l = new Label(ID_LABEL, label); if (StringUtils.isNotEmpty(labelSize)) { l.add(AttributeAppender.prepend("class", labelSize)); }/*w w w.j a v a2 s . c o m*/ add(l); WebMarkupContainer selectWrapper = new WebMarkupContainer(ID_SELECT_WRAPPER); if (StringUtils.isNotEmpty(textSize)) { selectWrapper.add(AttributeAppender.prepend("class", textSize)); } add(selectWrapper); DropDownChoice select = createDropDown(ID_SELECT, choices, renderer, required); select.setLabel(label); selectWrapper.add(select); FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(select)); feedback.setOutputMarkupId(true); selectWrapper.add(feedback); }
From source file:com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel.java
License:Apache License
private void initLayout(final IModel<String> label, final String labelSize, final String textSize) { Label l = new Label(ID_LABEL, label); if (StringUtils.isNotEmpty(labelSize)) { l.add(AttributeAppender.prepend("class", labelSize)); }/*w ww .j a v a2 s . c o m*/ add(l); WebMarkupContainer addFirstContainer = new WebMarkupContainer(ID_ADD_FIRST_CONTAINER); addFirstContainer.setOutputMarkupId(true); addFirstContainer.setOutputMarkupPlaceholderTag(true); addFirstContainer.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return getModelObject().isEmpty(); } }); add(addFirstContainer); AjaxLink addFirst = new AjaxLink(ID_ADD_FIRST) { @Override public void onClick(AjaxRequestTarget target) { addFirstPerformed(target); } }; addFirstContainer.add(addFirst); ListView repeater = new ListView<T>(ID_REPEATER, getModel()) { @Override protected void populateItem(final ListItem<T> listItem) { WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER); textWrapper.add(AttributeAppender.prepend("class", new AbstractReadOnlyModel<String>() { @Override public String getObject() { StringBuilder sb = new StringBuilder(); if (StringUtils.isNotEmpty(textSize)) { sb.append(textSize).append(' '); } if (listItem.getIndex() > 0 && StringUtils.isNotEmpty(getOffsetClass())) { sb.append(getOffsetClass()).append(' '); sb.append(CLASS_MULTI_VALUE); } return sb.toString(); } })); listItem.add(textWrapper); TextField text = new TextField<>(ID_TEXT, createTextModel(listItem.getModel())); text.add(new AjaxFormComponentUpdatingBehavior("onblur") { @Override protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) { } }); text.setEnabled(false); text.add(AttributeAppender.replace("placeholder", label)); text.setLabel(label); textWrapper.add(text); FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text)); textWrapper.add(feedback); WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP); buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() { @Override public String getObject() { if (listItem.getIndex() > 0 && StringUtils.isNotEmpty(labelSize)) { return CLASS_MULTI_VALUE; } return null; } })); AjaxLink edit = new AjaxLink(ID_EDIT) { @Override public void onClick(AjaxRequestTarget target) { editValuePerformed(target, listItem.getModel()); } }; textWrapper.add(edit); listItem.add(buttonGroup); initButtons(buttonGroup, listItem); } }; initDialog(); add(repeater); }
From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueChoosePanel.java
License:Apache License
private void initLayout(final IModel<String> label, final String labelSize, final String textSize, final boolean required, Class<T> type) { Label l = new Label(ID_LABEL, label); if (StringUtils.isNotEmpty(labelSize)) { l.add(AttributeAppender.prepend("class", labelSize)); }/*ww w. j a v a 2 s . c o m*/ add(l); ListView repeater = new ListView<T>(ID_REPEATER, getModel()) { @Override protected void populateItem(final ListItem<T> listItem) { WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER); textWrapper.add(AttributeAppender.prepend("class", new AbstractReadOnlyModel<String>() { @Override public String getObject() { StringBuilder sb = new StringBuilder(); if (StringUtils.isNotEmpty(textSize)) { sb.append(textSize).append(' '); } if (listItem.getIndex() > 0 && StringUtils.isNotEmpty(getOffsetClass())) { sb.append(getOffsetClass()).append(' '); sb.append(CLASS_MULTI_VALUE); } return sb.toString(); } })); listItem.add(textWrapper); TextField text = new TextField<>(ID_TEXT, createTextModel(listItem.getModel())); text.add(new AjaxFormComponentUpdatingBehavior("onblur") { @Override protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) { } }); text.setRequired(required); text.setEnabled(false); text.add(AttributeAppender.replace("placeholder", label)); text.setLabel(label); textWrapper.add(text); FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text)); textWrapper.add(feedback); WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP); buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() { @Override public String getObject() { if (listItem.getIndex() > 0 && StringUtils.isNotEmpty(labelSize)) { return CLASS_MULTI_VALUE; } return null; } })); AjaxLink edit = new AjaxLink(ID_EDIT) { @Override public void onClick(AjaxRequestTarget target) { editValuePerformed(target); } }; textWrapper.add(edit); listItem.add(buttonGroup); initButtons(buttonGroup, listItem); } }; initDialog(type); add(repeater); }