Example usage for org.apache.wicket.model Model ofMap

List of usage examples for org.apache.wicket.model Model ofMap

Introduction

In this page you can find the example usage for org.apache.wicket.model Model ofMap.

Prototype

public static <K, V> IModel<Map<K, V>> ofMap(final Map<K, V> map) 

Source Link

Document

Factory method for models that contain maps.

Usage

From source file:com.gitblit.wicket.freemarker.FreemarkerPanel.java

License:Apache License

/**
 * Construct./*from  w  ww .  j a  v  a2 s. co  m*/
 *
 * @param id
 *            Component id
 * @param template
 *            The Freemarker template
 * @param values
 *            values map that can be substituted by Freemarker.
 */
public FreemarkerPanel(final String id, String template, final Map<String, Object> values) {
    this(id, template, Model.ofMap(values));
}

From source file:com.googlecode.wicket.jquery.core.resource.JavaScriptPackageHeaderItem.java

License:Apache License

/**
 * Constructor/*  w w  w  .  j av  a  2s. com*/
 * 
 * @param scope the scope
 * @param function the function, i.e.: the name of the '.js' file without the extension
 * @param variables the variable {@code Map} to supply to the file
 */
public JavaScriptPackageHeaderItem(Class<?> scope, String function, Map<String, Object> variables) {
    super(new TextTemplateResourceReference(scope, function + ".js", Model.ofMap(variables)), null, function,
            false, null, null);
}

From source file:de.alpharogroup.wicket.behaviors.JavascriptResourceReferenceAppenderBehavior.java

License:Apache License

/**
 * Gets the resource reference.//from   ww  w  .  j a  va 2s .  c o  m
 *
 * @return the resource reference
 */
private ResourceReference getResourceReference() {
    final Map<String, Object> map = new HashMap<>();
    map.put("url", WicketUrlExtensions.getUrlAsString(pageClass));
    final ResourceReference resourceReference = new TextTemplateResourceReference(pageClass, this.filename,
            "text/javascript", Model.ofMap(map));
    return resourceReference;
}

From source file:org.apache.isis.viewer.wicket.ui.pages.accmngt.password_reset.PasswordResetEmailPanel.java

License:Apache License

/**
 * Constructor//w  w w .  ja v  a  2s.co  m
 *
 * @param id
 *            the component id
 */
public PasswordResetEmailPanel(final String id) {
    super(id);

    StatelessForm<Void> form = new StatelessForm<>("signUpForm");
    addOrReplace(form);

    final RequiredTextField<String> emailField = new RequiredTextField<>("email", Model.of(""));
    emailField.setLabel(new ResourceModel("emailLabel"));
    emailField.add(EmailAddressValidator.getInstance());
    emailField.add(EmailAvailableValidator.EXISTS);

    FormGroup formGroup = new FormGroup("formGroup", emailField);
    form.add(formGroup);

    formGroup.add(emailField);

    Button signUpButton = new Button("passwordResetSubmit") {
        @Override
        public void onSubmit() {
            super.onSubmit();

            String email = emailField.getModelObject();

            String confirmationUrl = emailVerificationUrlService.createVerificationUrl(PageType.PASSWORD_RESET,
                    email);

            /**
             * We have to init() the services here because the Isis runtime is not available to us
             * (guice will have instantiated a new instance of the service).
             *
             * We do it this way just so that the programming model for the EmailService is similar to regular Isis-managed services.
             */
            emailNotificationService.init();
            emailService.init();

            final PasswordResetEvent passwordResetEvent = new PasswordResetEvent(email, confirmationUrl,
                    applicationName);
            boolean emailSent = emailNotificationService.send(passwordResetEvent);
            if (emailSent) {
                Map<String, String> map = new HashMap<>();
                map.put("email", email);
                IModel<Map<String, String>> model = Model.ofMap(map);
                String emailSentMessage = getString("emailSentMessage", model);

                CookieUtils cookieUtils = new CookieUtils();
                cookieUtils.save(AccountManagementPageAbstract.FEEDBACK_COOKIE_NAME, emailSentMessage);
                pageNavigationService.navigateTo(PageType.SIGN_IN);
            }
        }
    };

    form.add(signUpButton);
}

