AJAX - Validation and obtaining component's generated HTML
AJAX - Validation and obtaining component's generated HTML
- Subject: AJAX - Validation and obtaining component's generated HTML
- From: Miguel Arroz <email@hidden>
- Date: Fri, 10 Feb 2006 14:42:00 +0000
Hi!
I have been playing with AJAX lately (thanks to the Jean Francois
Veillette's great JSON bridge for WO!) and I found out three
problems. I would like to share them with you, and know how you solve
this in an elegant way.
I have a component with a subcomponent, that is replaced, via
AJAX, with other subcomponents, during a wizard-like process. The
first problem is closely related to this - I need to obtain the HTML
code of the new subcomponent so that I can replace the old code with
the new one on the page DOM. I found out that this works:
SomeComponent resultPage = (SomeComponent) pageWithName
("SomeComponent");
// call resultPage setters here, so that the component may render
itself with the content I want
resultPage.appendToResponse(context().response(), context());
return context().response().contentString();
Is this the best way to achieve this? If not, what's the best way
of obtaining the component's generated HTML code?
The second problem is validation. When I do an AJAX request, there
is no RR cycle. There is not even a request, and all the values in
forms must be extracted in the JavaScript code and sent as arguments
of the AJAX RPC function. In these conditions, the
takeValuesFromRequest validation phase does not exist. So, I must do
something that acts like it, and, even better, calls the
validationFailedWithException method in the component so that my
previous validation stuff works seamlessly.
I still did not implement this (so I don't have a code snippet
yet) but I thought about creating some WOAssociations, putting them
on a list, and handling them to a method that would validate the
values (using validateValueForKey) and call the
validationFailedWithException method when catching an exception.
Still, I don't see how to automatically generate the WOAssociation
list. I could do it manually, but... :/
The third problem is hyperlinks. If I put an hyperlink that links
to a pageWithName, when I click I will see the "you backtracked too
far" message, not because I have really backtracked too far, but
because the response that generated that component is NOT on the
backtrack list (it's an AJAX request). The solution I'm using is
linking to a direct action. It apparently works (WO passes the
WOSession ID on the URL). Together with some secutiry (ie, handling
what happens in the Direct Action when there is no wosession id on
the URL), is there something that I sould worry about when doing
this? Or will WO do it's magic, and everything just works? It appears
to do so, but it might be just a happy coincidence! :)
Yours
Miguel Arroz
"GUERRA E' PAZ
LIBERDADE E' ESCRAVIDAO
IGNORANCIA E' FORCA" -- 1984
Miguel Arroz
http://www.ipragma.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden