org.apache.wicket.request.Response Java Examples

The following examples show how to use org.apache.wicket.request.Response. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PreferenceManager.java    From syncope with Apache License 2.0 6 votes vote down vote up
public static void set(final Request request, final Response response, final Map<String, List<String>> prefs) {
    Map<String, String> current = new HashMap<>();

    String prefString = COOKIE_UTILS.load(COOKIE_NAME);
    if (prefString != null) {
        current.putAll(getPrefs(new String(Base64.getDecoder().decode(prefString.getBytes()))));
    }

    // after retrieved previous setting in order to overwrite the key ...
    prefs.forEach((key, values) -> current.put(key, StringUtils.join(values, ";")));

    try {
        COOKIE_UTILS.save(COOKIE_NAME, Base64.getEncoder().encodeToString(setPrefs(current).getBytes()));
    } catch (IOException e) {
        LOG.error("Could not save {} info: {}", PreferenceManager.class.getSimpleName(), current, e);
    }
}
 
Example #2
Source File: PreferenceManager.java    From syncope with Apache License 2.0 6 votes vote down vote up
public static void set(final Request request, final Response response, final String key, final String value) {
    String prefString = COOKIE_UTILS.load(COOKIE_NAME);

    final Map<String, String> current = new HashMap<>();
    if (prefString != null) {
        current.putAll(getPrefs(new String(Base64.getDecoder().decode(prefString.getBytes()))));
    }

    // after retrieved previous setting in order to overwrite the key ...
    current.put(key, value);

    try {
        COOKIE_UTILS.save(COOKIE_NAME, Base64.getEncoder().encodeToString(setPrefs(current).getBytes()));
    } catch (IOException e) {
        LOG.error("Could not save {} info: {}", PreferenceManager.class.getSimpleName(), current, e);
    }
}
 
Example #3
Source File: AjaxBusyIndicator.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
	public void afterRender(Component component) {
        Response r = component.getResponse();

        // Very important :
        // z-index value must be higher than any other component to block the screen
        // take care also of modal windows!
        // a modal window has z-index=20001
        // we use here a 99999 z-index
        
        r.write("<span style=\"display:none;");
//        r.write("position:absolute; left:1px; top:1px; margin:0px 0px 0px 0px; z-index:99999; width:100%; clear:none; height:100%; opacity:0.7; filter:alpha(opacity=50); ");
        r.write("position:absolute; left:0px; top:0px; margin:0px 0px 0px 0px; z-index:99999; width:100%; clear:none; height:100%; ");        
        r.write("height:expression(document.body.scrollHeight>document.body.offsetHeight ? document.body.scrollHeight: document.body.offsetHeight + 'px'); \" class=\"");
        r.write(getSpanClass());
        r.write("\" ");
        r.write("id=\"");
        r.write(getMarkupId());
        r.write("\"><table><tr><td align=\"center\">");
        r.write("<span><img src=\"");        
        if (busyIndicatorUrl == null) {
            r.write(getIndicatorUrl());
        } else {
            r.write(busyIndicatorUrl);
        }
        r.write("\" alt=\"\"/>");
        r.write("&nbsp;");
        r.write(busyIndicatorText);
        r.write("</span></td></tr></table></span>");
    }
 
Example #4
Source File: StorefrontApplication.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public Session newSession(Request request, Response response) {

    final ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    final LanguageService languageService = ctx.getBean(
            "languageService",
            LanguageService.class);

    return super.newSession(
            new StorefrontRequestDecorator(request, languageService.getSupportedLanguages(ShopCodeContext.getShopCode())),
            response);

}
 
Example #5
Source File: ToDoApplication.java    From isis-app-todoapp with Apache License 2.0 5 votes vote down vote up
@Override
public Session newSession(final Request request, final Response response) {
    if(!DEMO_MODE_USING_CREDENTIALS_AS_QUERYARGS) {
        return super.newSession(request, response);
    } 
    
    // else demo mode
    final AuthenticatedWebSessionForIsis s = (AuthenticatedWebSessionForIsis) super.newSession(request, response);
    final org.apache.wicket.util.string.StringValue user = request.getRequestParameters().getParameterValue("user");
    final org.apache.wicket.util.string.StringValue password = request.getRequestParameters().getParameterValue("pass");
    s.signIn(user.toString(), password.toString());
    return s;
}
 
Example #6
Source File: DownloadUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static void setCharacterEncoding(final Response response, final String encoding)
{
  final Object cresp = response.getContainerResponse();
  if (cresp instanceof HttpServletResponse) {
    ((HttpServletResponse) cresp).setCharacterEncoding(encoding);
  } else {
    log.warn("Character encoding not supported for response of type: " + response.getClass());
  }
}
 
Example #7
Source File: WebSocketRequestHandler.java    From onedev with MIT License 5 votes vote down vote up
private PartialPageUpdate getUpdate() {
	if (update == null) {
		update = new XmlPartialPageUpdate(page) {

			@Override
			protected void onBeforeRespond(Response response) {
				super.onBeforeRespond(response);
				BasePage page = (BasePage) getPage();
				if (page.getSessionFeedback().anyMessage())
					WebSocketRequestHandler.this.add(page.getSessionFeedback());
				
				for (Component component: markupIdToComponent.values()) {
					prependJavaScript((String.format("$(document).trigger('beforeElementReplace', '%s');", component.getMarkupId())));
					appendJavaScript((String.format("$(document).trigger('afterElementReplace', '%s');", component.getMarkupId())));
				}
			}

			@Override
			protected void onAfterRespond(Response response) {
				if (!markupIdToComponent.isEmpty())
					OneDev.getInstance(WebSocketManager.class).observe((BasePage) getPage());
				super.onAfterRespond(response);
			}
			
		};
	}
	return update;
}
 
Example #8
Source File: TreeIconsActionPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static ContextImage getCurrentFolderImage(final Response response, final AbstractLink folderLink, final TreeTableNode node)
{
  final ContextImage folderImage = (ContextImage) folderLink.get("folderImage");
  final ContextImage folderOpenImage = (ContextImage) folderLink.get("folderOpenImage");
  final boolean isOpen = node.isOpened();
  folderImage.setVisible(!isOpen);
  folderOpenImage.setVisible(isOpen);
  if (isOpen == true) {
    return folderOpenImage;
  } else {
    return folderImage;
  }
}
 
Example #9
Source File: ScriptingPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
private void jFreeChartExport()
{
  try {
    final ExportJFreeChart exportJFreeChart = (ExportJFreeChart) groovyResult.getResult();
    final StringBuilder sb = new StringBuilder();
    sb.append("pf_chart_");
    sb.append(DateHelper.getTimestampAsFilenameSuffix(new Date()));
    final Response response = getResponse();
    final String extension = exportJFreeChart.write(response.getOutputStream());
    sb.append('.').append(extension);
    final String filename = sb.toString();
    final int width = exportJFreeChart.getWidth();
    final int height = exportJFreeChart.getHeight();
    final JFreeChartImage image = new JFreeChartImage("image", exportJFreeChart.getJFreeChart(), exportJFreeChart.getImageType(), width,
        height);
    image.add(AttributeModifier.replace("width", String.valueOf(width)));
    image.add(AttributeModifier.replace("height", String.valueOf(height)));
    imageResultContainer.removeAll();
    imageResultContainer.add(image).setVisible(true);
    ((WebResponse) response).setAttachmentHeader(filename);
    ((WebResponse) response).setContentType(DownloadUtils.getContentType(filename));
    log.info("Starting download for file. filename:" + filename + ", content-type:" + DownloadUtils.getContentType(filename));
    response.getOutputStream().flush();
  } catch (final Exception ex) {
    error(getLocalizedMessage("error", ex.getMessage()));
    log.error(ex.getMessage(), ex);
  }
}
 
Example #10
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public static HttpServletResponse getHttpServletResponse(final Response response)
{
  return (HttpServletResponse) response.getContainerResponse();
}
 
