• 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
[SOLVED] Getting a DIV's content and keeping page context
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SOLVED] Getting a DIV's content and keeping page context


  • Subject: [SOLVED] Getting a DIV's content and keeping page context
  • From: Yann Bizeul <email@hidden>
  • Date: Tue, 15 Aug 2006 20:10:57 +0200

As you can see, I perform a GET request on the AddressComponent directly, I think that is where I'm wrong, because doing this does get AddressComponent as the root component where it was a subcomponent before, the text field names are completely out of context once the DIV is reloaded.
The solution was quite simple, I just had to configure the "name" binding to a unique string in the form. WebObjects is no longer responsible of the field uniqueness, but every bindings still works.

Yann Bizeul • yann at tynsoe.org
Cocoa Developer

Le 15 août 06 à 19:33, Yann Bizeul a écrit :

I guess this is a traditionnal question about webobjects, but I did not find an answer in the archives and AJAX frameworks I found are poorly documented, since I am a beginner, I did not succeed to use them.

The problem is quite simple, I have a page containing :
- 1 WOPopUpButton with a list of 60+ countries
- 1 DIV containig WOTextFields with the address parts for the chosen country (City, state, Zip, etc...)


This div is a WOComponent (AddressComponent) I call in my page, with an "address" binding, according to the country set in the address, it diplays the different field for that country.
The reason why I'm doing this is that I want to avoid reloading the whole page, I want my site to be the very ergonomic, and I want to be able to dynamically reload DIV containins dynamic WO elements.


When the page is initially requested, it embed the AddressComponent, and everything works fine, I can submit the form and bindings are fully functionnal.

Then I change the country, the changeCountry method is called (see javascript attached at the end of the mail).

As you can see, I perform a GET request on the AddressComponent directly, I think that is where I'm wrong, because doing this does get AddressComponent as the root component where it was a subcomponent before, the text field names are completely out of context once the DIV is reloaded.

For example, this text field in the original page
<input size="15" type="text" name="7.6.1.4.0.CityComponent">

becomes :
<input size="15" type="text" name="1.4.0.CityComponent">

I hope things are a bit clearer and you will be able to help me :-)

<script type="text/javascript">
function changeAddressCountry(code)
{
http = getHTTPObject();
http.open("Get","<webobject name="ResourceURL1"></webobject>? countryCode=" + code,false);
http.send(null);
if (http.status==200) {
var div_handle = document.getElementById("address");
if(div_handle){
div_handle.innerHTML =''+http.responseText;
alert(http.responseText);
}
}
}


function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
</script>

_______________________________________________ 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: 
 >Getting a DIV's content and keeping page context (From: Yann Bizeul <email@hidden>)

  • Prev by Date: Getting a DIV's content and keeping page context
  • Next by Date: Re: WebObjects Foundation
  • Previous by thread: Getting a DIV's content and keeping page context
  • Next by thread: Re: Getting a DIV's content and keeping page context
  • Index(es):
    • Date
    • Thread