I deliberately did not answer Yann's question about the DIV, even though what he does would be pretty trivial with the Ajax framework just because I wanted to see if anyone would take a heart and does it for me. No, not you Mike! Anyone who has at least some understanding of WO and has looked at the Ajax example should be able to explain to him.

And this person(s) is also more than welcome to write up some better comments for the Ajax example explaining a bit more in-depth what is going on and why.

Cheers, Anjo

Am 15.08.2006 um 19:33 schrieb Yann Bizeul:

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;
  /[EMAIL PROTECTED]
  @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>


Le 15 août 06 à 07:44, John Bruce a écrit :

Can you let me know what the javascript is trying to do? Is it to edit
the address in the particular format for that country?

Depending on what you are trying to do it may be better to not use
Javascript - either way it might be best to get it working using
normal wo actions and then try to do it with javascript.

-John

On 8/15/06, Yann Bizeul <[EMAIL PROTECTED]> wrote:
Thanks to Miguel and John for their usefull answers.

The result is I make a big red cross to my idee to programmatically
generate components :-)

Using WOSwitchComponent, I'm almost successfull implementing exactly
what I want, but I have a problem with the dynamic part of the code
(the javascript that realods a DIC content).

When my page is loaded, the components hierarchy is a full page with
my header, the global component, my address component, each field in
it, etc...

But when I use Javascript to get a new form for the new address
format, it is completely out of the context, and for example, my City text field that look like this in the code with the original request :

<input size="15" type="text" name="7.6.1.4.0.CityComponent">

Become that after the DIV update :
<input size="15" type="text" name="1.4.0.CityComponent">

As you can see, since the root component is itself, the identifiers
are wrong.

How can I deal with that ?


Yann Bizeul • yann at tynsoe.org
Cocoa Developer

Tynsoe Projects
BuddyPop • GeekTool • SSH Tunnel Manager • ...
http://projects.tynsoe.org/


_______________________________________________
WebObjects-dev mailing list
[EMAIL PROTECTED]
http://www.omnigroup.com/mailman/listinfo/webobjects-dev




Yann Bizeul • yann at tynsoe.org
Cocoa Developer

Tynsoe Projects
BuddyPop • GeekTool • SSH Tunnel Manager • ...
http://projects.tynsoe.org/


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/krank% 40logicunited.com

This email sent to [EMAIL PROTECTED]

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com

Reply via email to