/** * Creates a new rating label, showing a message like 'Rated 5.4 from 53 votes'. * * @param id * the id of the label * @param rating * the model containing the rating * @param nrOfVotes * the model containing the number of votes (may be null) * @return the label component showing the message. */ protected Component newRatingLabel(final String id, final IModel<? extends Number> rating, final IModel<Integer> nrOfVotes) { IModel<String> model; if (nrOfVotes == null) { Object[] parameters = new Object[] { rating }; model = new StringResourceModel("rating.simple", this).setParameters(parameters); } else { Object[] parameters = new Object[] { rating, nrOfVotes }; model = new StringResourceModel("rating.complete", this).setParameters(parameters); } return new Label(id, model); }
public NotFoundWidget(String id, IModel<T> model, IModel<ODocument> widgetDocumentModel) { super(id, model, widgetDocumentModel); ODocument widgetDoc = widgetDocumentModel.getObject(); add(new Label("error", new StringResourceModel("widget.error.notfound", widgetDocumentModel) .setParameters(widgetDoc!=null?widgetDoc.field(OWidgetsModule.OPROPERTY_TYPE_ID):"null"))); }
/** * @deprecated use 'inline method' to get rid of the deprecation warning and complete the * migration to Wicket 7 API. */ /* * Original JavaDoc: * * Creates a new string resource model using the supplied parameters. * <p> * The model parameter is also optional and only needs to be supplied if value substitutions are * to take place on either the resource key or the actual resource strings. * <p> * The parameters parameter is also optional and is used for substitutions. * * @param resourceKey * The resource key for this string resource * @param model * The model to use for property substitutions * @param parameters * The parameters to substitute using a Java MessageFormat object */ @Deprecated @SuppressWarnings(value = "javadoc") public static StringResourceModel of(final String resourceKey, final IModel<?> model, final Object... parameters) { return new StringResourceModel(resourceKey).setModel(model).setParameters(parameters); }
/** * @deprecated use 'inline method' to get rid of the deprecation warning and complete the * migration to Wicket 7 API. * Original JavaDoc: * * Creates a new string resource model using the supplied parameters. <p> The relative component * parameter should generally be supplied, as without it resources can not be obtained from * resource bundles that are held relative to a particular component or page. However, for * application that use only global resources then this parameter may be null. <p> The model * parameter is also optional and only needs to be supplied if value substitutions are to take * place on either the resource key or the actual resource strings. <p> The parameters parameter * is also optional and is used for substitutions. * * @param resourceKey The resource key for this string resource * * @param component The component that the resource is relative to * * @param model The model to use for property substitutions * * @param parameters The parameters to substitute using a Java MessageFormat object */ @Deprecated @SuppressWarnings(value = "javadoc") public static StringResourceModel of(final String resourceKey, final Component component, final IModel<?> model, final Object... parameters) { return new StringResourceModel(resourceKey, component).setModel(model).setParameters( parameters); }
/** * Utility method for localizing strings using Wicket i18n subsystem. Useful if your model needs * to be localized and you don't have access to a Component instance. Use with care, in most * cases you should be able to localize your messages directly in pages or components. * * @param key * @param model * @param params */ public static String localize(String key, IModel<?> model, Object... params) { StringResourceModel rm = new StringResourceModel(key, (Component) null) { private static final long serialVersionUID = 7276431319922312811L; @Override public Localizer getLocalizer() { return GeoServerApplication.get().getResourceSettings().getLocalizer(); } }.setModel(model).setParameters(params); return rm.getString(); }
.setParameters(parameters);
.setParameters(parameters);
@Override protected void viewMailBody( final MailTemplateFormat format, final String content, final AjaxRequestTarget target) { mlp.next( new StringResourceModel("content", this).setParameters(format.name()).getObject(), new NotificationMailBodyDetails(content), target); }
/** * Shows confirmation dialog. If the user accepts, calls * {@link AbstractInfoPanel#actionDelete(AjaxRequestTarget)}. */ private void confirmActionDelete(AjaxRequestTarget aTarget) { confirmationDialog.setTitleModel( new StringResourceModel("kbobject.delete.confirmation.title", this)); // find out whether there are statements that reference the object List<Statement> statementsWithReference = kbService .listStatementsWithPredicateOrObjectReference(kbModel.getObject(), kbObjectModel.getObject().getIdentifier()); if (statementsWithReference.isEmpty()) { confirmationDialog.setContentModel(new StringResourceModel( "kbobject.delete.confirmation.content", this, handleModel)); } else { confirmationDialog.setContentModel( new StringResourceModel("kbobject.delete.confirmation.extendedContent", this, handleModel).setParameters(statementsWithReference.size())); } confirmationDialog.show(aTarget); confirmationDialog.setConfirmAction(this::actionDelete); }
/** * Shows confirmation dialog. If the user accepts, calls * {@link AbstractInfoPanel#actionDelete(AjaxRequestTarget)}. */ private void confirmActionDelete(AjaxRequestTarget aTarget) { confirmationDialog.setTitleModel( new StringResourceModel("kbobject.delete.confirmation.title", this)); // find out whether there are statements that reference the object List<Statement> statementsWithReference = kbService .listStatementsWithPredicateOrObjectReference(kbModel.getObject(), kbObjectModel.getObject().getIdentifier()); if (statementsWithReference.isEmpty()) { confirmationDialog.setContentModel(new StringResourceModel( "kbobject.delete.confirmation.content", this, handleModel)); } else { confirmationDialog.setContentModel( new StringResourceModel("kbobject.delete.confirmation.extendedContent", this, handleModel).setParameters(statementsWithReference.size())); } confirmationDialog.show(aTarget); confirmationDialog.setConfirmAction(this::actionDelete); }
@Override public void onSubmit() { if (StringUtils.hasLength(fileName) == false) { error(new StringResourceModel("fileNameEmpty", this, null).getString()); return; } try { if (dumpMasterPassword()) { info( new StringResourceModel("dumpInfo", this) .setParameters( new File(fileName).getCanonicalFile()) .getString()); } else error(new StringResourceModel("unauthorized", this).getString()); } catch (Exception e) { error(e); } } });
void handleException(Exception e, Component target) { Serializable msg = null; if (e instanceof SecurityConfigException) { SecurityConfigException sce = (SecurityConfigException) e; msg = new StringResourceModel("security." + sce.getId()) .setParameters(sce.getArgs()) .getObject(); } else { msg = e; } (target != null ? target : getPage()).error(msg); }
private void actionDelete(AjaxRequestTarget aTarget) { confirmationDialog.setContentModel(new StringResourceModel("DeleteDialog.text", this) .setParameters(selectedTagSet.getObject().getName())); confirmationDialog.show(aTarget); confirmationDialog.setConfirmAction((_target) -> { // If the tagset is used in any features, clear the tagset on these features when // the tagset is deleted! for (AnnotationFeature ft : annotationSchemaService .listAnnotationFeature(selectedProject.getObject())) { if (ft.getTagset() != null && ft.getTagset().equals(selectedTagSet.getObject())) { ft.setTagset(null); annotationSchemaService.createFeature(ft); } } annotationSchemaService.removeTagSet(selectedTagSet.getObject()); _target.add(getPage()); actionCancel(_target); }); }
private void actionDelete(AjaxRequestTarget aTarget) { confirmationDialog.setContentModel(new StringResourceModel("DeleteDialog.text", this) .setParameters(selectedTagSet.getObject().getName())); confirmationDialog.show(aTarget); confirmationDialog.setConfirmAction((_target) -> { // If the tagset is used in any features, clear the tagset on these features when // the tagset is deleted! for (AnnotationFeature ft : annotationSchemaService .listAnnotationFeature(selectedProject.getObject())) { if (ft.getTagset() != null && ft.getTagset().equals(selectedTagSet.getObject())) { ft.setTagset(null); annotationSchemaService.createFeature(ft); } } annotationSchemaService.removeTagSet(selectedTagSet.getObject()); _target.add(getPage()); actionCancel(_target); }); }
private void actionDelete(AjaxRequestTarget aTarget, Form<Void> aForm) { if (selectedDocuments.getObject() == null || selectedDocuments.getObject().isEmpty()) { error("No documents selected"); aTarget.addChildren(getPage(), IFeedback.class); return; } confirmationDialog.setContentModel(new StringResourceModel("DeleteDialog.text", this) .setParameters(selectedDocuments.getObject().size())); confirmationDialog.show(aTarget); confirmationDialog.setConfirmAction((_target) -> { for (SourceDocument sourceDocument : selectedDocuments.getObject()) { try { documentService.removeSourceDocument(sourceDocument); } catch (IOException e) { LOG.error("Unable to delete document", e); error("Unable to delete document: " + e.getMessage()); _target.addChildren(getPage(), IFeedback.class); } } selectedDocuments.getObject().clear(); _target.add(getPage()); }); } }
private void actionDelete(AjaxRequestTarget aTarget, Form<Void> aForm) { if (selectedDocuments.getObject() == null || selectedDocuments.getObject().isEmpty()) { error("No documents selected"); aTarget.addChildren(getPage(), IFeedback.class); return; } confirmationDialog.setContentModel(new StringResourceModel("DeleteDialog.text", this) .setParameters(selectedDocuments.getObject().size())); confirmationDialog.show(aTarget); confirmationDialog.setConfirmAction((_target) -> { for (SourceDocument sourceDocument : selectedDocuments.getObject()) { try { documentService.removeSourceDocument(sourceDocument); } catch (IOException e) { LOG.error("Unable to delete document", e); error("Unable to delete document: " + e.getMessage()); _target.addChildren(getPage(), IFeedback.class); } } selectedDocuments.getObject().clear(); _target.add(getPage()); }); } }
protected ChallengeResponseDialog createOrGetResetDocumentDialog() { if (resetDocumentDialog == null) { IModel<String> documentNameModel = PropertyModel.of(getModel(), "document.name"); resetDocumentDialog = new ChallengeResponseDialog("resetDocumentDialog", new StringResourceModel("ResetDocumentDialog.title", this), new StringResourceModel("ResetDocumentDialog.text", this).setModel(getModel()) .setParameters(documentNameModel), documentNameModel); resetDocumentDialog.setConfirmAction(this::actionResetDocument); } return resetDocumentDialog; }
@Override protected void onInitialize() { super.onInitialize(); TransparentWebMarkupContainer body; add(body = new TransparentWebMarkupContainer("body")); body.add(new AttributeAppender("class", " "+getBodyAppSubClasses())); if(get("title")==null) add(new Label("title", getTitleModel()).add(UpdateOnActionPerformedEventBehavior.INSTANCE_ALWAYS_FOR_CHANGING)); IModel<String> poweredByModel = new StringResourceModel("poweredby").setParameters( OrienteerWebApplication.get().getVersion(), OrienteerWebSession.get().isSignedIn() ? OrienteerWebApplication.get().getLoadModeInfo() : ""); if(get("modulesFailed")==null) add(new OModulesLoadFailedPanel("modulesFailed")); if(get("poweredBy")==null) add(new Label("poweredBy", poweredByModel).setEscapeModelStrings(false)); if(get("footer")==null) add(new Label("footer", new PropertyModel<List<ODocument>>(new PropertyModel<ODocument>(this, "perspective"), "footer")) .setEscapeModelStrings(false).setRenderBodyOnly(true)); if(get("indicator")==null) add(new AjaxIndicator("indicator")); //add(new BodyTagAttributeModifier("class", Model.of("sidebar"), this)); }
protected Label getOrCreatePositionInfoLabel() { if (numberOfPages == null) { numberOfPages = new Label("numberOfPages", new StringResourceModel("PositionInfo.text", this).setModel(getModel()) .setParameters( PropertyModel.of(getModel(), "firstVisibleUnitIndex"), PropertyModel.of(getModel(), "lastVisibleUnitIndex"), PropertyModel.of(getModel(), "unitCount"), LambdaModel.of(() -> getModelObject().getDocumentIndex() + 1), PropertyModel.of(getModel(), "numberOfDocuments"))) { private static final long serialVersionUID = 7176610419683776917L; { setOutputMarkupId(true); setOutputMarkupPlaceholderTag(true); } @Override protected void onConfigure() { super.onConfigure(); setVisible(getModelObject().getDocument() != null); } }; } return numberOfPages; }
deleteAnnotationDialog.setContentModel( new StringResourceModel("DeleteDialog.text", this, Model.of(layer)) .setParameters(attachStatus.attachCount)); deleteAnnotationDialog.setConfirmAction((aCallbackTarget) -> { editorPanel.actionDelete(aCallbackTarget);