From source file:org.apache.isis.viewer.wicket.ui.pages.accmngt.password_reset.PasswordResetPanel.java

License:Apache License

private INotificationMessage createPasswordChangeSuccessfulMessage() {
    Class<? extends Page> signInPage = pageClassRegistry.getPageClass(PageType.SIGN_IN);
    CharSequence signInUrl = urlFor(signInPage, null);
    Map<String, CharSequence> map = new HashMap<>();
    map.put("signInUrl", signInUrl);
    String passwordChangeSuccessful = getString("passwordChangeSuccessful", Model.ofMap(map));
    NotificationMessage message = new NotificationMessage(Model.of(passwordChangeSuccessful));
    message.escapeModelStrings(false);/*from   w w  w. j  av  a  2 s  . co  m*/
    return message;
}

From source file:org.apache.isis.viewer.wicket.ui.pages.accmngt.signup.RegistrationFormPanel.java

License:Apache License

/**
 * Constructor// ww w.j a  v  a 2  s .c o m
 *
 * @param id
 *            the component id
 */
public RegistrationFormPanel(final String id) {
    super(id);

    addOrReplace(new NotificationPanel("feedback"));

    StatelessForm<Void> form = new StatelessForm<>("signUpForm");
    addOrReplace(form);

    final RequiredTextField<String> emailField = new RequiredTextField<>("email", Model.of(""));
    emailField.setLabel(new ResourceModel("emailLabel"));
    emailField.add(EmailAddressValidator.getInstance());
    emailField.add(EmailAvailableValidator.DOESNT_EXIST);

    FormGroup formGroup = new FormGroup("formGroup", emailField);
    form.add(formGroup);

    formGroup.add(emailField);

    Button signUpButton = new Button("signUp") {
        @Override
        public void onSubmit() {
            super.onSubmit();

            String email = emailField.getModelObject();
            String confirmationUrl = emailVerificationUrlService.createVerificationUrl(PageType.SIGN_UP_VERIFY,
                    email);

            /**
             * We have to init() the services here because the Isis runtime is not available to us
             * (guice will have instantiated a new instance of the service).
             *
             * We do it this way just so that the programming model for the EmailService is similar to regular Isis-managed services.
             */
            emailNotificationService.init();
            emailService.init();

            final EmailRegistrationEvent emailRegistrationEvent = new EmailRegistrationEvent(email,
                    confirmationUrl, applicationName);
            boolean emailSent = emailNotificationService.send(emailRegistrationEvent);
            if (emailSent) {
                Map<String, String> map = new HashMap<>();
                map.put("email", email);
                String emailSentMessage = getString("emailSentMessage", Model.ofMap(map));

                CookieUtils cookieUtils = new CookieUtils();
                cookieUtils.save(AccountManagementPageAbstract.FEEDBACK_COOKIE_NAME, emailSentMessage);
                pageNavigationService.navigateTo(PageType.SIGN_IN);
            }
        }
    };

    form.add(signUpButton);
}

From source file:org.apache.karaf.webconsole.servicemix.internal.EndpointsPage.java

License:Apache License

