use of org.apache.wicket.request.Request in project wicket by apache.
the class WebApplication method unmount.
/**
* Unregisters all {@link IRequestMapper}s which would match on a this path.
* <p>
* Useful in OSGi environments where a bundle may want to update the mount point.
* </p>
*
* @param path
* the path to unmount
*/
public void unmount(String path) {
Args.notNull(path, "path");
if (path.charAt(0) == '/') {
path = path.substring(1);
}
IRequestMapper mapper = getRootRequestMapper();
while (mapper instanceof IRequestMapperDelegate) {
mapper = ((IRequestMapperDelegate) mapper).getDelegateMapper();
}
/*
* Only attempt to unmount if root request mapper is either a compound, or wraps a compound to avoid leaving the
* application with no mappers installed.
*/
if (mapper instanceof ICompoundRequestMapper) {
final Url url = Url.parse(path);
Request request = new Request() {
@Override
public Url getUrl() {
return url;
}
@Override
public Url getClientUrl() {
return url;
}
@Override
public Locale getLocale() {
return null;
}
@Override
public Charset getCharset() {
return null;
}
@Override
public Object getContainerRequest() {
return null;
}
};
unmountFromCompound((ICompoundRequestMapper) mapper, request);
}
}
use of org.apache.wicket.request.Request in project wicket by apache.
the class DefaultExceptionMapper method isProcessingAjaxRequest.
/**
* @return true if current request is an AJAX request, false otherwise.
*/
protected boolean isProcessingAjaxRequest() {
RequestCycle rc = RequestCycle.get();
Request request = rc.getRequest();
if (request instanceof WebRequest) {
return ((WebRequest) request).isAjax();
}
return false;
}
use of org.apache.wicket.request.Request in project wicket by apache.
the class Session method internalDetach.
/**
* NOT PART OF PUBLIC API, DO NOT CALL
*
* Detaches internal state of {@link Session}
*/
public void internalDetach() {
if (dirty) {
Request request = RequestCycle.get().getRequest();
getSessionStore().flushSession(request, this);
}
dirty = false;
}
use of org.apache.wicket.request.Request in project wicket by apache.
the class Session method bind.
/**
* Force binding this session to the application's {@link ISessionStore session store} if not
* already done so.
* <p>
* A Wicket application can operate in a session-less mode as long as stateless pages are used.
* Session objects will be then created for each request, but they will only live for that
* request. You can recognize temporary sessions by calling {@link #isTemporary()} which
* basically checks whether the session's id is null. Hence, temporary sessions have no session
* id.
* </p>
* <p>
* By calling this method, the session will be bound (made not-temporary) if it was not bound
* yet. It is useful for cases where you want to be absolutely sure this session object will be
* available in next requests. If the session was already bound (
* {@link ISessionStore#lookup(Request) returns a session}), this call will be a noop.
* </p>
*/
public final void bind() {
// modified call.
if (RequestCycle.get() == null) {
return;
}
ISessionStore store = getSessionStore();
Request request = RequestCycle.get().getRequest();
if (store.lookup(request) == null) {
// explicitly create a session
id = store.getSessionId(request, true);
// bind it
store.bind(request, this);
if (temporarySessionAttributes != null) {
for (Map.Entry<String, Serializable> entry : temporarySessionAttributes.entrySet()) {
store.setAttribute(request, entry.getKey(), entry.getValue());
}
temporarySessionAttributes = null;
}
}
}
use of org.apache.wicket.request.Request in project wicket by apache.
the class RequestCycleListenerTest method newRequestCycle.
private RequestCycle newRequestCycle(final RuntimeException exception) {
final Response originalResponse = newResponse();
Request request = new MockWebRequest(Url.parse("http://wicket.apache.org"));
handler = new IRequestHandler() {
@Override
public void respond(IRequestCycle requestCycle) {
if (exception != null) {
throw exception;
}
responses++;
}
@Override
public void detach(IRequestCycle requestCycle) {
detaches++;
}
};
IRequestMapper requestMapper = new IRequestMapper() {
@Override
public IRequestHandler mapRequest(Request request) {
return handler;
}
@Override
public Url mapHandler(IRequestHandler requestHandler) {
throw new UnsupportedOperationException();
}
@Override
public int getCompatibilityScore(Request request) {
throw new UnsupportedOperationException();
}
};
IExceptionMapper exceptionMapper = new IExceptionMapper() {
@Override
public IRequestHandler map(Exception e) {
exceptionsMapped++;
return null;
}
};
RequestCycleContext context = new RequestCycleContext(request, originalResponse, requestMapper, exceptionMapper);
RequestCycle cycle = new RequestCycle(context);
if (Application.exists()) {
cycle.getListeners().add(Application.get().getRequestCycleListeners());
}
return cycle;
}
Aggregations