On Tue, 04 May 2010 07:12:28 -0300, Genís Pujol <gpu...@ngeografics.com>
wrote:

Hello list,

Hi!

I have a doubt on using other ajax libs, not the ones bundled with tapestry5 (so I'm not using tags on the templates but xhr calls to json data instead).

When not using Tapestry's components, you'll have to write all the
JavaScript. On the server part, you'll inject Request to get query
parameters (regardless of GET or POST). For a very good introduction
of using JavaScript and Tapestry 5, read
http://wiki.apache.org/tapestry/Tapestry5AndJavaScriptExplained
and http://tapestry.apache.org/tapestry5.1/guide/ajax.html.

My doubts:

-how can I tell the bean that processes the post request that is updating an instance and not creating a new one?

I'm not following you. Anyway, you would inject ComponentResources and
use its createEventLink() method to define an event and pass this URL
(the returned Link.toString() to your JavaScript code. You'll need
to create a method to handle that event. It will return a JSONObject
or JSONArray to send data to the client. In the JavaScript side,
you would make an AJAX call to the event's URL.

In a nutshell, that's how AJAX work in Tapestry.

-how does the beaneditform handle the request?

Are you using BeanEditForm or not? You told us you're not using any Tapestry components.
BeanEditForm handles requests just like
Form. When doing an AJAX submission, they takes care of all the AJAX part.
They follows these steps:

1) Triggers the form field components validations.
2) Form field components apply the values to the edited properties.
3) The validateForm event is triggered for cross-field validations.
4) If the validation is successfull, the success event is triggered.
Otherwise, the failure event is triggered.
5) The submit event is triggered.

-how does it know wether to create or update an object?

If the object parameter is null, it updates. If not, it creates a new one.

Apparently with the default ajax libs it does that automagically ;)

The default AJAX lib doesn't process form submissions, just trigger them
and then update the page.

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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

Reply via email to