To follow the struts2 jquery ajax validation
and target
concept, I used below solution:
The login-form.jsp (no target is set):
<s:form id="loginForm" action="login-process-result" namespace="/security" >
<sj:submit button="true"
validateFunction="formValidator" validate="true" key="form.btn.login />
</s:form>
The action (with validations)
@Action(value = "login-process-result")
@Validations(requiredStrings={
@RequiredStringValidator(fieldName="userID",key="validate.required"),
@RequiredStringValidator(fieldName="password",key="validate.required")} )
public String result() throws ClientException{
//Authentication login goes here
return SUCCESS;
}
And finally the result form which do the trick, is a normal jsp which changes the window location via javascript
The page shows an success message and make an small delay before changing the url, which is optional and can be removed.
<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
You have logged in successfully ....
<br/>
<img src="images/loggin-in-progress.gif" />
<s:url var="url" action="private-page" namespace="/"/>
<script type="text/javascript">
function reload() {
window.location.href = "${url}";
}
$(document).ready(function() {
setTimeout('reload()', 800);
});
</script>