List of usage examples for org.apache.wicket Application get
public static Application get()
From source file:com.tysanclan.site.projectewok.TysanPage.java
License:Open Source License
public TysanPage(String title, IModel<?> model) { super(model); notificationWindow = new Dialog("notificationWindow"); notificationWindow.setTitle("Urgent Message"); notificationWindow.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true); notificationWindow.add(new ComponentFeedbackPanel("messages", notificationWindow).setOutputMarkupId(true) .setOutputMarkupPlaceholderTag(true)); notificationWindow.setAutoOpen(false); notificationWindow.setVisible(false); add(notificationWindow);/*from w w w.j a va 2 s .co m*/ headerLabel = new Label("header", title); titleLabel = new Label("title", title + getTitleSuffix()); headerLabel.setEscapeModelStrings(false); titleLabel.setEscapeModelStrings(false); add(headerLabel); add(titleLabel); add(new FeedbackPanel("feedback").setOutputMarkupId(true)); Dialog window = new Dialog("debugWindow"); window.setTitle("Debug Information"); window.add(new DebugWindow("debugPanel", this.getPageClass())); window.setWidth(600); window.setHeight(300); window.setResizable(false); window.add(new AjaxLink<Void>("magicpushbutton") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { } }.setVisible(ENABLE_MAGIC_PUSHTBUTTON)); add(window); add(new AjaxLink<Dialog>("debugLink", new Model<Dialog>(window)) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { Dialog _window = getModelObject(); target.appendJavaScript(_window.open().render().toString()); } }.setVisible(Application.get().getConfigurationType() == RuntimeConfigurationType.DEVELOPMENT)); User u = getTysanSession().getUser(); WebMarkupContainer subMenu = new WebMarkupContainer("topMenu"); if (u != null) { if (MemberUtil.isMember(u)) { topPanel = new WebMarkupContainer("topbar"); subMenu = new TysanMemberPanel("topMenu", u); } else { topPanel = new WebMarkupContainer("topbar"); subMenu = new TysanUserPanel("topMenu", u); } } else { topPanel = new TysanLoginPanel("topbar"); } add(new TysanMenu("menu", u != null)); add(subMenu); add(topPanel); add(new Label("version", TysanApplication.getApplicationVersion())); if (u != null) { get("version").add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(30)) { private static final long serialVersionUID = 1L; /** * @see org.apache.wicket.ajax.AjaxSelfUpdatingTimerBehavior#onPostProcessTarget(org.apache.wicket.ajax.AjaxRequestTarget) */ @Override protected void onPostProcessTarget(AjaxRequestTarget target) { Dialog d = getNotificationWindow(); TysanSession t = TysanSession.get(); int i = 0; for (SiteWideNotification swn : TysanApplication.get().getActiveNotifications()) { if (t != null && !t.notificationSeen(swn)) { swn.display(d); i++; } } if (i > 0) { d.setAutoOpen(true); d.setVisible(true); target.add(d); getNotificationWindow().open(target); } } }); } addAnimalPanel(); add(new Label("year", LocalDate.now().getYear()).setRenderBodyOnly(true)); add(new WebMarkupContainer("texas").setVisible(isAprilFoolsDay(2017))); }
From source file:com.userweave.application.UserWeaveWebRequestCycle.java
License:Open Source License
public void handleRuntimeException(RuntimeException e) { if (!ignoreNextException) { if ((Application.get().getConfigurationType() == RuntimeConfigurationType.DEPLOYMENT)) { exceptionHandlingHelper.sendRuntimeException(e); }/*from w w w . ja v a 2s.c o m*/ } ignoreNextException = false; }
From source file:com.vaynberg.wicket.select2.Select2ResourcesBehavior.java
License:Apache License
@Override public void renderHead(Component component, IHeaderResponse response) { final ApplicationSettings settings = ApplicationSettings.get(); // Include Wicket's provided jQuery reference response.render(JavaScriptHeaderItem .forReference(Application.get().getJavaScriptLibrarySettings().getJQueryReference())); if (settings.isIncludeMouseWheel()) { response.render(JavaScriptHeaderItem.forReference(settings.getMouseWheelReference())); }//from www . ja va2 s. co m if (settings.isIncludeJavascript()) { response.render(JavaScriptHeaderItem.forReference(settings.getJavaScriptReference())); } if (settings.isIncludeCss()) { response.render(CssHeaderItem.forReference(settings.getCssReference())); } }
From source file:com.visural.stereotyped.ui.base.BasePage.java
License:Mozilla Public License
public BasePage(PageParameters params) { super(params); add(new WebMarkupContainer("favicon1") .add(new SimpleAttributeModifier("href", urlFor(new FaviconRef()).toString()))); add(new WebMarkupContainer("favicon2") .add(new SimpleAttributeModifier("href", urlFor(new FaviconRef()).toString()))); add(new BookmarkablePageLink("homeLink", LandingPage.class) .add(new Image("logo", new ResourceReference(BasePage.class, "logo.png")))); add(new Label("version", Version.getAsString())); add(new Label("headTitle", new AbstractReadOnlyModel() { @Override//from w w w . j av a 2 s .co m public Object getObject() { return getPageTitle() + " - Stereotyped"; } })); add(new Label("pageTitle", new AbstractReadOnlyModel() { @Override public Object getObject() { return getPageTitle(); } })); if (config.isFirstRun() && !this.getClass().equals(ConfigPage.class)) { setRedirect(true); setResponsePage(ConfigPage.class); } WebMarkupContainer loggedIn = new WebMarkupContainer("loggedIn"); add(loggedIn); if (userService.isAuthenticated()) { loggedIn.add(new BookmarkablePageLink("myprofile", EditUserPage.class, PageParamFactory.get(StdParam.LOAD_ID, userService.getCurrentUser()))); loggedIn.add(new Label("currentUser", userService.getCurrentUser())); loggedIn.add(new SecureAjaxLink("adminLink") { @Override public IPrivilege getRenderPrivilege() { return Privilege.ADMINISTRATOR; } @Override public void onClick(AjaxRequestTarget target) { setResponsePage(MainAdminPage.class, PageParameters.NULL); } }); loggedIn.add(new Link("logout") { @Override public void onClick() { userService.logout(); setRedirect(true); setResponsePage(Application.get().getHomePage()); } }); } else { loggedIn.setVisible(false); } }
From source file:com.visural.wicket.component.dropdown.DropDown.java
License:Apache License
public DropDown(String id, IModel<T> model, Class<T> type, DropDownDataSource source, boolean requireListValue) { super(id, model, type); this.outputPath = Application.get().getDebugSettings().isOutputComponentPath(); this.source = source; this.requireListValue = requireListValue; this.setComponentBorder(new DropDownBorder()); origMarkupId = this.getMarkupId(); this.setOutputMarkupId(true); if (requireListValue) { this.setMarkupId("visural_dropdown_id_" + origMarkupId); } else {/*from ww w. ja va2 s.c om*/ this.setMarkupId("visural_dropdown_value_" + origMarkupId); } add(new AbstractBehavior() { @Override public void onRendered(Component component) { if (DropDown.this.requireListValue) { String value = ""; if (DropDown.this.hasRawInput()) { String lookup = DropDown.this.getRawInput(); T unsubmittedObject = convertValue(new String[] { lookup }); if (unsubmittedObject != null) { value = DropDown.this.source.getDescriptionForValue(unsubmittedObject); } } else if (DropDown.this.getModelObject() != null) { value = DropDown.this.source.getDescriptionForValue(DropDown.this.getModelObject()); } component.getResponse() .write(String.format( "<input %s type='text' %s value=\"%s\" id='visural_dropdown_value_%s' %s/>", DropDown.this.isEnabled() ? "" : "disabled ", getFlattenedValueAttributes(), StringUtil.htmlAttributeEscape(value), origMarkupId, outputPath ? "wicketpath=\"" + getPageRelativePath() + "_vwdd\"" : "")); } else { component.getResponse() .write("<input type='hidden' id='visural_dropdown_id_" + origMarkupId + "'/>"); } if (DropDown.this.isShowArrowIcon()) { component.getResponse().write( "<a class=\"visural_dropdown_arrow\" href=\"#\" onclick=\"visural_dropdown_toggle('" + origMarkupId + "'); return false;\">" + "<img class='visural_dropdown' alt='[v]' src='" + urlFor(getDropDownIconReference()) + "'/>" + "</a>"); } component.getResponse() .write("<div id=\"visural_dropdown_" + origMarkupId + "\" class=\"visural_dropdown\" " + "onMouseOver=\"visural_dropdown_mouseover('" + origMarkupId + "')\" " + "onMouseOut=\"visural_dropdown_mouseout('" + origMarkupId + "')\"></div>"); } }); if (autoAddToHeader()) { add(JavascriptPackageResource.getHeaderContribution(DropDown.class, "dropdown.js")); add(JavascriptPackageResource.getHeaderContribution(new StringBufferResourceReference())); add(getCSSHeaderContribution()); if (isSupportIE6()) { add(JavascriptPackageResource.getHeaderContribution(new JQueryBGIFrameResourceReference())); } } final String dsjs = DropDownDataSourceJSRender.getJS(source); add(new HeaderContributor(new IHeaderContributor() { public void renderHead(IHeaderResponse arg0) { arg0.renderOnDomReadyJavascript(dsjs); } })); add(new HeaderContributor(new IHeaderContributor() { public void renderHead(IHeaderResponse arg0) { arg0.renderOnDomReadyJavascript(getInitJS()); } })); }
From source file:com.vk.bingmaps.api.BingMap.java
License:Apache License
/** * @see org.apache.wicket.MarkupContainer#onRender(org.apache.wicket.markup.MarkupStream) *///from w w w .j a va 2 s. c o m @Override protected void onRender(MarkupStream markupStream) { super.onRender(markupStream); if (Application.DEVELOPMENT.equalsIgnoreCase(Application.get().getConfigurationType()) && !Application.get().getMarkupSettings().getStripWicketTags()) { log.warn("Application is in DEVELOPMENT mode && Wicket tags are not stripped," + " Firefox 3.0 will not render the GMap." + " Change to DEPLOYMENT mode || turn on Wicket tags stripping." + " See:" + " http://www.nabble.com/Gmap2-problem-with-Firefox-3.0-to18137475.html."); } }
From source file:com.wickettasks.web.application.WicketTasksApplication.java
License:Open Source License
public static WicketTasksApplication get() { return (WicketTasksApplication) Application.get(); }
From source file:com.wiquery.plugins.jqgrid.component.XMLDataRequestTarget.java
License:Apache License
/** * @see org.apache.wicket.IRequestTarget#respond(org.apache.wicket.RequestCycle) *//*from w ww .j av a 2 s. com*/ public final void respond(final RequestCycle requestCycle, StringBuffer writer) { final WebResponse response = (WebResponse) requestCycle.getResponse(); if (markupIdToComponent.values().contains(page)) { // the page itself has been added to the request target, we simply issue a redirect back // to the page final String url = requestCycle.urlFor(page).toString(); response.redirect(url); return; } for (ITargetRespondListener listener : respondListeners) { listener.onTargetRespond(this); } final Application app = Application.get(); // Determine encoding final String encoding = app.getRequestCycleSettings().getResponseRequestEncoding(); // Set content type based on markup type for page response.setCharacterEncoding(encoding); response.setContentType("text/xml; charset=" + encoding); // Make sure it is not cached by a client response.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); response.setHeader("Cache-Control", "no-cache, must-revalidate"); response.setHeader("Pragma", "no-cache"); writer.append("<?xml version=\"1.0\" encoding=\""); writer.append(encoding); writer.append("\"?>"); writer.append("<ajax-response>"); // invoke onbeforerespond event on listeners fireOnBeforeRespondListeners(); // normal behavior Iterator<String> it = prependJavascripts.iterator(); while (it.hasNext()) { String js = it.next(); respondInvocation(response, js, writer); } // process added components respondComponents(response, writer); fireOnAfterRespondListeners(response, writer); // execute the dom ready javascripts as first javascripts // after component replacement it = domReadyJavascripts.iterator(); while (it.hasNext()) { String js = it.next(); respondInvocation(response, js, writer); } it = appendJavascripts.iterator(); while (it.hasNext()) { String js = it.next(); respondInvocation(response, js, writer); } writer.append("</ajax-response>"); }
From source file:cz.muni.fi.pa165.languageschoolweb.model.SessionModel.java
License:Apache License
/** * @see org.apache.wicket.model.AbstractReadOnlyModel#getObject() *//*from w w w . j a v a 2 s. c o m*/ @Override public String getObject() { final String msg; String sessionId = Application.get().getSessionStore().getSessionId(RequestCycle.get().getRequest(), false); if (sessionId == null) { msg = "no concrete session is created yet (only a volatile one)"; } else { msg = "a session exists for this client, with session id " + sessionId; } return msg; }
From source file:cz.zcu.kiv.eegdatabase.wui.components.menu.ddm.MainMenu.java
License:Apache License
@Override public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { StringBuilder buf = new StringBuilder(2048); MenuItem menu = new MenuItem(EEGDatabaseMainMenu.Main); processMenu(menu, buf, RequestCycle.get(), Application.get().getResourceSettings().getLocalizer()); getResponse().write(buf);/*from w w w. j a v a 2 s . c o m*/ }