Example #11
Source File: PFAutoCompleteRenderer.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void render(final String value, final Response response, final String criteria)
{
  response.write(value);
}
 
Example #12
Source File: DownloadUtils.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public static void setUTF8CharacterEncoding(final Response response)
{
  setCharacterEncoding(response, "utf-8");
}
 
Example #13
Source File: ImageBookmarkablePageLinkPanel.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public ImageBookmarkablePageLinkPanel(final String id, final Class< ? extends WebPage> pageClass, final Response response,
    final String relativeImagePath)
{
  this(id, pageClass);
  link.add(new PresizedImage("image", relativeImagePath));
}
 
Example #14
Source File: ImageBookmarkablePageLinkPanel.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public ImageBookmarkablePageLinkPanel(final String id, final Class< ? extends WebPage> pageClass, final Response response,
    final String relativeImagePath, final String tooltip)
{
  this(id, pageClass);
  link.add(new TooltipImage("image", relativeImagePath, tooltip));
}
 
Example #15
Source File: ImageBookmarkablePageLinkPanel.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public ImageBookmarkablePageLinkPanel(final String id, final Class< ? extends WebPage> pageClass, final Response response,
    final String relativeImagePath, final IModel<String> tooltip)
{
  this(id, pageClass);
  link.add(new TooltipImage("image", relativeImagePath, tooltip));
}
 
Example #16
Source File: Formatter.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public Map<String, Object> getData(final List<TimesheetDO> timeSheets, final Integer taskId, final Request request, final Response response,
  final TimesheetFilter actionFilter)
  {
return getData(timeSheets, taskId, (HttpServletRequest) request.getContainerRequest(),
    (HttpServletResponse) response.getContainerResponse(), actionFilter);
  }
 
Example #17
Source File: WicketPageTestBase.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Session newSession(final Request request, final Response response)
{
  return new MySession(request);
}
 
Example #18
Source File: NextServerApplication.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
@Override
public Session newSession(Request request, Response response) {
	return new NextServerSession(request);
}
 
Example #19
Source File: WicketApplication.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Session newSession(final Request request, final Response response)
{
  final MySession mySession = new MySession(request);
  return mySession;
}
 
Example #20
Source File: PFAutoCompleteRenderer.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @see org.apache.wicket.extensions.ajax.markup.html.autocomplete.IAutoCompleteRenderer#renderFooter(org.apache.wicket.request.Response, int)
 */
@Override
public void renderFooter(final Response response, final int count)
{
}
 
Example #21
Source File: PFAutoCompleteRenderer.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void renderHeader(final Response response)
{
}
 
Example #22
Source File: MetaHeaderItem.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
public void render(final Response response) {
    response.write("<meta http-equiv=\"" + key + "\" content=\"" + value + "\"/>");
    response.write("\n");
}
 
Example #23
Source File: PreferenceManager.java    From syncope with Apache License 2.0 4 votes vote down vote up
public static void setList(
        final Request request, final Response response, final Map<String, List<String>> prefs) {
    set(request, response, prefs);
}
 
Example #24
Source File: PreferenceManager.java    From syncope with Apache License 2.0 4 votes vote down vote up
public static void setList(
        final Request request, final Response response, final String key, final List<String> values) {
    set(request, response, key, StringUtils.join(values, ";"));
}
 
Example #25
Source File: SyncopeWebApplication.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
public Session newSession(final Request request, final Response response) {
    return new SyncopeEnduserSession(request);
}
 
Example #26
Source File: ShopApplication.java    From AppStash with Apache License 2.0 4 votes vote down vote up
@Override
public Session newSession(Request request, Response response) {
    return new ShopSession(request);
}
 
Example #27
Source File: ShopApplication.java    From the-app with Apache License 2.0 4 votes vote down vote up
@Override
public Session newSession(Request request, Response response) {
    return new ShopSession(request);
}
 
Example #28
Source File: OneWebApplication.java    From onedev with MIT License 4 votes vote down vote up
@Override
public Session newSession(Request request, Response response) {
	return new WebSession(request);
}