Re: Multiple Submits and Ajax Form

2012-06-11 Thread afaque_khan_2...@yahoo.com
Thanks for the response.
I tried what you described. The functionality works. But, even though the
event handler function of the submit button bookTrade returns other some
page, I have an impression that it is an ajax form submit. This is because
on using the object  Request defined in the java file, i see that the
.isXHR() returns always true.

What I want is that the bookTrade button should submit the page normally,
and there should not be any ajax animations.

--
Page in TML
--
div t:type=zone t:id=formZone
form class=creationForm t:zone=formZone t:type=form
t:id=orderClaculateValue method=postt:errors /
input t:type=textfield t:id=price t:value=price/
input t:type=textfield t:id=quantity t:value=quantity /
input t:type=textfield t:id=amount t:value=amount t:size=5/
input t:type=textfield t:id=counterparty t:value=counterparty /
.
.
input t:type=Submit t:id=calculate value=Calculate/
.
.
input t:id=bookTrade value=Finalise t:type=submit/

/form
/div

.java

@InjectPage
private OrderFinalise orderFinalisePage;

@Component
private Submit calculate;

@Component
private Submit bookTrade;

@Component(id=formZone)
private Zone formZone;

@Inject
private Request request;

void onSelectedFromBookTrade() {

formEventReturn = orderFinalisePage; // go to AnotherPage
}

void onSelectedFromCalculate() {

amount = quantity * price;
formEventReturn = formZone.getBody(); // stay on this page
}

Object onSuccessFromOrderClaculateValue() {
   
//if(request.isXHR())
//{
//   return formZone.getBody(); // AJAX request, return zone body
//}
//else
//{
//  return orderFinalisePage; // non-AJAX request, redraw current 
page
//}
  
   return formEventReturn;  
}

--

--


--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Multiple-Submits-and-Ajax-Form-tp5713699p5713767.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Multiple Submits and Ajax Form

2012-06-11 Thread Thiago H de Paula Figueiredo
On Mon, 11 Jun 2012 11:30:04 -0300, afaque_khan_2...@yahoo.com  
afaque_khan_2...@yahoo.com wrote:



I tried what you described. The functionality works. But, even though the
event handler function of the submit button bookTrade returns other  
some page, I have an impression that it is an ajax form submit. This is  
because on using the object  Request defined in the java file, i see  
that the

.isXHR() returns always true.


AJAX and non-AJAX requests (form submissions included) are the same  
(except for an HTTP header), so you don't have to worry about isXHR()  
unless you want to check before returning an AJAX response.  
Request.isXHR() just checks the presence of this HTTP header and Tapestry  
itself just uses it to prevent you from returning an AJAX response to a  
non-AJAX request. The opposite is *not* valid. The difference between AJAX  
and non-AJAX requests is the response. This is true in general, not just  
with Tapestry.


Summary: you're worrying for something you shouldn't.

--
Thiago H. de Paula Figueiredo

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Multiple Submits and Ajax Form

2012-06-07 Thread Thiago H de Paula Figueiredo
On Thu, 07 Jun 2012 09:00:54 -0300, afaque_khan_2...@yahoo.com  
afaque_khan_2...@yahoo.com wrote:



Hi,


Hi!


In short i want to do a normal submit to an ajax form.


There's no such thing as an AJAX form in Tapestry. There are AJAX form  
submissions and non-AJAX form submissions. To force a non-AJAX form  
submission, in your even handler method, just return some value which  
isn't an AJAX response one (JSONObject, JSONArray, Zone, Block), returning  
null or a page instance or a page class instance instead.


--
Thiago H. de Paula Figueiredo

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org