• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java WebResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.wicket.request.http.WebResponse的典型用法代码示例。如果您正苦于以下问题:Java WebResponse类的具体用法?Java WebResponse怎么用?Java WebResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WebResponse类属于org.apache.wicket.request.http包,在下文中一共展示了WebResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: respond

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
/** {@inheritDoc} */
public void respond(final IRequestCycle requestCycle)
{
	String location = requestCycle.getUrlRenderer().renderRelativeUrl(Url.parse(getRedirectUrl()));
	
	WebResponse response = (WebResponse)requestCycle.getResponse();

	if (status == HttpServletResponse.SC_MOVED_TEMPORARILY)
	{
		response.sendRedirect(location);
	}
	else
	{
		response.setStatus(status);
		response.setHeader("Location", location);
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:18,代码来源:RedirectRequestHandler.java


示例2: storeRecentOpened

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
private void storeRecentOpened(String blobPath) {
	List<String> recentOpened = getRecentOpened();
	recentOpened.remove(blobPath);
	recentOpened.add(0, blobPath);
	while (recentOpened.size() > MAX_RECENT_OPENED)
		recentOpened.remove(recentOpened.size()-1);
	String encoded;
	try {
		encoded = URLEncoder.encode(Joiner.on("\n").join(recentOpened), Charsets.UTF_8.name());
	} catch (UnsupportedEncodingException e) {
		throw new RuntimeException(e);
	}
	Cookie cookie = new Cookie(COOKIE_RECENT_OPENED, encoded);
	cookie.setMaxAge(Integer.MAX_VALUE);
	WebResponse response = (WebResponse) RequestCycle.get().getResponse();
	response.addCookie(cookie);
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:18,代码来源:QuickSearchPanel.java


示例3: respond

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
@Override
public void respond(IRequestCycle requestCycle) {
    String script = ToastrHelper.generateJs(singularException, ToastrType.ERROR, false);

    WebResponse response = (WebResponse)requestCycle.getResponse();
    final String encoding = Application.get()
            .getRequestCycleSettings()
            .getResponseRequestEncoding();

    // Set content type based on markup type for page
    response.setContentType("text/xml; charset=" + encoding);

    // Make sure it is not cached by a client
    response.disableCaching();

    response.write("<?xml version=\"1.0\" encoding=\"");
    response.write(encoding);
    response.write("\"?>");
    response.write("<ajax-response>");
    response.write("<evaluate><![CDATA[" + script + "]]></evaluate>");
    response.write("</ajax-response>");

}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:24,代码来源:AjaxErrorRequestHandler.java


示例4: onSuccessfulLogin

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
public static void onSuccessfulLogin(String username,
        SessionAccessorPage page,
        SSOLoginData loginData, SessionService sessionService,
        SubsystemService subsystemService) {
    if (loginData == null) {
        throw new IllegalStateException("loginData is null");
    }

    SSOSession ssoSession = sessionService.createSSOSession(username);
    Cookie cookie = new Cookie(SSOUtils.SSO_SESSION_ID_COOKIE_NAME, ssoSession.getIdentifier());
    cookie.setMaxAge(SSOUtils.SSO_SESSION_ID_COOKIE_MAXAGE);
    cookie.setPath(getApplicationRootPath(page));
    ((WebResponse) RequestCycle.get().getResponse()).addCookie(cookie);

    SubsystemTokenData token = subsystemService.issueSubsystemTokenIfCanLogin(
            ssoSession.getId(), loginData.getSubsystemIdentifier());
    if (token != null) {
        // can login: redirecting a user to a subsystem
        SSOUtils.redirectToSubsystem(page, loginData, token);
    } else {
        // can't login: just display an error
        // actually, this should not happen as we've already
        // checked user access, but just in case...
        SSOUtils.redirectToCantLoginErrorPage(page, loginData, "Please check if user can login to subsystems. Please note: assign actions to your role only via groups. Do not assign actions directly to role.");
    }
}
 
开发者ID:payneteasy,项目名称:superfly,代码行数:27,代码来源:SSOUtils.java


示例5: HtmlIFramePanel

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
public HtmlIFramePanel(String id, final IModel<String> htmlModel) {

        super(id);

        IResource resource = new IResource() {
            @Override
            public void respond(Attributes attributes) {
                WebResponse response = (WebResponse) attributes.getResponse();
                response.setContentType("text/html; charset=utf-8");
                response.write(htmlModel.getObject());
            }
        };

        setResource(resource);

    }
 
开发者ID:jkrasnay,项目名称:panelized,代码行数:17,代码来源:HtmlIFramePanel.java


示例6: map

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
@SuppressWarnings("illegalcatch")
@Override
public IRequestHandler map(Exception e) {
    try {
        // we don't want to cache an exceptional reply in the browser
        getWebResponse().ifPresent(WebResponse::disableCaching);

        return internalMap(e);
    } catch (RuntimeException ie) { // exception thrown while handling the exception
        if (LOG.isDebugEnabled()) {
            LOG.error("An error occurred while handling a previous error: " + ie.getMessage(), ie);
        }

        LOG.error("Unexpected exception when handling another exception: " + e.getMessage(), e);
        // the mapping process failed, so this is the fallback error handler (nothing more we can really do)
        return new ErrorCodeRequestHandler(INTERNAL_SERVER_ERROR);
    }
}
 
开发者ID:flex-oss,项目名称:flex-ui,代码行数:19,代码来源:AbstractExceptionMapper.java


示例7: respond

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
@Override
public void respond(Attributes attributes) {
	if (mainPage.getNanopub() == null) return;
	WebResponse resp = (WebResponse) attributes.getResponse();
	RDFFormat format = mainPage.getFormat();
	if (format == null) {
		format = mainPage.getFormat();
	}
	if (format == null) {
		format = RDFFormat.TRIG;
	}
	resp.setContentType(format.getMIMETypes().get(0));
	resp.setAttachmentHeader("nanopub." + format.getDefaultFileExtension());
	try {
		NanopubUtils.writeToStream(mainPage.getNanopub(), resp.getOutputStream(), format);
	} catch (Exception ex) {
		ex.printStackTrace();
	}
	resp.close();
}
 
开发者ID:tkuhn,项目名称:nanopub-validator,代码行数:21,代码来源:DownloadResource.java


示例8: logout

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
public static void logout(final MySession mySession, final WebRequest request, final WebResponse response,
    final UserXmlPreferencesCache userXmlPreferencesCache, final MenuBuilder menuBuilder)
{
  final PFUserDO user = mySession.getUser();
  if (user != null) {
    userXmlPreferencesCache.flushToDB(user.getId());
    userXmlPreferencesCache.clear(user.getId());
    if (menuBuilder != null) {
      menuBuilder.expireMenu(user.getId());
    }
  }
  mySession.logout();
  final Cookie stayLoggedInCookie = UserFilter.getStayLoggedInCookie(WicketUtils.getHttpServletRequest(request));
  if (stayLoggedInCookie != null) {
    stayLoggedInCookie.setMaxAge(0);
    stayLoggedInCookie.setValue(null);
    stayLoggedInCookie.setPath("/");
    response.addCookie(stayLoggedInCookie);
  }
}
 
开发者ID:micromata,项目名称:projectforge-webapp,代码行数:21,代码来源:LoginPage.java


示例9: toObject

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
/**
 * Utility method to convert string values to the corresponding objects.
 * 
 * @param clazz
 *            the type of the object we want to obtain.
 * @param value
 *            the string value we want to convert.
 * @return the object corresponding to the converted string value, or null
 *         if value parameter is null
 */
public static Object toObject(Class clazz, String value) throws IllegalArgumentException {
	if (value == null)
		return null;
	// we use the standard Wicket conversion mechanism to obtain the
	// converted value.
	try {
		IConverter converter = Application.get().getConverterLocator().getConverter(clazz);

		return converter.convertToObject(value, Session.get().getLocale());
	} catch (Exception e) {
		WebResponse response = (WebResponse) RequestCycle.get().getResponse();

		response.setStatus(400);
		response.write("Could not find a suitable constructor for value '" + value
				+ "' of type '" + clazz + "'");

		return null;
	}
}
 
开发者ID:bitstorm,项目名称:Wicket-rest-annotations,代码行数:30,代码来源:AbstractRestResource.java


示例10: onSelectTab

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
private void onSelectTab(AjaxRequestTarget target) {
	WebResponse response = (WebResponse) RequestCycle.get().getResponse();
	Cookie cookie = new Cookie(COOKIE_SEARCH_TYPE, option.getClass().getName());
	cookie.setMaxAge(Integer.MAX_VALUE);
	response.addCookie(cookie);
	SearchOptionEditor editor = newSearchOptionEditor(option);
	form.replace(editor);
	target.add(editor);
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:10,代码来源:AdvancedSearchPanel.java


示例11: onRender

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
@Override
protected void onRender() {
	final String encoding = getApplication().getRequestCycleSettings().getResponseRequestEncoding();
	final boolean validEncoding = (Strings.isEmpty(encoding) == false);
	final String contentType;
	if (validEncoding) {
		contentType = getMarkupType().getMimeType() + "; charset=" + encoding;
	} else {
		contentType = getMarkupType().getMimeType();
	}

	((WebResponse) RequestCycle.get().getResponse()).setContentType(contentType);

	super.onRender();
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:16,代码来源:AbstractMonitoringPage.java


示例12: set

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
public void set(final Request request, final Response response,
        final Map<String, List<String>> prefs) {

    Cookie prefCookie =
            ((WebRequest) request).getCookie(Constants.PREFS_COOKIE_NAME);

    final Map<String, String> current = new HashMap<String, String>();

    if (prefCookie == null || !StringUtils.hasText(prefCookie.getValue())) {
        prefCookie = new Cookie(Constants.PREFS_COOKIE_NAME, null);
    } else {
        current.putAll(getPrefs(new String(Base64.decodeBase64(
                prefCookie.getValue().getBytes()))));
    }

    // after retrieved previous setting in order to overwrite the key ...
    for (Entry<String, List<String>> entry : prefs.entrySet()) {
        current.put(entry.getKey(), StringUtils.collectionToDelimitedString(
                entry.getValue(), ";"));
    }

    try {
        prefCookie.setValue(new String(
                Base64.encodeBase64(setPrefs(current).getBytes())));
    } catch (IOException e) {
        LOG.error("Could not set preferences " + current, e);
    }

    prefCookie.setMaxAge(ONE_YEAR_TIME);
    ((WebResponse) response).addCookie(prefCookie);
}
 
开发者ID:ilgrosso,项目名称:oldSyncopeIdM,代码行数:32,代码来源:PreferenceManager.java


示例13: setHeaders

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
@Override
protected void setHeaders(final WebResponse response) {
    final HttpServletRequest request = RequestCycles.getContainerRequest();
    final Integer statusCode = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
    if (statusCode != null) {
        response.setStatus(statusCode);
    } else {
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:11,代码来源:InternalErrorPage.java


示例14: setCookie

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
public static void setCookie(String name, Object value) {
    if (value == null) {
        clearCookie(name);
        return;
    }

    WebResponse response = (WebResponse) RequestCycle.get().getResponse();
    response.addCookie(new Cookie(name, value.toString()));
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:10,代码来源:CookieUtils.java


示例15: onClick

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
@Override
public void onClick() {
    IResourceStream resourceStream = getResourceStream();
    RequestCycle requestCycle = getRequestCycle();
    WebResponse response = (WebResponse) requestCycle.getResponse();
    response.setHeader("Cache-Control", "no-store");

    requestCycle.scheduleRequestHandlerAfterCurrent(
            new ResourceStreamRequestHandler(resourceStream)
                    .setFileName(getFileName())
                    .setContentDisposition(ContentDisposition.ATTACHMENT));
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:13,代码来源:DownloadButton.java


示例16: configureResponse

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
@Override
protected void configureResponse(WebResponse response) {
    super.configureResponse(response);
    response.setHeader("Cache-Control", "no-cache, max-age=0, must-revalidate, no-store");

    //for IE
    response.setHeader("Expires", "-1");
    response.setHeader("Pragma", "no-cache");
}
 
开发者ID:payneteasy,项目名称:superfly,代码行数:10,代码来源:BaseSSOPage.java


示例17: redirectTo

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
private void redirectTo(RequestCycle cycle, Url urlWithoutDirectBuy) {
    Url requestUrl = cycle.getRequest().getUrl();
    if (!requestUrl.equals(urlWithoutDirectBuy)) {
        WebResponse response = (WebResponse) cycle.getResponse();
        response.reset();
        response.sendRedirect(urlWithoutDirectBuy.toString(Url.StringMode.FULL));
    }
}
 
开发者ID:zutherb,项目名称:AppStash,代码行数:9,代码来源:DirectBuyRequestCycleListener.java


示例18: newStringResponse

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
private WebResponse newStringResponse() {
    WebResponse response = (WebResponse) getResponse();
    response.setContentType("text/plain");
    response.write(responseText());
    response.flush();
    response.setStatus(HttpStatus.OK.value());
    return response;
}
 
开发者ID:zutherb,项目名称:AppStash,代码行数:9,代码来源:AbstractPlainTextPage.java


示例19: ok

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
public static final <T> Result<T> ok(WebResponse response, Gson gson,
        T content) throws JsonIOException, IOException {
    Result<T> result = new Result<T>(response, 200, "application/json");
    response.disableCaching();
    HttpServletResponse httpServletResponse = (HttpServletResponse) response
            .getContainerResponse();
    httpServletResponse.setCharacterEncoding("UTF-8");
    gson.toJson(content, httpServletResponse.getWriter());
    return result;
}
 
开发者ID:PkayJava,项目名称:pluggable,代码行数:11,代码来源:Result.java


示例20: importResult

import org.apache.wicket.request.http.WebResponse; //导入依赖的package包/类
@Secured(roles = {@Role(name = "ROLE_REST_QUERY_PLUGIN_IMPORT", description = "Access Query Plugin Rest Import")})
@RequestMapping(value = "/queryplugin/api/import", method = RequestMethod.POST)
@ApiMethod(description = "import data")
public Result<Void> importResult(
        AbstractWebApplication application,
        WebRequest request,
        WebResponse response,
        Gson gson,
        @ApiParam(name = "table", description = "table name", required = true, type = String.class) StringValue table,
        @ApiParam(name = "field", description = "field {'name':'value'}", required = true, type = String[].class) StringValue[] field)
        throws JsonIOException, IOException {

    if ("".equals(table.toString("")) || field == null || field.length == 0) {
        return Result.badRequest(response, "application/json", Void.class);
    }
    SimpleJdbcInsert insert = new SimpleJdbcInsert(
            application.getJdbcTemplate());
    insert.withTableName(table.toOptionalString());
    Map<String, Object> fields = new HashMap<String, Object>();
    for (StringValue f : field) {
        Field fi = gson.fromJson(f.toOptionalString(), Field.class);
        fields.put(fi.getName(), fi.getValue());
    }
    try {
        insert.execute(fields);
    } catch (DuplicateKeyException duplicateKeyException) {
        // LOGGER.info(duplicateKeyException.getMessage());
    }
    return Result.ok(response, "application/json", Void.class);
}
 
开发者ID:PkayJava,项目名称:pluggable,代码行数:31,代码来源:ImportRestAPI.java



注:本文中的org.apache.wicket.request.http.WebResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DoubleByReference类代码示例发布时间:2022-05-21
下一篇:
Java Instruction35c类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap