Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Newbee question

    Ok.. I am starting to play around with developing using Smart Client and I am have ran into some basic issues that hopeful someone can help.

    The first issues I am running into is that I am trying to create a quick and dirty component to embed a virtual earth component. In a previous thread someone pointed me to a google example and it appears to make sense.

    I then want to Add this component to a a layout. HLayout, SectionStack etc. These components are defined in XML while my VEControl is defined in JS. Question is.. How do I access a Component that has been defined through the XML configuration in JS. Also, if I want to put some JS logic in the XML file how do I go about doing it.

    #2
    The XML definition is translated to JavaScript before it is run, so it works the same. See Component XML for more info.

    Comment


      #3
      Yes I found the <JS> tag after I wrote this post..

      In terms of access a component.. How does one get the handle to the object per say. I see where getElementById would not work. Is there an equivalent API in the framework to accomplish the same thing or am I missing something basic here.

      Comment


        #4
        Hi WeeJavaDude,

        You generally don't directly access the DOM elements writen out by SmartClient Components - SmartClient components have APIs to handle rendering their handles out as HTML into the DOM, and manipulating those elements (draw / clear / show / hide / change size / color etc etc).

        There are various reasons for us to do it this way. For example, by insulating developers from the generated HTML, we can handle writing out HTML that gives a consistent appearance to widgets across browsers / platforms / doctype, etc - the actual HTML we generate may (and frequently does) vary by platform.

        In your case (if I understand you correctly) you have a set of components defined in XML and you're trying to access them (write other widgets into them as children, perhaps)
        At runtime the components which were originally defined in XML will be available as javascript objects - and you can access them in the global scope using their IDs, so if you wanted to add a new child to a component with the ID "myCanvas" you can simply call something like
        Code:
        myCanvas.addChild(isc.Canvas.create({backgroundColor:"yellow", ID:"foo"}));
        I hope this helps. If I'm missing your use case, please feel free to post and explain what you're trying to do and we can point you in the right direction.

        Thanks
        Isomorphic Software

        Comment


          #5
          Hello Isomorphic,

          How do we access isomorphic elements in a way similar to how we access html elements using document.getElementById('id') by just providing the id.

          We have a requirement where the server will send only the element id as string which we retrieve in call back function, now how do i get the actual element using this id.

          for eg:
          i created a button
          Code:
          isc.IButton.create({title:"Remove", autoDraw:false, ID:"IButtonId"})
          and now i get "IButtonId" from server side as a string value, how do i get access to the button element.

          Similarly i may have to access a following element:
          1. Text/Select inside a dynamic or search form
          2. tab under a tabset
          3. Section under section stack.
          How do i get access to these elements with only their ids.

          Comment


            #6
            To get an element by ID is just isc.Canvas.getById(ID). However two comments:

            1. a Canvas ID is not a DOM ID. It's a global ID for a JavaScript object that exists independent of the DOM, can create a DOM representation (draw()) and wipe it out (clear()) without affecting it's state.

            2. this question is a big red flag for using the wrong architecture. The server should not know component IDs - the server should consist only of a set of secure, reusable data services. Your team would probably benefit from the Jump Start program as it sounds like you are headed down a path where you will make everything 10 times harder for yourselves.

            Comment


              #7
              Hi,

              I got the control for a element by passing the id to isc.Canvas.getById() for some of the controls on the page.
              For some controls this API returns null, what may be the reason for this.
              For eg:
              I have a checkbox item with a ID: 'checkBoxItem_12' and if i use isc.Canvas.getById('checkBoxItem_12') this returns me null.

              Question 1 : Is there a restriction for form items to be accessed by getById();

              Question 2 : The controls that are not yet displayed for first time cannot be accessed by isc.Canvas.getById() ??

              I have a tabset where every tab may have another tabset under it and so on upto 3-4 levels.
              Won't I be able to access a tab in 3 or 4 level in hierarchy on page load if i have the id for the tab?
              Last edited by ypoovil; 5 Jan 2010, 02:55.

              Comment


                #8
                All Canvases are always accessible by their ID regardless of whether they've been draw()n or not. The same is true of FormItems, but you may be confused because a FormItem can have a "name", which is not required to be globally unique and is used with dynamicForm.getItem(), not Canvas.getById().

                Comment


                  #9
                  Hello,
                  Thanks for the quick response

                  But i had used id for a form item and isc.Canvas.getById('id') returned me null. :(

                  Also i had a tabset where in under one tab i had another tabset and in one of the tabs of child tabset i had another tabset. Like i had 3 levels for a tabset. and i did the following things:
                  On page load event, I got a tab element of the 3rd level tab setby its id using isc.Canvas.getById('tabid') and this returned me null.
                  and i did the same thing when i clicked each tabs and went to the 3rd level tabset and had button in there on click of which i followed the same steps and this time isc.Canvas.getById('tabid') did return the tab id.

                  What did went wrong here ?

                  Comment


                    #10
                    Sorry, to clarify, Canvas.getById() returns a Canvas and a FormItem is not a Canvas. However the FormItem is still available globally by it's ID because both Canvas and FormItems with IDs create JavaScript globals. Hence normal JavaScript syntax for accessing global variables applies; window.globalId or window["globalId"].

                    Comment


                      #11
                      I want to get the object of SelectItem control from its attribute $89 = "isc_SelectItem_113" to select the value dynamically. This attribute value is generating dynamically. I tried with canvas.getbyid but return null. Also it is not coming in the Formitem.getelement('isc_SelectItem_113). Can you please suggest how can we get the object of this selectitem through javascript? I am able to get the object of button control using isc.IButton.getByID().

                      Comment


                        #12
                        If you give a FormItem an ID it is available via just "window.theID" in JavaScript, as was already covered above.

                        However note that your code should not rely on auto-generated IDs like the isc_SelectItem_113 you mention above. These can end up changing depending on the order in which you create components.

                        Comment

                        Working...
                        X