本文整理汇总了Java中org.apache.wicket.request.http.WebResponse类的典型用法代码示例。如果您正苦于以下问题:Java WebResponse类的具体用法?Java WebResponse怎么用?Java WebResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebResponse类属于org.apache.wicket.request.http包,在下文中一共展示了WebResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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);
}
示例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>");
}
示例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.");
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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;
}
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
}
示例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()));
}
示例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));
}