• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AJAX - Validation and obtaining component's generated HTML
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AJAX - Validation and obtaining component's generated HTML


  • Subject: Re: AJAX - Validation and obtaining component's generated HTML
  • From: Jean-François Veillette <email@hidden>
  • Date: Fri, 10 Feb 2006 10:28:46 -0500


Le 06-02-10, à 09:42, Miguel Arroz a écrit :

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?

Look at generateResponse() instead.

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... :/

Not sure, I guess it will mostly depend on how the validation is implemented already. Is it on the component ? Is it on the business model ? Anyway, I have not yet faced this problem, I have nothing to say really.


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! :)

DA will work, and might be your only option.

The problem with hyperlink and form's elements is the context and elements id. Context id have to match with your page cache. Element id have to match your regenerated page. If you can generate a subcomponent that make both ok, then great !
That's why DA works (doesn't need context id).


- jfv


http://www.freeiPods.com/?r=21419063 _______________________________________________ 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
References: 
 >AJAX - Validation and obtaining component's generated HTML (From: Miguel Arroz <email@hidden>)

  • Prev by Date: Re: Newbie Key Value-coding and Subclasses Question
  • Next by Date: Re: Some help with Optimization
  • Previous by thread: AJAX - Validation and obtaining component's generated HTML
  • Next by thread: EOGenerator & Inheritance
  • Index(es):
    • Date
    • Thread