本文整理匯總了Java中org.apache.wicket.request.cycle.RequestCycle類的典型用法代碼示例。如果您正苦於以下問題:Java RequestCycle類的具體用法?Java RequestCycle怎麽用?Java RequestCycle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RequestCycle類屬於org.apache.wicket.request.cycle包,在下文中一共展示了RequestCycle類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getUrlString
import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
@Override
public String getUrlString(Class<? extends Page> pageClass, QueryFacetsSelection selection, SolrDocument document) {
final PageParameters params = new PageParameters();
if (selection != null) {
params.mergeWith(paramsConverter.toParameters(selection));
}
if (document != null) {
params.add(VloWebAppParameters.DOCUMENT_ID, document.getFirstValue(FacetConstants.FIELD_ID));
}
final String style = Session.get().getStyle();
if (style != null) {
params.add(VloWebAppParameters.THEME, style);
}
final CharSequence url = RequestCycle.get().urlFor(pageClass, params);
final String absoluteUrl = RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(url));
return absoluteUrl;
}
示例2: newWebRequest
import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
@Override
public WebRequest newWebRequest(HttpServletRequest servletRequest, String filterPath) {
return new ServletWebRequest(servletRequest, filterPath) {
@Override
public boolean shouldPreserveClientUrl() {
if (RequestCycle.get().getActiveRequestHandler() instanceof RenderPageRequestHandler) {
RenderPageRequestHandler requestHandler =
(RenderPageRequestHandler) RequestCycle.get().getActiveRequestHandler();
/*
* Add this to make sure that the page url does not change upon errors, so that
* user can know which page is actually causing the error. This behavior is common
* for main stream applications.
*/
if (requestHandler.getPage() instanceof BaseErrorPage)
return true;
}
return super.shouldPreserveClientUrl();
}
};
}
示例3: respond
import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
@Override
protected void respond(AjaxRequestTarget target) {
IRequestParameters params = RequestCycle.get().getRequest().getPostParameters();
String tooltipId = params.getParameterValue("tooltip").toString();
String commitHash = params.getParameterValue("commit").toString();
RevCommit commit = getProject().getRevCommit(commitHash);
String authoring;
if (commit.getAuthorIdent() != null) {
authoring = commit.getAuthorIdent().getName();
if (commit.getCommitterIdent() != null)
authoring += " " + DateUtils.formatAge(commit.getCommitterIdent().getWhen());
authoring = "'" + JavaScriptEscape.escapeJavaScript(authoring) + "'";
} else {
authoring = "undefined";
}
String message = JavaScriptEscape.escapeJavaScript(commit.getFullMessage());
String script = String.format("gitplex.server.blameMessage.show('%s', %s, '%s');", tooltipId, authoring, message);
target.appendJavaScript(script);
}
示例4: MarkdownEditor
import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
/**
* @param id
* component id of the editor
* @param model
* markdown model of the editor
* @param compactMode
* editor in compact mode occupies horizontal space and is suitable
* to be used in places such as comment aside the code
*/
public MarkdownEditor(String id, IModel<String> model, boolean compactMode) {
super(id, model);
this.compactMode = compactMode;
String cookieKey;
if (compactMode)
cookieKey = "markdownEditor.compactMode.split";
else
cookieKey = "markdownEditor.normalMode.split";
WebRequest request = (WebRequest) RequestCycle.get().getRequest();
Cookie cookie = request.getCookie(cookieKey);
if (cookie!=null && "true".equals(cookie.getValue())) {
initialSplit = true;
} else {
initialSplit = !compactMode;
}
}
示例5: storeRecentOpened
import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的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);
}
示例6: AdvancedSearchPanel
import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
public AdvancedSearchPanel(String id, IModel<Project> projectModel, IModel<String> revisionModel) {
super(id);
this.projectModel = projectModel;
this.revisionModel = revisionModel;
WebRequest request = (WebRequest) RequestCycle.get().getRequest();
Cookie cookie = request.getCookie(COOKIE_SEARCH_TYPE);
if (cookie != null) {
try {
option = (SearchOption) Class.forName(cookie.getValue()).newInstance();
} catch (Exception e) {
logger.debug("Error restoring search option from cookie", e);
}
}
}
示例7: isInstantiationAuthorized
import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
@Override
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
if (componentClass == CmsPage.class) {
RequestCycle requestCycle = RequestCycle.get();
String pageId = requestCycle.getRequest().getQueryParameters().getParameterValue("pageId").toString("");
PageRoleTable pageRoleTable = Tables.PAGE_ROLE.as("pageRoleTable");
RoleTable roleTable = Tables.ROLE.as("roleTable");
DSLContext context = Spring.getBean(DSLContext.class);
List<String> roles = context.select(roleTable.NAME).from(roleTable).innerJoin(pageRoleTable).on(roleTable.ROLE_ID.eq(pageRoleTable.ROLE_ID)).where(pageRoleTable.PAGE_ID.eq(pageId)).fetchInto(String.class);
Roles r = new Roles();
if (roles != null && !roles.isEmpty()) {
r.addAll(roles);
}
return hasAny(r);
} else {
return super.isInstantiationAuthorized(componentClass);
}
}
示例8: init
import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
@Override
protected void init() {
super.init();
getRequestCycleListeners().add(new AbstractRequestCycleListener() {
@Override
public void onBeginRequest(RequestCycle cycle) {
super.onBeginRequest(cycle);
if (cycle.getRequest() instanceof ServletWebRequest) {
ServletWebRequest req = (ServletWebRequest) cycle.getRequest();
AttributePrincipal principal = (AttributePrincipal) req.getContainerRequest().getUserPrincipal();
String user = req.getContainerRequest().getRemoteUser();
System.out.println("Principal: " + principal);
System.out.println("Attributes:");
for (Entry<String, Object> e : principal.getAttributes().entrySet()) {
System.out.println(e.getKey() + ":" + e.getValue() + "(" + e.getValue().getClass() + ")");
}
System.out.println("Principal Name: " + principal.getName());
System.out.println("Principal Class: " + principal.getClass());
System.out.println("Remote User: " + user);
}
}
});
}
示例9: onRequestHandlerScheduled
import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
@Override
public void onRequestHandlerScheduled(RequestCycle cycle, IRequestHandler handler) {
if (handler instanceof RenderPageRequestHandler) {
Class<? extends IRequestablePage> pageClass = ((RenderPageRequestHandler) handler).getPageClass();
if (REQUEST_LOGGER.isTraceEnabled()) {
REQUEST_LOGGER.trace("REQUEST CYCLE: Scheduled redirect to page {}", pageClass);
}
if (PageError.class.isAssignableFrom(pageClass)) {
REQUEST_LOGGER.info("REQUEST CYCLE: Scheduled redirect to error page {}", pageClass);
}
} else {
if (REQUEST_LOGGER.isTraceEnabled()) {
REQUEST_LOGGER.trace("REQUEST CYCLE: Scheduled request handler {}",
WebComponentUtil.debugHandler(handler));
}
}
super.onRequestHandlerScheduled(cycle, handler);
}
示例10: onConfigure
import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
@Override
protected void onConfigure() {
super.onConfigure();
ServletWebRequest req = (ServletWebRequest) RequestCycle.get().getRequest();
HttpServletRequest httpReq = req.getContainerRequest();
HttpSession httpSession = httpReq.getSession();
Exception ex = (Exception) httpSession.getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
if (ex == null) {
return;
}
String key = ex.getMessage() != null ? ex.getMessage() : "web.security.provider.unavailable";
error(getString(key));
httpSession.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
clearBreadcrumbs();
}
示例11: getBaseURL
import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
public static String getBaseURL() {
final RequestCycle requestCycle = RequestCycle.get();
final Request request = requestCycle.getRequest();
final String currentPath = request.getUrl().toString();
String fullUrl = requestCycle.getUrlRenderer().renderFullUrl(request.getUrl());
if (org.apache.commons.lang3.StringUtils.isNotBlank(currentPath)) {
final int beginPath = fullUrl.lastIndexOf(currentPath);
fullUrl = fullUrl.substring(0, beginPath - 1);
}
final Optional<String> contextPath = Optional.ofNullable(requestCycle.getRequest().getContextPath());
final Optional<String> filterPath = Optional.ofNullable(requestCycle.getRequest().getFilterPath());
return fullUrl + contextPath.orElse("") + filterPath.orElse("");
}
示例12: init
import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
/**
* @see org.apache.wicket.Application#init()
*/
@Override
public void init()
{
super.init();
// TODO STEP 7b: uncomment to enable injection of fortress spring beans:
getComponentInstantiationListeners().add(new SpringComponentInjector(this));
// Catch runtime exceptions this way:
getRequestCycleListeners().add( new AbstractRequestCycleListener()
{
@Override
public IRequestHandler onException( RequestCycle cycle, Exception e )
{
return new RenderPageRequestHandler( new PageProvider( new ErrorPage( e ) ) );
}
} );
getMarkupSettings().setStripWicketTags(true);
getRequestCycleSettings().setRenderStrategy( RequestCycleSettings.RenderStrategy.ONE_PASS_RENDER);
}
示例13: SSOLoginHOTPPage
import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
public SSOLoginHOTPPage() {
final SSOLoginData loginData = SSOUtils.getSsoLoginData(this);
if (loginData == null) {
RequestCycle.get().setResponsePage(new SSOLoginErrorPage(new Model<String>("No login data found")));
}
final LoginBean loginBean = new LoginBean();
Form<Void> form = new Form<Void>("form") {
@Override
protected void onSubmit() {
doOnSubmit(loginBean, loginData);
}
};
add(form);
form.add(new PasswordTextField("hotp", new PropertyModel<String>(loginBean, "hotp")));
errorMessageLabel = new Label("message", errorMessageModel);
errorMessageLabel.setVisible(StringUtils.hasLength(errorMessageModel.getObject()));
form.add(errorMessageLabel);
}
示例14: randomizeOncePerRequestCycle
import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
private void randomizeOncePerRequestCycle() {
if (lastRandomizedRequestCycle != RequestCycle.get()) {
lastRandomizedRequestCycle = RequestCycle.get();
Assertions.assertThat(lastRandomizedRequestCycle == RequestCycle.get())
.as("RequestCycle.get() always returns a different instance?!?")
.isTrue(); //sanity check
final List<ICarouselImage> imgs = new ArrayList<ICarouselImage>();
for (int i = 1; i <= 5; i++) {
final String path = "FrameworkSlogan_" + i + ".jpg";
final PackageResourceReference resource = new PackageResourceReference(getClass(), path);
final Url url = RequestCycle.get().mapUrlFor(resource, null);
imgs.add(new CarouselImage(url.toString()));
}
Collections.shuffle(imgs);
frameworkSloganImgs = imgs;
}
}
示例15: init
import org.apache.wicket.request.cycle.RequestCycle; //導入依賴的package包/類
/**
* @see org.apache.wicket.Application#init()
*/
@Override
public void init()
{
super.init();
// Enable injection of fortress spring beans:
getComponentInstantiationListeners().add(new SpringComponentInjector(this));
// Catch runtime exceptions this way:
getRequestCycleListeners().add( new AbstractRequestCycleListener()
{
@Override
public IRequestHandler onException( RequestCycle cycle, Exception e )
{
return new RenderPageRequestHandler( new PageProvider( new ErrorPage( e ) ) );
}
} );
getMarkupSettings().setStripWicketTags(true);
getRequestCycleSettings().setRenderStrategy( RequestCycleSettings.RenderStrategy.ONE_PASS_RENDER);
}