Hi All
I'm trying to submit a form then do a callback to a javascript function, but
the form appears to be submitted twice.
The tapestry form is for login and has a couple of textfields with a
t:submit button
<t:submit class="submit" t:id="login_submit" t:value="Login" />
Abridged Java class
@Mixins("t5components/OnEvent")
@Component(id = "loginForm", parameters={"event=submit",
"onCompleteCallback=completeLogin"})
@Persist
private Form loginForm;
public JSONObject onSubmitFromLoginForm() {
System.out.println("\n\n----logging in member ");
JSONObject json = new JSONObject();
String isLoginSuccessful = "false";
LoginDto login = new LoginDto();
login.setUserName(getUserName());
login.setPassword(getPassword());
try {
System.out.println("----logging in member " +
login.getUserName());
loginService.login(login);
securityToken = login.getSecurityToken();
isLoginSuccessful = "true";
} catch (ServiceFaultException e) {
json.put("message", "Login details are incorrect");
}
System.out.println("----login is successful " + isLoginSuccessful);
json.put("isLoginSuccessful", isLoginSuccessful);
return json;
}
----------------------------
The javascript function gets called, but is always passed false for
isLoginSuccessful. When I submit the form (with testuser and password for
the input) I get the following output:
----logging in member
----logging in member null
[DEBUG] HydraService ---------------------------- logging in member in
service
----login is successful false
127.0.0.1 - - [07/May/2008:15:24:50 +0000] "POST
/home.landingpage.loginwidget.loginform:submit HTTP/1.1" 200 69 "-"
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404
Firefox/2.0.0.14"
----logging in member
----logging in member testuser
[DEBUG] HydraService ---------------------------- logging in member in
service
*******creating token********
----login is successful true
127.0.0.1 - - [07/May/2008:15:24:50 +0000] "POST
/home.landingpage.loginwidget.loginform HTTP/1.1" 200 30 "-" "Mozilla/5.0
(Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404
Firefox/2.0.0.14"
This is the javascript:
function completeLogin(response){
var json = response.evalJSON();
alert(json.isLoginSuccessful);
if (json != null && json.isLoginSuccessful.toString() == 'true') {
gotoHomePage();
}else{
showLoginError();
}
}
Does anyone have any ideas why this is submitting twice. The first time
doesn't appear to be a proper submit as none of the form fields are being
passed through.
Any help would be greatly appreciated!
--
View this message in context:
http://www.nabble.com/Problem-with-form-submission-with-callback-tp17106416p17106416.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]