List of usage examples for org.apache.wicket.request.http WebRequest getRequestParameters
public IRequestParameters getRequestParameters()
From source file:com.google.code.jqwicket.ui.validationengine.AjaxValidationRule.java
License:Apache License
protected AbstractAjaxBehavior newAjaxBehavior() { return new AbstractAjaxBehavior() { private static final long serialVersionUID = 1L; public void onRequest() { WebRequest req = (WebRequest) RequestCycle.get().getRequest(); String validateError = req.getRequestParameters().getParameterValue("validateError").toString(); String validateId = req.getRequestParameters().getParameterValue("validateId").toString(); boolean result = execute(new ExecutionContext(validateError, validateId, req.getRequestParameters().getParameterValue("validateValue").toString(), req.getRequestParameters().getParameterValue("extraData").toString())); StringBuffer buf = new StringBuffer("{'jsonValidateReturn':"); buf.append("[").append(Utils.quote(validateId)); buf.append(",").append(Utils.quote(validateError)); buf.append(",").append(Utils.quote(String.valueOf(result))); buf.append("]}"); RequestCycle.get().scheduleRequestHandlerAfterCurrent(new TextRequestHandler(buf.toString())); }/*from www . j a v a2 s . com*/ }; }
From source file:com.googlecode.wickedcharts.wicket6.JavaScriptExpressionSendingAjaxBehavior.java
License:Apache License
/** * Reads the value of the given javascript variable from the AJAX request. * //from w w w . ja v a2 s . c o m * @param parameterName * the parameter name of the javascript expression whose value to * read. The parameterName must have been specified earlier when * calling {@link #addJavaScriptValue(String, String)}. * @return the string representation of the javascript expression's value */ protected StringValue getVariableValue(String parameterName) { RequestCycle cycle = RequestCycle.get(); WebRequest webRequest = (WebRequest) cycle.getRequest(); StringValue value = webRequest.getRequestParameters().getParameterValue(parameterName); return value; }
From source file:eu.esdihumboldt.hale.server.templates.war.components.RecaptchaPanel.java
License:Open Source License
/** * Constructor.// ww w . j a v a2 s.c om * * @param id the component ID */ public RecaptchaPanel(String id) { super(id); add(new FormComponent<String>("imagePassword", new Model<String>()) { private static final long serialVersionUID = 6622368671409426173L; @Override public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) { String privateCaptchaKey = getPrivateKey(); String publicCaptchaKey = getPublicKey(); ReCaptcha recaptcha = ReCaptchaFactory.newReCaptcha(publicCaptchaKey, privateCaptchaKey, false); Properties properties = new Properties(); properties.put("theme", "clean"); replaceComponentTagBody(markupStream, openTag, recaptcha.createRecaptchaHtml(null, properties)); } @Override public void validate() { WebRequest request = (WebRequest) RequestCycle.get().getRequest(); HttpServletRequest servletRequest = (HttpServletRequest) getRequest().getContainerRequest(); // FIXME find proxied address when running behind proxy? String remoteAddr = servletRequest.getRemoteAddr(); String challenge = request.getRequestParameters().getParameterValue("recaptcha_challenge_field") .toString(); String response = request.getRequestParameters().getParameterValue("recaptcha_response_field") .toString(); if (response == null || response.isEmpty()) { error("Please enter the Captcha or log in to upload a template."); return; } String privateCaptchaKey = getPrivateKey(); String publicCaptchaKey = getPublicKey(); ReCaptcha recaptcha = ReCaptchaFactory.newReCaptcha(publicCaptchaKey, privateCaptchaKey, false); ReCaptchaResponse reCaptchaResponse = recaptcha.checkAnswer(remoteAddr, challenge, response); if (!reCaptchaResponse.isValid()) { error("The Captcha was not entered correctly. Please enter the Captcha or log in to upload a template."); } } }); }
From source file:org.hippoecm.frontend.PluginPage.java
License:Apache License
public PluginPage(IApplicationFactory appFactory) { Task pageInitTask = null;//w w w .j av a2 s.c o m try { if (HDC.isStarted()) { pageInitTask = HDC.getCurrentTask().startSubtask("PluginPage.init"); } pageId = ((PluginUserSession) UserSession.get()).getPageId(); add(new EmptyPanel("root")); mgr = new PluginManager(this); context = new PluginContext(mgr, new JavaPluginConfig("home")); context.connect(null); context.registerTracker(this, "service.root"); pluginConfigService = new PluginConfigFactory(UserSession.get(), appFactory); context.registerService(pluginConfigService, IPluginConfigService.class.getName()); obRegistry = new ObservableRegistry(context, null); obRegistry.startObservation(); dialogService = new DialogServiceFactory("dialog"); dialogService.init(context, IDialogService.class.getName()); add(dialogService.getComponent()); context.registerService(this, Home.class.getName()); registerGlobalBehaviorTracker(); add(menuBehavior = new ContextMenuBehavior()); IClusterConfig pluginCluster = pluginConfigService.getDefaultCluster(); IClusterControl clusterControl = context.newCluster(pluginCluster, null); clusterControl.start(); IController controller = context.getService(IController.class.getName(), IController.class); if (controller != null) { WebRequest request = (WebRequest) RequestCycle.get().getRequest(); controller.process(request.getRequestParameters()); } } finally { if (pageInitTask != null) { pageInitTask.stop(); } } }
From source file:org.opensingular.form.wicket.mapper.attachment.BaseJQueryFileUploadBehavior.java
License:Apache License
protected IRequestParameters params() { WebRequest request = (WebRequest) RequestCycle.get().getRequest(); return request.getRequestParameters(); }
From source file:org.opensingular.form.wicket.mapper.attachment.DownloadSupportedBehavior.java
License:Apache License
private void handleRequest() throws IOException { WebRequest request = (WebRequest) RequestCycle.get().getRequest(); IRequestParameters parameters = request.getRequestParameters(); StringValue id = parameters.getParameterValue("fileId"); StringValue name = parameters.getParameterValue("fileName"); writeResponse(getDownloadURL(id.toString(), name.toString())); }
From source file:org.wicketstuff.openlayers.MapWithGetSpecificFeaturePage.java
License:Apache License
/** * //from w ww .ja v a 2 s . co m */ public MapWithGetSpecificFeaturePage() { super(); List<Layer> layerList = new LinkedList<Layer>(); // function init(){ // OpenLayers.ProxyHost= "proxy.cgi?url="; // map = new OpenLayers.Map('map', { // controls: [ // new OpenLayers.Control.PanZoom(), // new OpenLayers.Control.Permalink(), // new OpenLayers.Control.Navigation() // ] // }); // layer = new OpenLayers.Layer.WMS( // "States WMS/WFS", // "http://demo.opengeo.org/geoserver/ows", // {layers: 'topp:states', format: 'image/gif'} // ); HashMap<String, String> options = new LinkedHashMap<String, String>(); options.put("layers", JSUtils.getQuotedString("topp:states")); options.put("format", JSUtils.getQuotedString("image/png8")); options.put("srs", JSUtils.getQuotedString("EPSG:4326")); WMS layer = new WMS("States WMS/WFS", "http://demo.opengeo.org:80/geoserver/wms", options); layerList.add(layer); final WFSProxyBehavior proxyBehaviour = new WFSProxyBehavior(); final AbstractDefaultAjaxBehavior callbackBehaviour = new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void respond(AjaxRequestTarget target) { RequestCycle rc = RequestCycle.get(); WebRequest wr = (WebRequest) rc.getRequest(); String state = wr.getRequestParameters().getParameterValue("propertyValue").toString(); target.prependJavaScript("alert('you selected state = " + state + ");"); } }; GetSpecificFeature control = new GetSpecificFeature(layer, proxyBehaviour, callbackBehaviour, "http://demo.opengeo.org:80/geoserver/wms", "topp", "http://www.openplans.org/topp", "states", 4326, "STATE_NAME"); HashMap<String, String> mapOptions = new LinkedHashMap<String, String>(); mapOptions.put("projection", JSUtils.getQuotedString("EPSG:4326")); mapOptions.put("units", JSUtils.getQuotedString("degrees")); // mapOptions.put("maxExtent", // "new OpenLayers.Bounds(143.834,-43.648,148.479,-39.573)"); OpenLayersMap map = new OpenLayersMap("map", true, layerList, mapOptions) { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * * @see org.wicketstuff.openlayers.OpenLayersMap#getJSinit() */ @Override protected String getJSinit() { return "OpenLayers.ProxyHost='" + proxyBehaviour.getProxyUrl() + "';\n" + super.getJSinit(); } }; map.setCenter(LonLat.parse("-140.444336,25.115234,-44.438477,50.580078")); map.setZoom(3); map.addControl(control); map.addControl(Control.PanZoomBar); map.addControl(Control.Navigation); map.addControl(Control.Permalink); map.add(proxyBehaviour); map.add(callbackBehaviour); add(map); }
From source file:org.wicketstuff.push.timer.TimerPushBehavior.java
License:Apache License
/** * {@inheritDoc}// www . j a v a 2 s .c om */ @Override protected void onTimer(final AjaxRequestTarget target) { if (isStopped()) { getComponent().remove(this); return; } final TimerPushService pushService = TimerPushService.get(target.getPage().getApplication()); final WebRequest request = (WebRequest) RequestCycle.get().getRequest(); if (!request.getRequestParameters().getParameterValue("unload").isNull()) // if the page is unloaded notify the pushService to disconnect all push nodes for (final TimerPushNode<?> node : handlers.keySet()) pushService.onDisconnect(node); else // retrieve all collected events and process them for (final Entry<TimerPushNode, IPushEventHandler> entry : handlers.entrySet()) { final TimerPushNode node = entry.getKey(); for (final IPushEventContext<?> ctx : (List<IPushEventContext<?>>) pushService.pollEvents(node)) try { entry.getValue().onEvent(target, ctx.getEvent(), node, ctx); } catch (final RuntimeException ex) { LOG.error("Failed while processing event", ex); } } }
From source file:sk.drunkenpanda.leaflet.behaviors.LeafletAjaxBehavior.java
License:Apache License
/** * Reads the value of the given javascript variable from the AJAX request. * * @param parameterName the parameter name of javascript variable whose value should be read. * Parameter name must have been specified earlier * using {@link #addJavascriptValue(java.lang.String, java.lang.String)}. * @return the string representation of javascript variable *//*from w w w . j a va 2 s .c o m*/ protected StringValue getVariableValue(String parameterName) { Args.notNull(parameterName, "parameterName"); RequestCycle requestCycle = RequestCycle.get(); WebRequest request = (WebRequest) requestCycle.getRequest(); StringValue parameterValue = request.getRequestParameters().getParameterValue(parameterName); return parameterValue; }