List of usage examples for org.apache.wicket.util.time Duration ONE_SECOND
Duration ONE_SECOND
To view the source code for org.apache.wicket.util.time Duration ONE_SECOND.
Click Source Link
From source file:com.comcast.cdn.traffic_control.traffic_monitor.MonitorApplication.java
License:Apache License
/** * @see org.apache.wicket.Application#init() */// ww w. ja v a 2s.co m @Override public void init() { super.init(); // add your configuration here getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND); /* * This allows us to override the Host header sent via URLConnection */ System.setProperty("sun.net.http.allowRestrictedHeaders", "true"); final HealthDeterminer hd = new HealthDeterminer(); tmw = new TmWatcher(hd); cw = new CacheWatcher(); cw.init(hd); dsw = new DsWatcher(); dsw.init(hd); pw = new PeerWatcher(); pw.init(); tmw.addTmListener(RouterConfig.getTmListener(hd)); tmw.init(); CrStates.init(cw, pw, hd); mountPackage("/publish", CrStates.class); startTime = System.currentTimeMillis(); }
From source file:com.cubeia.backoffice.web.BackofficeApplication.java
License:Open Source License
@Override protected void init() { super.init(); getComponentInstantiationListeners().add(new SpringComponentInjector(this)); getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND); getMarkupSettings().setStripWicketTags(true); // setRequestCycleProvider(new IRequestCycleProvider() { // @Override // public RequestCycle get(RequestCycleContext ctx) { // // TODO Auto-generated method stub // return new BackofficeRequestCycle(BackofficeApplication.this, (WebRequest) request, response); // } // }); getRequestCycleListeners().add(new BackofficeRequestCycleListener()); }
From source file:com.doculibre.constellio.wicket.components.progress.ProgressInfoLabel.java
License:Open Source License
/** * Start the progress bar./*from w ww . j a va2s . c o m*/ * * This must happen in an AJAX request. * * @param target */ public void start(AjaxRequestTarget target) { setVisible(true); add(new DynamicAjaxSelfUpdatingTimerBehavior(Duration.ONE_SECOND) { @Override protected void onPostProcessTarget(AjaxRequestTarget target) { ProgressInfo progressInfo = (ProgressInfo) progressInfoModel.getObject(); int currentIndex = progressInfo.getCurrentIndex(); int total = progressInfo.getTotal(); if (total != 0 && currentIndex == total - 1) { // stop the self update stop(); // do custom action onFinished(target); } } }); if (getParent() != null) { target.addComponent(getParent()); } else { target.addComponent(this); } }
From source file:com.doculibre.constellio.wicket.panels.admin.indexing.AdminIndexingPanel.java
License:Open Source License
public AdminIndexingPanel(String id) { super(id);//from w w w .j a v a2 s .c om sizeDisk = 0; indexedRecords = 0; add(new AjaxSelfUpdatingTimerBehavior(Duration.ONE_SECOND)); // add(new AbstractAjaxTimerBehavior(Duration.ONE_SECOND) { // @Override // protected void onTimer(AjaxRequestTarget target) { // // Do nothing, will prevent page from expiring // } // }); connectorsModel = new LoadableDetachableModel() { @Override protected Object load() { List<ConnectorInstance> connectors; RecordCollection collection = getRecordCollection(); if (collection.isFederationOwner()) { FederationServices federationServices = ConstellioSpringUtils.getFederationServices(); connectors = federationServices.listConnectors(collection); } else { connectors = new ArrayList<ConnectorInstance>(collection.getConnectorInstances()); } return connectors; } }; manageConnectorsLink = new Link("manageConnectorsLink") { @Override public void onClick() { AdminCollectionPanel adminCollectionPanel = (AdminCollectionPanel) findParent( AdminCollectionPanel.class); adminCollectionPanel.setSelectedTab(AdminCollectionPanel.CONNECTORS_MANAGEMENT_PANEL); } @Override public boolean isVisible() { boolean visible = super.isVisible(); if (visible) { RecordCollection collection = getRecordCollection(); visible = collection.getConnectorInstances().isEmpty(); } return visible; } }; synchronizeIndexFieldsLink = new Link("synchronizeIndexFieldsLink") { @Override public void onClick() { RecordCollection collection = getRecordCollection(); RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices(); SolrServices solrServices = ConstellioSpringUtils.getSolrServices(); solrServices.updateSchemaFields(collection); solrServices.initCore(collection); EntityManager entityManager = ConstellioPersistenceContext.getCurrentEntityManager(); if (!entityManager.getTransaction().isActive()) { entityManager.getTransaction().begin(); } collectionServices.markSynchronized(collection); entityManager.getTransaction().commit(); IndexingManager indexingManager = IndexingManager.get(collection); if (!indexingManager.isActive()) { indexingManager.startIndexing(); } } @Override public boolean isVisible() { boolean visible = super.isVisible(); if (visible) { RecordCollection collection = getRecordCollection(); visible = collection.isSynchronizationRequired(); } return visible; } }; manageIndexFieldsLink = new Link("manageIndexFieldsLink") { @Override public void onClick() { AdminCollectionPanel adminCollectionPanel = (AdminCollectionPanel) findParent( AdminCollectionPanel.class); adminCollectionPanel.setSelectedTab(AdminCollectionPanel.INDEX_FIELDS_MANAGEMENT_PANEL); } }; recordCountLabel = new Label("recordCount", new LoadableDetachableModel() { @Override protected Object load() { RecordCollection collection = getRecordCollection(); return StatusManager.countTraversedRecords(collection); } }); deleteAllLink = new Link("deleteAllLink") { @Override public void onClick() { RecordCollection collection = getRecordCollection(); RecordServices recordServices = ConstellioSpringUtils.getRecordServices(); FederationServices federationServices = ConstellioSpringUtils.getFederationServices(); ReadWriteLock collectionLock = recordServices.getLock(collection.getName()); collectionLock.writeLock().lock(); try { ConstellioPersistenceUtils.beginTransaction(); recordServices.markRecordsForDeletion(collection); if (collection.isFederationOwner()) { List<RecordCollection> includedCollections = federationServices .listIncludedCollections(collection); for (RecordCollection includedCollection : includedCollections) { recordServices.markRecordsForDeletion(includedCollection); } } SolrServer solrServer = SolrCoreContext.getSolrServer(collection); try { solrServer.commit(); solrServer.optimize(); } catch (Throwable t) { try { solrServer.rollback(); } catch (Exception e) { throw new RuntimeException(t); } } } finally { try { ConstellioPersistenceUtils.finishTransaction(false); } finally { collectionLock.writeLock().unlock(); } } // RecordCollection collection = getRecordCollection(); // // ConnectorManagerServices connectorManagerServices = // ConstellioSpringUtils.getConnectorManagerServices(); // ConnectorManager connectorManager = // connectorManagerServices.getDefaultConnectorManager(); // for (ConnectorInstance connectorInstance : // collection.getConnectorInstances()) { // String connectorName = connectorInstance.getName(); // connectorManagerServices.disableConnector(connectorManager, // connectorName); // } // // IndexingManager indexingManager = // IndexingManager.get(collection); // indexingManager.deleteAll(); // indexingManager.optimize(); // while (indexingManager.isOptimizing()) { // try { // Thread.sleep(200); // } catch (InterruptedException e) { // e.printStackTrace(); // } // } } @Override protected CharSequence getOnClickScript(CharSequence url) { String confirmMsg = getLocalizer().getString("confirmDeleteAll", AdminIndexingPanel.this) .replace("'", "\\'"); return "if (confirm('" + confirmMsg + "')) { window.location.href='" + url + "';} else { return false; }"; } }; indexedRecordCountLabel = new Label("indexedRecordCount", new LoadableDetachableModel() { @Override protected Object load() { RecordCollection collection = getRecordCollection(); return StatusManager.countIndexedRecords(collection); } }); controlIndexingButtons = new WebMarkupContainer("controlIndexingButtons"); controlIndexingButtons.setOutputMarkupId(true); reindexAllLink = new Link("reindexAllLink") { @Override public void onClick() { RecordCollection collection = getRecordCollection(); final String collectioName = collection.getName(); final Long collectionId = collection.getId(); new Thread() { @Override public void run() { RecordServices recordServices = ConstellioSpringUtils.getRecordServices(); ReadWriteLock collectionLock = recordServices.getLock(collectioName); collectionLock.writeLock().lock(); try { EntityManager entityManager = ConstellioPersistenceContext.getCurrentEntityManager(); if (!entityManager.getTransaction().isActive()) { entityManager.getTransaction().begin(); } RecordCollectionServices collectionServices = ConstellioSpringUtils .getRecordCollectionServices(); FederationServices federationServices = ConstellioSpringUtils.getFederationServices(); RecordCollection collection = collectionServices.get(collectionId); try { recordServices.markRecordsForUpdateIndex(collection); if (collection.isFederationOwner()) { List<RecordCollection> includedCollections = federationServices .listIncludedCollections(collection); for (RecordCollection includedCollection : includedCollections) { recordServices.markRecordsForUpdateIndex(includedCollection); } } SolrServer solrServer = SolrCoreContext.getSolrServer(collection); try { // solrServer.commit(); solrServer.optimize(); } catch (Throwable t) { try { solrServer.rollback(); } catch (Exception e) { throw new RuntimeException(t); } } } finally { ConstellioPersistenceUtils.finishTransaction(false); } } finally { collectionLock.writeLock().unlock(); } } }.start(); } @Override protected CharSequence getOnClickScript(CharSequence url) { String confirmMsg = getLocalizer().getString("confirmReindexAll", AdminIndexingPanel.this) .replace("'", "\\'"); return "if (confirm('" + confirmMsg + "')) { window.location.href='" + url + "';} else { return false; }"; } }; resumeIndexingLink = new Link("resumeIndexingLink") { @Override public void onClick() { RecordCollection collection = getRecordCollection(); IndexingManager indexingManager = IndexingManager.get(collection); if (!indexingManager.isActive()) { indexingManager.startIndexing(false); } } @Override public boolean isVisible() { // boolean visible = super.isVisible(); // if (visible) { // RecordCollection collection = getRecordCollection(); // IndexingManager indexingManager = // IndexingManager.get(collection); // visible = !collection.isSynchronizationRequired() && // !indexingManager.isActive(); // } // return visible; return false; } }; optimizeLink = new Link("optimizeLink") { @Override public void onClick() { RecordCollection collection = getRecordCollection(); final Long collectionId = collection.getId(); new Thread() { @Override public void run() { RecordCollectionServices collectionServices = ConstellioSpringUtils .getRecordCollectionServices(); RecordCollection collection = collectionServices.get(collectionId); SolrServer solrServer = SolrCoreContext.getSolrServer(collection); try { solrServer.optimize(); } catch (Throwable t) { try { solrServer.rollback(); } catch (Exception e) { throw new RuntimeException(t); } } // IndexingManager indexingManager = // IndexingManager.get(collection); // if (indexingManager.isActive() && // !indexingManager.isOptimizing()) { // indexingManager.optimize(); // } } }.start(); } @Override protected CharSequence getOnClickScript(CharSequence url) { String confirmMsg = getLocalizer().getString("confirmOptimize", AdminIndexingPanel.this) .replace("'", "\\'"); return "if (confirm('" + confirmMsg + "')) { window.location.href='" + url + "';} else { return false; }"; } @Override public boolean isVisible() { // boolean visible = super.isVisible(); // if (visible) { // RecordCollection collection = getRecordCollection(); // IndexingManager indexingManager = // IndexingManager.get(collection); // visible = indexingManager.isActive(); // } // return visible; return true; } @Override public boolean isEnabled() { // boolean enabled = super.isEnabled(); // if (enabled) { // RecordCollection collection = getRecordCollection(); // IndexingManager indexingManager = // IndexingManager.get(collection); // enabled = indexingManager.isActive() && // !indexingManager.isOptimizing(); // } // return enabled; return true; } }; indexSizeOnDiskLabel = new Label("indexSizeOnDisk", new LoadableDetachableModel() { @Override protected Object load() { RecordCollection collection = getRecordCollection(); return StatusManager.getSizeOnDisk(collection); } }); connectorTraversalStatesListView = new ListView("connectorTraversalStates", connectorsModel) { @Override protected void populateItem(ListItem item) { ConnectorInstance connectorInstance = (ConnectorInstance) item.getModelObject(); final ReloadableEntityModel<ConnectorInstance> connectorInstanceModel = new ReloadableEntityModel<ConnectorInstance>( connectorInstance); Label displayNameLabel = new Label("displayName", connectorInstance.getDisplayName()); Label lastTraversalDateLabel = new Label("latestTraversalDate", new LoadableDetachableModel() { @Override protected Object load() { ConnectorInstance connectorInstance = connectorInstanceModel.getObject(); Date lastTraversalDate = StatusManager.getLastTraversalDate(connectorInstance); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return lastTraversalDate != null ? sdf.format(lastTraversalDate) : "---"; } @Override public void detach() { connectorInstanceModel.detach(); super.detach(); } }); Link restartTraversalLink = new Link("restartTraversalLink") { @Override public void onClick() { ConnectorInstance connectorInstance = connectorInstanceModel.getObject(); ConnectorManagerServices connectorManagerServices = ConstellioSpringUtils .getConnectorManagerServices(); ConnectorManager connectorManager = connectorManagerServices.getDefaultConnectorManager(); connectorManagerServices.restartTraversal(connectorManager, connectorInstance.getName()); } @Override protected CharSequence getOnClickScript(CharSequence url) { String confirmMsg = getLocalizer() .getString("confirmRestartTraversal", AdminIndexingPanel.this).replace("'", "\\'"); return "if (confirm('" + confirmMsg + "')) { window.location.href='" + url + "';} else { return false; }"; } @Override public boolean isVisible() { ConnectorInstance connectorInstance = connectorInstanceModel.getObject(); RecordCollection connectorInstanceCollection = connectorInstance.getRecordCollection(); ConstellioUser user = ConstellioSession.get().getUser(); return super.isVisible() && user.hasAdminPermission(connectorInstanceCollection); } }; Link disableConnectorLink = new Link("disableConnectorLink") { @Override public void onClick() { ConnectorInstance connectorInstance = connectorInstanceModel.getObject(); String connectorName = connectorInstance.getName(); ConnectorManagerServices connectorManagerServices = ConstellioSpringUtils .getConnectorManagerServices(); ConnectorManager connectorManager = connectorManagerServices.getDefaultConnectorManager(); connectorManagerServices.disableConnector(connectorManager, connectorName); } @Override protected CharSequence getOnClickScript(CharSequence url) { String confirmMsg = getLocalizer() .getString("confirmDisableConnector", AdminIndexingPanel.this).replace("'", "\\'"); return "if (confirm('" + confirmMsg + "')) { window.location.href='" + url + "';} else { return false; }"; } @Override public boolean isVisible() { boolean visible = super.isVisible(); if (visible) { ConnectorInstance connectorInstance = connectorInstanceModel.getObject(); String connectorName = connectorInstance.getName(); ConnectorManagerServices connectorManagerServices = ConstellioSpringUtils .getConnectorManagerServices(); ConnectorManager connectorManager = connectorManagerServices .getDefaultConnectorManager(); visible = connectorManagerServices.isConnectorEnabled(connectorManager, connectorName); if (visible) { RecordCollection connectorInstanceCollection = connectorInstance .getRecordCollection(); ConstellioUser user = ConstellioSession.get().getUser(); visible = user.hasAdminPermission(connectorInstanceCollection); } } return visible; } }; Link enableConnectorLink = new Link("enableConnectorLink") { @Override public void onClick() { ConnectorInstance connectorInstance = connectorInstanceModel.getObject(); String connectorName = connectorInstance.getName(); ConnectorManagerServices connectorManagerServices = ConstellioSpringUtils .getConnectorManagerServices(); ConnectorManager connectorManager = connectorManagerServices.getDefaultConnectorManager(); connectorManagerServices.enableConnector(connectorManager, connectorName); } @Override protected CharSequence getOnClickScript(CharSequence url) { String confirmMsg = getLocalizer() .getString("confirmEnableConnector", AdminIndexingPanel.this).replace("'", "\\'"); return "if (confirm('" + confirmMsg + "')) { window.location.href='" + url + "';} else { return false; }"; } @Override public boolean isVisible() { boolean visible = super.isVisible(); if (visible) { ConnectorInstance connectorInstance = connectorInstanceModel.getObject(); String connectorName = connectorInstance.getName(); ConnectorManagerServices connectorManagerServices = ConstellioSpringUtils .getConnectorManagerServices(); ConnectorManager connectorManager = connectorManagerServices .getDefaultConnectorManager(); visible = !connectorManagerServices.isConnectorEnabled(connectorManager, connectorName); if (visible) { RecordCollection connectorInstanceCollection = connectorInstance .getRecordCollection(); ConstellioUser user = ConstellioSession.get().getUser(); visible = user.hasAdminPermission(connectorInstanceCollection); } } return visible; } }; item.add(displayNameLabel); item.add(lastTraversalDateLabel); item.add(restartTraversalLink); item.add(disableConnectorLink); item.add(enableConnectorLink); } }; latestIndexedRecordsTextArea = new LoggingTextArea("latestIndexedRecordsTextArea", new LoadableDetachableModel() { @Override protected Object load() { RecordCollection collection = getRecordCollection(); return StatusManager.listLastIndexedRecords(collection); } }, refreshTimeMillis); connectorTraversalTextAreasListView = new ListView("connectorTraversalTextAreas", connectorsModel) { @Override protected void populateItem(ListItem item) { ConnectorInstance connectorInstance = (ConnectorInstance) item.getModelObject(); final ReloadableEntityModel<ConnectorInstance> connectorInstanceModel = new ReloadableEntityModel<ConnectorInstance>( connectorInstance); Label displayNameLabel = new Label("displayName", connectorInstance.getDisplayName()); LoggingTextArea traversalTextArea = new LoggingTextArea("traversalTextArea", new LoadableDetachableModel() { @Override protected Object load() { ConnectorInstance connectorInstance = connectorInstanceModel.getObject(); return StatusManager.listLastTraversedRecords(connectorInstance); } }, refreshTimeMillis) { @Override public void detachModels() { connectorInstanceModel.detach(); super.detachModels(); } }; item.add(displayNameLabel); item.add(traversalTextArea); } }; // connectorTextAreasListView.setReuseItems(true); add(manageConnectorsLink); add(synchronizeIndexFieldsLink); add(manageIndexFieldsLink); add(recordCountLabel); add(deleteAllLink); add(indexedRecordCountLabel); add(controlIndexingButtons); controlIndexingButtons.add(reindexAllLink); controlIndexingButtons.add(resumeIndexingLink); controlIndexingButtons.add(optimizeLink); add(indexSizeOnDiskLabel); add(connectorTraversalStatesListView); add(latestIndexedRecordsTextArea); add(connectorTraversalTextAreasListView); /* * Quotas Part of the code : * antoine.timonnier@gmail.com */ //Loading the size of the disk IModel model1 = new LoadableDetachableModel() { protected Object load() { return getsizeDisk(); } }; //Loading the number of documents indexed IModel model2 = new LoadableDetachableModel() { protected Object load() { return getindexedRecords(); } }; //Boolean that is true if both of the quotas are reached boolean bothQuotas = false; QuotasManagerImpl quotasManager = new QuotasManagerImpl(); //TODO connect quotas manager with the quotas.properties /*double quotaSizeDisk = quotasManager.getQuotaSizeDisk(); double quotaIndexedRecords = quotasManager.getQuotaIndexedRecords(); double quotaPercentage = quotasManager.getQuotaPercentage();*/ double quotaSizeDisk = 1; double quotaIndexedRecords = 1; double quotaPercentage = 70; double percentageSizeDisk = (sizeDisk * 100) / quotaSizeDisk; double percentageIndexedRecords = (indexedRecords * 100) / quotaIndexedRecords; //if the size of the disk is upper the quota percentage and doesn't reach the quota (lower than 100%) if (quotaPercentage < percentageSizeDisk && percentageSizeDisk < 100) { final String textPercentageSizeDisk = "Vous tes rendu " + Double.toString(percentageSizeDisk) + "% de votre quota d'espace disque, veuillez contacter un administrateur !"; configurePopUp(popUpPercentageSizeDisk, textPercentageSizeDisk, "Attention"); } add(popUpPercentageSizeDisk); //if the number of doc indexed is upper the quota percentage and doesn't reach the quota (lower than 100%) if (quotaIndexedRecords < percentageIndexedRecords && percentageIndexedRecords < 100) { final String textPercentageIndexedRecords = "Vous tes rendu " + Double.toString(percentageSizeDisk) + "% de votre quota de nombre de documents indexs, veuillez contacter un administrateur !"; configurePopUp(popUpPercentageIndexedRecords, textPercentageIndexedRecords, "Attention"); } add(popUpPercentageIndexedRecords); //Adding a pop up if both of the quotas are reached popUpBothQuotas = new ModalWindow("popUpBothQuotas"); if (sizeDisk > quotaSizeDisk && indexedRecords > quotaIndexedRecords) { bothQuotas = true; // Sending the email // TODO sendEmail(String hostName, int smtpPort, // DefaultAuthenticator authenticator, String sender, String // subject, String message, String receiver); // TODO lock the indexing //Configuration of the popUp final String textBothQuotas = "Vous avez dpass votre quota d'espace disque et votre quotat de document indexs, veuillez contacter un administrateur"; configurePopUp(popUpBothQuotas, textBothQuotas, "Attention"); } add(popUpBothQuotas); //Adding a pop up if the size disk quota is reached popUpSizeDisk = new ModalWindow("popUpSizeDisk"); boolean sizeDiskSuperior = sizeDisk > quotaSizeDisk; if (sizeDiskSuperior && bothQuotas == false) { /* Sending the email try { sendEmail("smtp.googlemail.com", 465, new DefaultAuthenticator("antoine.timonnier@gmail.com","quenellede300"), "antoine.timonnier@gmail.com", "constellio", "blabla", "antoine.timonnier@gmail.com"); } catch (EmailException e) { // TODO Auto-generated catch block e.printStackTrace(); } */ // TODO lock // Configuration of the popup final String textSizeDisk = "Attention, vous avez dpass votre quota d'espace disque, veuillez contacter un administrateur"; configurePopUp(popUpSizeDisk, textSizeDisk, "Attention"); } add(popUpSizeDisk); //Adding a pop up if the indexed records quota is reached popUpIndexedRecords = new ModalWindow("popUpIndexedRecords"); if (indexedRecords > quotaIndexedRecords && bothQuotas == false) { // sending the email // TODO sendEmail(String hostName, int smtpPort, // DefaultAuthenticator authenticator, String sender, String // subject, String message, String receiver); // TODO lock // Configuration of the popup final String textIndexedRecords = "Attention, vous avez dpass votre quota de documents indexs, veuillez contacter un administrateur. boolean both = " + bothQuotas; configurePopUp(popUpIndexedRecords, textIndexedRecords, "Attention"); } add(popUpIndexedRecords); }
From source file:com.evolveum.midpoint.web.component.AbstractAjaxDownloadBehavior.java
License:Apache License
public void onRequest() { IResourceStream resourceStream = getResourceStream(); if (resourceStream == null) { return; // We hope the error was already processed and will be shown. }// ww w .j a va2s . com ResourceStreamRequestHandler reqHandler = new ResourceStreamRequestHandler(resourceStream) { @Override public void respond(IRequestCycle requestCycle) { super.respond(requestCycle); } }.setContentDisposition(ContentDisposition.ATTACHMENT).setCacheDuration(Duration.ONE_SECOND); if (StringUtils.isNotEmpty(getFileName())) { reqHandler.setFileName(getFileName()); } getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(reqHandler); }
From source file:com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromFile.java
License:Apache License
public void onRequest() { final File file = initFile(); IResourceStream resourceStream = new FileResourceStream(new File(file)); getComponent().getRequestCycle()//ww w . j a v a2s . co m .scheduleRequestHandlerAfterCurrent(new ResourceStreamRequestHandler(resourceStream) { @Override public void respond(IRequestCycle requestCycle) { try { super.respond(requestCycle); } finally { if (removeFile) { LOGGER.debug("Removing file '{}'.", new Object[] { file.getAbsolutePath() }); Files.remove(file); } } } }.setFileName(file.getName()).setContentDisposition(ContentDisposition.ATTACHMENT) .setCacheDuration(Duration.ONE_SECOND)); }
From source file:com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromStream.java
License:Apache License
public void onRequest() { final InputStream byteStream = initStream(); if (byteStream == null) { return;//w ww . j a va2 s.c o m } IResourceStream resourceStream = new AbstractResourceStream() { @Override public String getContentType() { return contentType; } @Override public InputStream getInputStream() throws ResourceStreamNotFoundException { return byteStream; } @Override public void close() throws IOException { byteStream.close(); } }; getComponent().getRequestCycle() .scheduleRequestHandlerAfterCurrent(new ResourceStreamRequestHandler(resourceStream) { @Override public void respond(IRequestCycle requestCycle) { super.respond(requestCycle); } }.setContentDisposition(ContentDisposition.ATTACHMENT).setCacheDuration(Duration.ONE_SECOND)); }
From source file:de.alpharogroup.wicket.base.util.application.ApplicationExtensions.java
License:Apache License
/** * Use this method to enable hot deploy of your html templates on development. Works only with * jetty. Only for/*from w ww . j av a 2s . com*/ * * @param application * the new html hot deploy */ public static void setHtmlHotDeploy(final WebApplication application) { application.getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND); final String slash = "/"; String realPath = application.getServletContext().getRealPath(slash); if ((realPath != null) && !realPath.endsWith(slash)) { realPath += slash; } final String javaSourcePath = realPath + "../java"; final String resourcesPath = realPath + "../resources"; addResourceFinder(application, javaSourcePath); addResourceFinder(application, resourcesPath); }
From source file:de.codepitbull.behavior.HomePage.java
License:Apache License
public HomePage(final PageParameters parameters) { final List<String> choices = new ArrayList<String>(); final IModel<String> input = Model.of(""); add(new Label("roundtrips", new PropertyModel<Integer>(this, "roundtrips")) .add(new AjaxSelfUpdatingTimerBehavior(Duration.ONE_SECOND) { @Override/*from w w w . jav a 2s . c om*/ protected void onPostProcessTarget(AjaxRequestTarget target) { roundtrips++; } })); add(new Form("inputForm") { @Override protected void onSubmit() { super.onSubmit(); choices.add(input.getObject()); } }.add(new TextField<String>("autocomplete", input) .add(new AutoCompleteBehavior<Object>(new StringAutoCompleteRenderer()) { @Override protected Iterator<Object> getChoices(String input) { List<Object> ret = new ArrayList<Object>(); for (String choice : choices) { if (choice.startsWith(input)) { ret.add(choice); } } return ret.iterator(); } }))); }
From source file:eu.uqasar.web.UQasar.java
License:Apache License
@Override public void init() { super.init(); // wicketstuff-javaee-inject configuration for injecting EJBs into // Wicket pages configureJavaEEInject();/* w w w .ja v a 2s . c o m*/ // CDI configuration for injection CDI components into Wicket pages configureCDIInjecttion(); // Bean Validation configuration configureBeanValidation(); // add authorization strategy getSecuritySettings().setAuthorizationStrategy(new UQasarAuthorizationStrategy()); // add bootstrap stuff configureBootstrap(); // mount pages mountPages(); // mount resources mountResources(); // markup settings getMarkupSettings().setStripWicketTags(true); getMarkupSettings().setDefaultMarkupEncoding("UTF-8"); // exception settings getResourceSettings().setThrowExceptionOnMissingResource(false); if (usesDeploymentConfig()) { getApplicationSettings().setInternalErrorPage(ErrorPage.class); getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE); } getRequestCycleListeners().add(new UQasarExceptionRequestCycleListener(usesDeploymentConfig())); // gather client (browser) properties getRequestCycleSettings().setGatherExtendedBrowserInfo(true); getApplicationSettings().setUploadProgressUpdatesEnabled(true); // init dashboard from context initDashboard(); // Redirect to the start page on page expiration getApplicationSettings().setPageExpiredErrorPage(AboutPage.class); getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND); }