@SuppressWarnings({ "unchecked", "serial" })
public EndpointsPage() {
    IColumn<Map<String, Object>, String>[] columns = new IColumn[] { new OrdinalColumn<Map<String, Object>>(),
            new PropertyColumnExt<Map<String, Object>>("Name", Endpoint.NAME),
            new PropertyColumnExt<Map<String, Object>>("Version", Endpoint.VERSION),
            new PropertyColumnExt<Map<String, Object>>("Endpoint Name", Endpoint.ENDPOINT_NAME),
            new PropertyColumnExt<Map<String, Object>>("Interface", Endpoint.INTERFACE_NAME),
            new PropertyColumnExt<Map<String, Object>>("Service name", Endpoint.SERVICE_NAME),
            new PropertyColumnExt<Map<String, Object>>("Sync?", Endpoint.CHANNEL_SYNC_DELIVERY),
            new PropertyColumnExt<Map<String, Object>>("Untargetable?", Endpoint.UNTARGETABLE),
            new PropertyColumnExt<Map<String, Object>>("Wsdl url", Endpoint.WSDL_URL) };

    AdvancedDataProvider<Map<String, Object>> provider = new BaseDataProvider<Map<String, Object>>() {

        public Iterator<? extends Map<String, Object>> iterator(long first, long count) {
            List<Map<String, Object>> props = new ArrayList<Map<String, Object>>();

            EndpointRegistry endpointRegistry = nmr.getEndpointRegistry();
            for (Endpoint endpoint : endpointRegistry.getServices()) {
                props.add((Map<String, Object>) endpointRegistry.getProperties(endpoint));
            }// w  ww .  jav a 2s .c o m

            return props.subList((int) first, (int) count).iterator();
        }

        public long size() {
            return nmr.getEndpointRegistry().getServices().size();
        }

        public IModel<Map<String, Object>> model(Map<String, Object> object) {
            return Model.ofMap(object);
        }
    };

    add(new BaseDataTable<Map<String, Object>>("endpoints", Arrays.asList(columns), provider, 20));
}

From source file:org.apache.openmeetings.web.user.calendar.CalendarFunctionsBehavior.java

License:Apache License

private IModel<Map<String, Object>> newResourceModel() {
    return Model.ofMap(new MicroMap<String, Object>("markupId", this.markupId));
}

From source file:org.brixcms.plugin.site.resource.managers.text.CreateTextResourcePanel.java

License:Apache License

public CreateTextResourcePanel(String id, IModel<BrixNode> container, final SimpleCallback back) {
    super(id, container);

    add(new FeedbackPanel("feedback"));

    Form<?> form = new Form<Void>("form");
    add(form);//ww  w . j a v  a 2 s .  co m

    form.add(new TextField<String>("fileName", new PropertyModel<String>(this, "fileName")).setRequired(true)
            .add(NodeNameValidator.getInstance()).setLabel(new ResourceModel("fileName")));

    final ModelBuffer model = new ModelBuffer();

    form.add(new TextResourceEditor("editor", model));

    form.add(new SubmitLink("save") {
        @Override
        public void onSubmit() {
            if (getContainer().hasNode(fileName)) {
                error(getString("fileExists", Model.ofMap(new MicroMap<String, String>("fileName", fileName))));
                return;
            }

            // create initial node skeleton
            BrixNode node = (BrixNode) getContainer().addNode(fileName, "nt:file");
            BrixFileNode file = BrixFileNode.initialize(node, "text"); // temp-mime

            // save the node so brix assigns the correct jcr type to it
            getContainer().save();

            // populate node
            ResourceNode resource = (ResourceNode) getContainer().getSession().getItem(node.getPath());
            model.setObject(new BrixNodeModel(resource));
            model.apply();

            getContainer().save();

            // done
            getSession().info(getString("saved"));
            SitePlugin.get().selectNode(this, resource, true);
        }
    });

    form.add(new Link<Void>("cancel") {
        @Override
        public void onClick() {
            getSession().info(getString("cancelled"));
            back.execute();
        }
    });
}

From source file:org.efaps.ui.wicket.models.field.factories.BooleanUIFactory.java

License:Apache License

/**
 * {@inheritDoc}//  w  w  w  . j a v a  2s. c om
 */
@SuppressWarnings("unchecked")
@Override
public Component getEditable(final String _wicketId, final AbstractUIField _uiField) throws EFapsException {
    Component ret = null;
    if (applies(_uiField)) {
        final FieldConfiguration config = _uiField.getFieldConfiguration();
        final UIType uiType = config.getUIType();
        if (uiType.equals(UIType.CHECKBOX)) {
            ret = new CheckBoxField(_wicketId, Model.of(_uiField), null, config);
        } else {
            final IModel<Map<Object, Object>> model = Model.ofMap(
                    (Map<Object, Object>) _uiField.getValue().getEditValue(_uiField.getParent().getMode()));
            final Serializable value = _uiField.getValue().getDbValue();
            ret = new BooleanField(_wicketId, value, model, _uiField.getFieldConfiguration(),
                    _uiField.getLabel(), _uiField instanceof UIFieldSetValue);
        }
    }
    return ret;
}