0

I'm making a Design Studio custom component in Eclipse. I created a property 'backgroundColor' in my contribution.xml file. I can call this xml file inside my javascript and adjust it locally, but is there a way I can upload these changes to the server xml file again? Cause at the moment my alerts return all the new data but on the server side nothing happens.

Code that i have:

Contribution.xml:

<property
        id="backgroundColor"
        title="BackgroundColor"
        type="Color"
        group="Display"
        visible="true"
        bindable="true"/>

component.js:

var xhttp = new XMLHttpRequest();
                xhttp.onreadystatechange = function() {
                    if (this.readyState == 4 && this.status == 200) {
                        myFunction(this);
                    }
                };
                xhttp.open("GET", "serverpath/contribution.xml", true);
                xhttp.send();

                function myFunction(xml) {

                    xml.responseXML.getElementsByTagName('property')[0].setAttribute("visible",false);
                    //this returns BackgroundColor so the call does work
                    alert(xml.responseXML.getElementsByTagName('property')[0].getAttribute("title"));

                }
mrdeadsven
  • 744
  • 1
  • 9
  • 22

1 Answers1

1

You will need to make some server side coding to do that. You could achieve that by making simple rest api. But otherwise without any server side coding you cant do that. You are now getting data with GET request to server which means you cant do any modifications, you simply get any server response data.

  • Do you have any example of an api to overwrite a xml document? Sorry i'm new to this all, and have only used and api to insert sql to a database ever before. – mrdeadsven Aug 29 '17 at 10:25
  • It depends in what language you are working on the server side. It could be PHP or JavaEE or any other server sided language. – František Jeřábek Aug 29 '17 at 11:14
  • I can decide this myself at the moment I don't have an api at the server for this so one in php would be nice for an example since my sql one was in php – mrdeadsven Aug 29 '17 at 11:35
  • Take a look at this https://stackoverflow.com/questions/4684075/how-to-build-a-restful-api it might help you. Also this might help you https://stackoverflow.com/questions/1768894/how-to-write-into-a-file-in-php – František Jeřábek Aug 29 '17 at 12:17