Example usage for org.apache.wicket.protocol.http WebApplication getMarkupSettings

List of usage examples for org.apache.wicket.protocol.http WebApplication getMarkupSettings

Introduction

In this page you can find the example usage for org.apache.wicket.protocol.http WebApplication getMarkupSettings.

Prototype

public MarkupSettings getMarkupSettings() 

Source Link

Usage

From source file:de.alpharogroup.wicket.base.application.plugins.ApplicationDebugSettingsPlugin.java

License:Apache License

/**
 * Factory method for that can be used to add additional configuration to this plugin.
 * <p>// w  w w  . j a  va 2  s. c  o  m
 * Overrides should call {@code super.onConfigure()}.
 *
 * @param application
 *            the application
 */
protected void onConfigure(final WebApplication application) {
    set(application, this);
    ApplicationExtensions.setDefaultDebugSettingsForDevelopment(application);
    // Adds the references from source code to the browser to reference in eclipse....
    // If you want to add WicketSource capabilities overwrite this method with a super call and
    // add the following...
    // WicketSource.configure(application);

    application.getMarkupSettings().setStripComments(false);
    application.getMarkupSettings().setCompressWhitespace(false);
    application.getMarkupSettings().setStripWicketTags(false);

}

From source file:de.alpharogroup.wicket.base.util.application.ApplicationExtensions.java

License:Apache License

/**
 * Can be used to set the global settings for development and deployment mode for the given
 * application./*from w ww .  j  av  a2  s  . c o m*/
 *
 * @param application
 *            the application
 * @param httpPort
 *            the http port
 * @param httpsPort
 *            the https port
 * @param footerFilterName
 *            the footer filter name
 * @param encoding
 *            the encoding
 * @param patterns
 *            the patterns
 */
public static void setGlobalSettings(final WebApplication application, final int httpPort, final int httpsPort,
        final String footerFilterName, final String encoding, final String... patterns) {
    // Standard-Encoding for Markup-Files
    application.getMarkupSettings().setDefaultMarkupEncoding(encoding);
    // Sets the Response-Header to Character encoding
    // this means Content-Type text/html;charset=<encoding>
    application.getRequestCycleSettings().setResponseRequestEncoding(encoding);
    // set footer scripts...
    ApplicationExtensions.setHeaderResponseDecorator(application, footerFilterName);
    // set up ports for http and https...
    ApplicationExtensions.setRootRequestMapper(application, httpPort, httpsPort);
    // add file patterns to the resource guard...
    ApplicationExtensions.addFilePatternsToPackageResourceGuard(application, patterns);
    // Removes(strips) all wicket tags like <wicket:panel>, <wicket:extend> and <wicket:child>.
    // This is very important to set to true if you use the library wicket-jquery-ui
    application.getMarkupSettings().setStripWicketTags(true);
}

From source file:org.jaulp.wicket.base.util.application.ApplicationUtils.java

License:Apache License

/**
 * Can be used to set the global settings for development and deployment mode for the given
 * application./*from   w w w.j  a  va 2 s .  c o m*/
 *
 * @param application
 *            the application
 * @param httpPort
 *            the http port
 * @param httpsPort
 *            the https port
 * @param footerFilterName
 *            the footer filter name
 * @param encoding
 *            the encoding
 * @param patterns
 *            the patterns
 */
public static void setGlobalSettings(final WebApplication application, final int httpPort, final int httpsPort,
        final String footerFilterName, final String encoding, final String... patterns) {
    // Standard-Encoding for Markup-Files
    application.getMarkupSettings().setDefaultMarkupEncoding(encoding);
    // Sets the Response-Header to Character encoding
    // this means Content-Type text/html;charset=<encoding>
    application.getRequestCycleSettings().setResponseRequestEncoding(encoding);
    // set footer scripts...
    ApplicationUtils.setHeaderResponseDecorator(application, footerFilterName);
    // set up ports for http and https...
    ApplicationUtils.setRootRequestMapper(application, httpPort, httpsPort);
    // add file patterns to the resource guard...
    ApplicationUtils.addFilePatternsToPackageResourceGuard(application, patterns);
    // Removes(strips) all wicket tags like <wicket:panel>, <wicket:extend> and <wicket:child>.
    // This is very important to set to true if you use the library wicket-jquery-ui
    application.getMarkupSettings().setStripWicketTags(true);
}

From source file:org.ops4j.pax.wicket.api.PaxWicketApplicationFactory.java

License:Apache License

private WebApplication createWicketApplicationViaCustomFactory() {
    WebApplication paxWicketApplication;
    paxWicketApplication = applicationFactory.createWebApplication(new ApplicationLifecycleListener() {
        private final List<ServiceRegistration> m_serviceRegistrations = new ArrayList<ServiceRegistration>();
        private PageMounterTracker mounterTracker;
        private ComponentInstantiationListenerFacade componentInstanciationListener;

        public void onInit(WebApplication wicketApplication) {
            componentInstanciationListener = new ComponentInstantiationListenerFacade(
                    delegatingComponentInstanciationListener);
            wicketApplication.addComponentInstantiationListener(componentInstanciationListener);

            IApplicationSettings applicationSettings = wicketApplication.getApplicationSettings();
            applicationSettings.setClassResolver(delegatingClassResolver);
            addWicketService(IApplicationSettings.class, applicationSettings);

            ISessionSettings sessionSettings = wicketApplication.getSessionSettings();
            sessionSettings.setPageFactory(pageFactory);
            addWicketService(ISessionSettings.class, sessionSettings);

            addWicketService(IDebugSettings.class, wicketApplication.getDebugSettings());
            addWicketService(IExceptionSettings.class, wicketApplication.getExceptionSettings());
            addWicketService(IFrameworkSettings.class, wicketApplication.getFrameworkSettings());
            addWicketService(IMarkupSettings.class, wicketApplication.getMarkupSettings());
            addWicketService(IPageSettings.class, wicketApplication.getPageSettings());
            addWicketService(IRequestCycleSettings.class, wicketApplication.getRequestCycleSettings());
            addWicketService(IResourceSettings.class, wicketApplication.getResourceSettings());
            addWicketService(ISecuritySettings.class, wicketApplication.getSecuritySettings());

            if (pageMounter != null) {
                for (MountPointInfo bookmark : pageMounter.getMountPoints()) {
                    wicketApplication.mount(bookmark.getCodingStrategy());
                }/*from   w w w  .ja v a  2  s. c  o m*/
            }

            // Now add a tracker so we can still mount pages later
            mounterTracker = new PageMounterTracker(bundleContext, wicketApplication, getApplicationName());
            mounterTracker.open();

            for (final IInitializer initializer : initializers) {
                initializer.init(wicketApplication);
            }
        }

        private <T> void addWicketService(Class<T> service, T serviceImplementation) {
            Properties props = new Properties();

            // Note: This is kept for legacy
            props.setProperty("applicationId", getApplicationName());
            props.setProperty(APPLICATION_NAME, getApplicationName());

            String serviceName = service.getName();
            ServiceRegistration registration = bundleContext.registerService(serviceName, serviceImplementation,
                    props);
            m_serviceRegistrations.add(registration);
        }

        public void onDestroy(WebApplication wicketApplication) {
            wicketApplication.removeComponentInstantiationListener(componentInstanciationListener);

            if (mounterTracker != null) {
                mounterTracker.close();
                mounterTracker = null;
            }

            for (ServiceRegistration reg : m_serviceRegistrations) {
                reg.unregister();
            }
            m_serviceRegistrations.clear();
        }
    });
    return paxWicketApplication;
}