當前位置: 首頁>>代碼示例>>Java>>正文


Java SessionlessForm類代碼示例

本文整理匯總了Java中com.gitblit.wicket.SessionlessForm的典型用法代碼示例。如果您正苦於以下問題:Java SessionlessForm類的具體用法?Java SessionlessForm怎麽用?Java SessionlessForm使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SessionlessForm類屬於com.gitblit.wicket包,在下文中一共展示了SessionlessForm類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: LoginForm

import com.gitblit.wicket.SessionlessForm; //導入依賴的package包/類
public LoginForm(String id, String markupId, MarkupContainer markupProvider) {
	super(id, markupId, markupProvider);
	setRenderBodyOnly(true);

	SessionlessForm<Void> loginForm = new SessionlessForm<Void>("loginForm", RootPage.this.getClass(), getPageParameters()) {

		private static final long serialVersionUID = 1L;

		@Override
		public void onSubmit() {
			String username = RootPage.this.username.getObject();
			char[] password = RootPage.this.password.getObject().toCharArray();

			HttpServletRequest request = ((WebRequest) RequestCycle.get().getRequest()).getHttpServletRequest();

			UserModel user = app().authentication().authenticate(username, password, request.getRemoteAddr());
			if (user == null) {
				error(getString("gb.invalidUsernameOrPassword"));
			} else if (user.username.equals(Constants.FEDERATION_USER)) {
				// disallow the federation user from logging in via the
				// web ui
				error(getString("gb.invalidUsernameOrPassword"));
				user = null;
			} else {
				loginUser(user);
			}
		}
	};
	TextField<String> unameField = new TextField<String>("username", username);
	WicketUtils.setInputPlaceholder(unameField, markupProvider.getString("gb.username"));
	loginForm.add(unameField);
	NonTrimmedPasswordTextField pwField = new NonTrimmedPasswordTextField("password", password);
	WicketUtils.setInputPlaceholder(pwField, markupProvider.getString("gb.password"));
	loginForm.add(pwField);
	add(loginForm);
}
 
開發者ID:tomaswolf,項目名稱:gerrit-gitblit-plugin,代碼行數:37,代碼來源:RootPage.java

示例2: LoginForm

import com.gitblit.wicket.SessionlessForm; //導入依賴的package包/類
public LoginForm(String id, String markupId, MarkupContainer markupProvider) {
	super(id, markupId, markupProvider);
	setRenderBodyOnly(true);

	SessionlessForm<Void> loginForm = new SessionlessForm<Void>("loginForm", RootPage.this.getClass(), getPageParameters()) {

		private static final long serialVersionUID = 1L;

		@Override
		public void onSubmit() {
			String username = RootPage.this.username.getObject();
			char[] password = RootPage.this.password.getObject().toCharArray();

			UserModel user = GitBlit.self().authenticate(username, password);
			if (user == null) {
				error(getString("gb.invalidUsernameOrPassword"));
			} else if (user.username.equals(Constants.FEDERATION_USER)) {
				// disallow the federation user from logging in via the
				// web ui
				error(getString("gb.invalidUsernameOrPassword"));
				user = null;
			} else {
				loginUser(user);
			}
		}
	};
	TextField<String> unameField = new TextField<String>("username", username);
	WicketUtils.setInputPlaceholder(unameField, markupProvider.getString("gb.username"));
	loginForm.add(unameField);
	PasswordTextField pwField = new PasswordTextField("password", password);
	WicketUtils.setInputPlaceholder(pwField, markupProvider.getString("gb.password"));
	loginForm.add(pwField);
	add(loginForm);
}
 
開發者ID:warpfork,項目名稱:gitblit,代碼行數:35,代碼來源:RootPage.java


注:本文中的com.gitblit.wicket.SessionlessForm類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。