本文整理汇总了Java中org.apache.wicket.protocol.http.WebSession类的典型用法代码示例。如果您正苦于以下问题:Java WebSession类的具体用法?Java WebSession怎么用?Java WebSession使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebSession类属于org.apache.wicket.protocol.http包,在下文中一共展示了WebSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setClientCustomization
import org.apache.wicket.protocol.http.WebSession; //导入依赖的package包/类
public void setClientCustomization() {
MidPointPrincipal principal = SecurityUtils.getPrincipalUser();
if (principal == null) {
return;
}
//setting locale
setLocale(WebModelServiceUtils.getLocale());
LOGGER.debug("Using {} as locale", getLocale());
//set time zone
ClientProperties props = WebSession.get().getClientInfo().getProperties();
props.setTimeZone(WebModelServiceUtils.getTimezone());
LOGGER.debug("Using {} as time zone", props.getTimeZone());
}
示例2: parseDate
import org.apache.wicket.protocol.http.WebSession; //导入依赖的package包/类
/**
* Adapted from DateUtils to support Timezones, and parse ical dates into {@link java.util.Date}.
* Note: Replace FastDateFormat to java.time, when shifting to Java 8 or higher.
*
* @param str Date representation in String.
* @param patterns Patterns to parse the date against
* @param _timeZone Timezone of the Date.
* @return <code>java.util.Date</code> representation of string or
* <code>null</code> if the Date could not be parsed.
*/
public Date parseDate(String str, String[] patterns, TimeZone _timeZone) {
FastDateFormat parser;
Locale locale = WebSession.get().getLocale();
TimeZone timeZone = str.endsWith("Z") ? TimeZone.getTimeZone("UTC") : _timeZone;
ParsePosition pos = new ParsePosition(0);
for (String pattern : patterns) {
parser = FastDateFormat.getInstance(pattern, timeZone, locale);
pos.setIndex(0);
Date date = parser.parse(str, pos);
if (date != null && pos.getIndex() == str.length()) {
return date;
}
}
log.error("Unable to parse the date: " + str + " at " + -1);
return null;
}
示例3: ChangePasswordPage
import org.apache.wicket.protocol.http.WebSession; //导入依赖的package包/类
public ChangePasswordPage(PageParameters params) {
super(ListUsersPage.class, params);
add(new ChangePasswordPanel("change-password-panel") {
@Override
protected String getCurrentUserName() {
return SecurityUtils.getUsername();
}
@Override
protected void onPasswordChanged() {
getRequestCycle().setResponsePage(getApplication().getHomePage());
WebSession.get().invalidate();
SecurityContextHolder.clearContext();
}
});
}
示例4: renderHead
import org.apache.wicket.protocol.http.WebSession; //导入依赖的package包/类
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.render(CssHeaderItem.forReference(ResourceReference.BOOTSTRAP_CSS));
// response.render(CssHeaderItem.forReference(ResourceReference.BOOTSTRAP_TIMEPIKER_CSS));
// response.render(CssHeaderItem.forReference(ResourceReference.BOOTSTRAP_THEME_CSS));
response.render(JavaScriptHeaderItem.forReference(JQueryResourceReference.get()));
response.render(JavaScriptHeaderItem.forReference(ResourceReference.BOOTSTRAP_JS));
// response.render(JavaScriptHeaderItem.forReference(ResourceReference.BOOTSTRAP_TIMEPIKER_JS));
response.render(JavaScriptHeaderItem.forReference(ResourceReference.MOMENT_JS));
response.render(JavaScriptHeaderItem.forReference(ResourceReference.PIKADAY_JS));
response.render(CssHeaderItem.forReference(ResourceReference.PIKADAY_CSS));
WebSession session = (WebSession) getSession();
WebClientInfo webClientInfo = session.getClientInfo();
if (webClientInfo.getProperties().isBrowserInternetExplorer()) {
if (webClientInfo.getProperties().getBrowserVersionMajor() < 9) {
response.render(JavaScriptHeaderItem.forReference(ResourceReference.HTML5SHIV_JS));
response.render(JavaScriptHeaderItem.forReference(ResourceReference.RESPOND_JS));
}
}
}
示例5: setTimeZone
import org.apache.wicket.protocol.http.WebSession; //导入依赖的package包/类
protected void setTimeZone(PageBase page){
PrismObject<UserType> user = loadUserSelf();
String timeZone = null;
MidPointPrincipal principal = SecurityUtils.getPrincipalUser();
if (user != null && user.asObjectable().getTimezone() != null){
timeZone = user.asObjectable().getTimezone();
} else {
timeZone = principal.getAdminGuiConfiguration().getDefaultTimezone();
}
if (timeZone != null) {
WebSession.get().getClientInfo().getProperties().
setTimeZone(TimeZone.getTimeZone(timeZone));
}
}
示例6: AdvancedSearchOptionsPanel
import org.apache.wicket.protocol.http.WebSession; //导入依赖的package包/类
public AdvancedSearchOptionsPanel(String id, IModel<QueryFacetsSelection> model) {
super(id, model);
optionsForm = new Form("options");
final CheckBox selectionType = new CheckBox("selectionType", new Model(filterQuerySelectionType));
selectionType.add(new OnChangeAjaxBehavior(){
@Override
protected void onUpdate(AjaxRequestTarget target) {
filterQuerySelectionType = !filterQuerySelectionType;
WebSession.get().setAttribute(SELECTION_TYPE_ATTRIBUTE_NAME, filterQuerySelectionType);
}
});
optionsForm.add(selectionType);
final CheckBox fcsCheck = createFieldNotEmptyOption("fcs", FacetConstants.FIELD_SEARCH_SERVICE);
optionsForm.add(fcsCheck);
final MarkupContainer collectionsSection = new WebMarkupContainer("collectionsSection");
final CheckBox collectionCheck = createFieldNotEmptyOption("collection", FacetConstants.FIELD_HAS_PART_COUNT);
collectionsSection.add(collectionCheck);
collectionsSection.setVisible(config.isProcessHierarchies());
optionsForm.add(collectionsSection);
optionsForm.add(indicatorAppender);
add(optionsForm);
}
示例7: ensureApplication
import org.apache.wicket.protocol.http.WebSession; //导入依赖的package包/类
public static IApplication ensureApplication(Long langId) {
IApplication a = _ensureApplication();
if (ThreadContext.getRequestCycle() == null) {
ServletWebRequest req = new ServletWebRequest(new MockHttpServletRequest((Application)a, new MockHttpSession(a.getServletContext()), a.getServletContext()), "");
RequestCycleContext rctx = new RequestCycleContext(req, new MockWebResponse(), a.getRootRequestMapper(), a.getExceptionMapperProvider().get());
ThreadContext.setRequestCycle(new RequestCycle(rctx));
}
if (ThreadContext.getSession() == null) {
WebSession s = WebSession.get();
if (langId > 0) {
((IWebSession)s).setLanguage(langId);
}
}
return a;
}
示例8: setTimeZone
import org.apache.wicket.protocol.http.WebSession; //导入依赖的package包/类
protected void setTimeZone(PageBase page) {
PrismObject<UserType> user = loadUserSelf();
String timeZone = null;
MidPointPrincipal principal = SecurityUtils.getPrincipalUser();
if (user != null && user.asObjectable().getTimezone() != null) {
timeZone = user.asObjectable().getTimezone();
} else if (principal != null && principal.getAdminGuiConfiguration() != null) {
timeZone = principal.getAdminGuiConfiguration().getDefaultTimezone();
}
if (timeZone != null) {
WebSession.get().getClientInfo().getProperties().
setTimeZone(TimeZone.getTimeZone(timeZone));
}
}
示例9: put
import org.apache.wicket.protocol.http.WebSession; //导入依赖的package包/类
@Override
@Deprecated
/**
* When you are working with a generic web user interface based on Wicket,
* you should rather use the strongly typed session object concept of Wicket
* instead of putting name value pairs in the session with this function.
* However, if you like so, it still works :-)
*/
public void put(String key, Object value) {
WebSession.get().setAttribute(key, (Serializable) value);
}
示例10: get
import org.apache.wicket.protocol.http.WebSession; //导入依赖的package包/类
@Override
@Deprecated
/**
* When you are working with a generic web user interface based on Wicket,
* you should rather use the strongly typed session object concept of Wicket
* instead of fetching name value pairs from the session with this function.
* However, if you like so, it still works :-)
*/
public Object get(String key) {
return WebSession.get().getAttribute(key);
}
示例11: finishProcessing
import org.apache.wicket.protocol.http.WebSession; //导入依赖的package包/类
@Override
public void finishProcessing(AjaxRequestTarget target, OperationResult result, boolean returningFromAsync) {
if (previewRequested) {
finishPreviewProcessing(target, result);
return;
}
if (result.isSuccess() && getDelta() != null && getDelta().getOid().equals(SecurityUtils.getPrincipalUser().getOid())) {
UserType user = null;
if (getObjectWrapper().getObject().asObjectable() instanceof UserType){
user = (UserType) getObjectWrapper().getObject().asObjectable();
}
Session.get().setLocale(WebModelServiceUtils.getLocale(user));
LOGGER.debug("Using {} as locale", getLocale());
WebSession.get().getClientInfo().getProperties().
setTimeZone(WebModelServiceUtils.getTimezone(user));
LOGGER.debug("Using {} as time zone", WebSession.get().getClientInfo().getProperties().getTimeZone());
}
boolean focusAddAttempted = getDelta() != null && getDelta().isAdd();
boolean focusAddSucceeded = focusAddAttempted && StringUtils.isNotEmpty(getDelta().getOid());
// we don't want to allow resuming editing if a new focal object was created (on second 'save' there would be a conflict with itself)
// and also in case of partial errors, like those related to projections (many deltas would be already executed, and this could cause problems on second 'save').
boolean canContinueEditing = !focusAddSucceeded && result.isFatalError();
boolean canExitPage;
if (returningFromAsync) {
canExitPage = getProgressReporter().isAllSuccess(); // if there's at least a warning in the progress table, we would like to keep the table open
} else {
canExitPage = !canContinueEditing; // no point in staying on page if we cannot continue editing (in synchronous case i.e. no progress table present)
}
if (!isKeepDisplayingResults() && canExitPage) {
showResult(result);
redirectBack();
} else {
if (returningFromAsync) {
getProgressReporter().showBackButton(target);
getProgressReporter().hideAbortButton(target);
}
showResult(result);
target.add(getFeedbackPanel());
if (canContinueEditing) {
getProgressReporter().hideBackButton(target);
getProgressReporter().showContinueEditingButton(target);
}
}
}
示例12: getOmSession
import org.apache.wicket.protocol.http.WebSession; //导入依赖的package包/类
public static IWebSession getOmSession() {
return (IWebSession)WebSession.get();
}
示例13: Index
import org.apache.wicket.protocol.http.WebSession; //导入依赖的package包/类
public Index()
{
// Properties properties = (Properties) ((NeedServer) getApplication()).getServletContext().getAttribute(CoreController.PropertiesKey);
headerPanel = new HeaderPanel("headerPanel");
footerPanel = new FooterPanel("footerPanel");
sidePanel = new WebMarkupContainer("sidePanel");
add(new Label("nonPriviledgedMessage", "Everyone can see this"));
sidePanel.add(new Label("priviledged", "Only authenticated users can see this"));
// AllocateInterfaceOptionPanel reservePanel = new AllocateInterfaceOptionPanel("allocateInterfaceOptionPanel");
// sidePanel.add(reservePanel);
// ViewAllocatedPanel viewAllocatedPanel = new ViewAllocatedPanel("viewAllocatedPanel");
// sidePanel.add(viewAllocatedPanel);
// reservePanel.setVisible(getClientInformation().isAuthenticated());
// viewAllocatedPanel.setVisible(getClientInformation().isAuthenticated());
// sidePanel.setVisible(getClientInformation().isAuthenticated());
add(headerPanel);
add(footerPanel);
add(sidePanel);
boolean isAuthenticated = ((WicketClientInfo)WebSession.get().getClientInfo()).isAuthenticated();
sidePanel.setVisible(isAuthenticated);
// InterfaceData interfaceData = new InterfaceData("[1:{01}]", "1", "opendof");
// add(new InterfaceRequestForm("interfaceRequestForm", new CompoundPropertyModel<InterfaceData>(interfaceData)));
//
// add(new BookmarkablePageLink<>("browse", Browse.class));
//
// gcseDiv = new WebMarkupContainer("gcseDiv");
// String cx = properties.getProperty(NeedServer.GoogleCSEcxKey);
// StringBuilder sb = new StringBuilder();
// sb.append("<script>");
// sb.append("(function() {");
// // sb.append("var cx = '" + cx + "';");
// sb.append("var gcse = document.createElement('script');");
// sb.append("gcse.type = 'text/javascript';");
// sb.append("gcse.async = true;");
// sb.append("gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;");
// sb.append("var s = document.getElementsByTagName('script')[0];");
// sb.append("s.parentNode.insertBefore(gcse, s);");
// sb.append("})();");
// sb.append("</script>");
// sb.append("<gcse:search></gcse:search>");
// gcseLabel = new Label("gcseLabel", sb.toString());
// gcseLabel.setEscapeModelStrings(false);
// gcseDiv.add(gcseLabel);
// add(gcseDiv);
}
示例14: CrestAuthCallback
import org.apache.wicket.protocol.http.WebSession; //导入依赖的package包/类
public CrestAuthCallback(PageParameters parameters) throws Exception
{
super(parameters);
SessionClientInfo sessionClientInfo = (SessionClientInfo) WebSession.get().getClientInfo();
handleCallback(parameters, sessionClientInfo);
}
示例15: finishProcessing
import org.apache.wicket.protocol.http.WebSession; //导入依赖的package包/类
@Override
public void finishProcessing(AjaxRequestTarget target, OperationResult result, boolean returningFromAsync) {
if (previewRequested) {
finishPreviewProcessing(target, result);
return;
}
if (result.isSuccess() && getDelta() != null && getDelta().getOid().equals(SecurityUtils.getPrincipalUser().getOid())) {
UserType user = null;
if (getObjectWrapper().getObject().asObjectable() instanceof UserType){
user = (UserType) getObjectWrapper().getObject().asObjectable();
}
Session.get().setLocale(WebModelServiceUtils.getLocale(user));
LOGGER.debug("Using {} as locale", getLocale());
WebSession.get().getClientInfo().getProperties().
setTimeZone(WebModelServiceUtils.getTimezone(user));
LOGGER.debug("Using {} as time zone", WebSession.get().getClientInfo().getProperties().getTimeZone());
}
boolean focusAddAttempted = getDelta() != null && getDelta().isAdd();
boolean focusAddSucceeded = focusAddAttempted && StringUtils.isNotEmpty(getDelta().getOid());
// we don't want to allow resuming editing if a new focal object was created (on second 'save' there would be a conflict with itself)
// and also in case of partial errors, like those related to projections (many deltas would be already executed, and this could cause problems on second 'save').
boolean canContinueEditing = !focusAddSucceeded && result.isFatalError();
boolean canExitPage;
if (returningFromAsync) {
canExitPage = getProgressPanel().isAllSuccess(); // if there's at least a warning in the progress table, we would like to keep the table open
} else {
canExitPage = !canContinueEditing; // no point in staying on page if we cannot continue editing (in synchronous case i.e. no progress table present)
}
if (!isKeepDisplayingResults() && canExitPage) {
showResult(result);
redirectBack();
} else {
if (returningFromAsync) {
getProgressPanel().showBackButton(target);
getProgressPanel().hideAbortButton(target);
}
showResult(result);
target.add(getFeedbackPanel());
if (canContinueEditing) {
getProgressPanel().hideBackButton(target);
getProgressPanel().showContinueEditingButton(target);
}
}
}