本文整理匯總了Java中org.apache.tapestry5.EventConstants類的典型用法代碼示例。如果您正苦於以下問題:Java EventConstants類的具體用法?Java EventConstants怎麽用?Java EventConstants使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EventConstants類屬於org.apache.tapestry5包,在下文中一共展示了EventConstants類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: validation
import org.apache.tapestry5.EventConstants; //導入依賴的package包/類
@Log
@OnEvent(value = EventConstants.VALIDATE, component = "loginForm")
public void validation()
{
if (!loginForm.isValid()) {
return;
}
//LOG.debug("onValidateLoginForm [" + username + "] ");
try {
Subject subject = SecurityUtils.getSubject();
if (!subject.isAuthenticated()) {
// http://shiro.apache.org/static/1.2.2/apidocs/org/apache/shiro/authc/UsernamePasswordToken.html
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
//token.setRememberMe(rememberMe);
subject.login(token);
token.clear();
LOG.debug("User [" + subject.getPrincipal() + "] logged in successfully.");
} else {
LOG.debug("User [" + subject.getPrincipal() + "] failed to log.");
}
} catch (Exception e) {
loginForm.recordError("Error " + e.getMessage());
}
}
示例2: submit
import org.apache.tapestry5.EventConstants; //導入依賴的package包/類
@OnEvent(EventConstants.SUCCESS)
public Object submit() {
Subject currentUser = securityService.getSubject();
if (currentUser == null) {
throw new IllegalStateException("Subject can`t be null");
}
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
try {
currentUser.login(token);
} catch (Exception e) {
alertManager.error("Authentication Error");
return null;
}
return "Index";
}
示例3: loggingSuccess
import org.apache.tapestry5.EventConstants; //導入依賴的package包/類
@Log
@OnEvent(value = EventConstants.SUCCESS, component = "loginForm")
public void loggingSuccess()
{
String successPage = loginContextService.getSuccessPage();
try{
loginContextService.redirectToSavedRequest(successPage);
}
catch (IOException e) {
e.printStackTrace();
}
}