Example usage for org.apache.wicket IRequestCycleProvider IRequestCycleProvider

List of usage examples for org.apache.wicket IRequestCycleProvider IRequestCycleProvider

Introduction

In this page you can find the example usage for org.apache.wicket IRequestCycleProvider IRequestCycleProvider.

Prototype

IRequestCycleProvider

Source Link

Usage

From source file:com.jolira.wicket.guicier.GuicierWebApplication.java

License:Open Source License

/**
 * Installs the {@link GuicierPageFactory} and a customized
 * {@link IComponentInstantiationListener}.
 * //w w w.  java2 s .  c  o  m
 * @see WebApplication#init()
 */
@Override
protected void init() {
    super.init();

    final ComponentInstantiationListenerCollection listeners = getComponentInstantiationListeners();

    listeners.add(new IComponentInstantiationListener() {
        @Override
        public void onInstantiation(final Component component) {
            final Injector i = GuicierWebApplication.this.getInjector();

            i.injectMembers(component);
        }
    });

    setRequestCycleProvider(new IRequestCycleProvider() {
        @Override
        public RequestCycle get(final RequestCycleContext context) {
            return new GuicierWebRequestCycle(context);
        }
    });
}

From source file:com.userweave.application.UserWeaveApplication.java

License:Open Source License

@Override
public void init() {
    super.init();

    getComponentInstantiationListeners().add(new SpringComponentInjector(this));

    setupAuthorization();/*from w  w  w .j  av a2 s.  com*/

    mountPages();
    mountResources();

    getMarkupSettings().setStripWicketTags(true);

    setupErrorHandling();

    setupProductionSettings();

    setDefaultResourceLocale(LocalizationUtils.getDefaultLocale());

    getMarkupSettings().setMarkupFactory(new MarkupFactory() {

        @Override
        public MarkupParser newMarkupParser(MarkupResourceStream resource) {
            MarkupParser markupParser = new MarkupParser(resource);

            markupParser.add(new AbstractMarkupFilter() {
                //               @Override
                //               public MarkupElement nextTag() throws ParseException {
                //                    
                //                  // Get the next tag. If null, no more tags are available
                //                    final ComponentTag tag = (ComponentTag)getParent().nextTag();
                //                    if ( null == tag || null != tag.getId() )
                //                        return tag;
                //
                //                    // Process open <html> tags
                //                    if( null != tag.getName() && tag.getName().equals( "html" ) && tag.isOpen())
                //                    {
                //                       String language = UserWeaveSession.get().getLocale().getLanguage();
                //                        tag.getAttributes().put("lang", language);
                //                        tag.getAttributes().put("xml:lang", language);
                //                        tag.setModified( true );
                //                    }
                //
                //                    return tag;
                //               }

                @Override
                protected MarkupElement onComponentTag(ComponentTag tag) throws ParseException {
                    if (null == tag || null != tag.getId()) {
                        return tag;
                    }

                    // Process open <html> tags
                    if (null != tag.getName() && tag.getName().equals("html") && tag.isOpen()) {
                        String language = UserWeaveSession.get().getLocale().getLanguage();
                        tag.getAttributes().put("lang", language);
                        tag.getAttributes().put("xml:lang", language);
                        tag.setModified(true);
                    }

                    return tag;
                }
            });

            return markupParser;
        }
    });

    /*
     * @see: migration guide to wicket 1.5 Request cycle
     * 
     * Instead of overrride newRequestCycle, we have to create a factory,
     * that builds our custom RequestCycle.
     */
    setRequestCycleProvider(new IRequestCycleProvider() {
        @Override
        public RequestCycle get(RequestCycleContext context) {
            return new UserWeaveWebRequestCycle(context);
        }
    });

    /*
     * @see: https://cwiki.apache.org/WICKET/request-mapping.html
     * 
     * newRequestCycleProcessor is obsolete, so we replace the
     * CryptedUrlWebRequestCodingStrategy with a CryptoMapper,
     */
    //      if(ENCRYPTION)
    //      {
    //         setRootRequestMapper(new CryptoMapper(getRootRequestMapper(), this));
    //      }

    // add custom listener for runtime exceptions.
    getRequestCycleListeners().add(new AbstractRequestCycleListener() {
        @Override
        public IRequestHandler onException(RequestCycle cycle, Exception ex) {
            if (ex instanceof RuntimeException) {
                ((UserWeaveWebRequestCycle) cycle).handleRuntimeException((RuntimeException) ex);
            }

            return null;
        }
    });

    // disable caching strategy
    getResourceSettings().setCachingStrategy(NoOpResourceCachingStrategy.INSTANCE);
}

From source file:org.xaloon.wicket.component.security.AuthenticatedWebApplication.java

License:Apache License

protected void initRequestCycleSettings() {
    getRequestCycleSettings().setResponseRequestEncoding(ENCODING_UTF_8);

    setRequestCycleProvider(new IRequestCycleProvider() {
        public RequestCycle get(RequestCycleContext context) {
            return new AuthenticatedRequestCycle(context);
        }//  ww w  .  j av a  2 s  . c om
    });
}