Reg  : Accessing dynamically created attribute

Hi All,
         I had created a dynamic node ("demo") and added two attributes ("appid" & "apptext") to it. And also i created three elements for that node and binded the values. Now my dynamic node is having 3 records. I am creating link to action dynamically and binded a action called "onClick". Now in the output i am getting
linktoaction1
linktoaction2
linktoaction3
Now i am stuck with, when i am clicking either of these 3 linktoactions in runtime, i am able to get only the first record. May i know how to traverse through the node. i.e on clicking of linktoaction2 i want to fetch second records of the node and simillarly and linktoaction1 and linktoaction2. I used the following code in "onClick"
IWDNode dynnode = wdContext.currentContextElement().node().getChildNode      ("demo",IWDNode.LEAD_SELECTION);
IWDNodeElement ele = dynnode.getCurrentElement();
String text = (String)ele.getAttributeValue("Apptext");
wdComponentAPI.getMessageManager().reportSuccess(text);
Thanks,
Mugundhan.

Hi Nikil,
Ya i had assigned only one action for the three linktoactions. I am filling my dynamic node according to the number of records coming from the RFC. How can i pass the index value (i.e) how to identify that which action is being clicked. I am little confused. Thia is what i wrote in my coding,
In Init method,
IWDNodeInfo nodeInfo=wdContext.getNodeInfo().addChild("demo", null,true,true,
true,false,false,true,null,null,null);
nodeInfo.addAttribute("Applid", "com.sap.dictionary.string");
nodeInfo.addAttribute("Apptext", "com.sap.dictionary.string");
IWDNode node = wdContext.wdGetAPI().getRootNode().getChildNode("demo",IWDNode.NO_SELECTION);
  for(int i=0; i<wdContext.nodeEt_Mobileportal().size();i++)
     IWDNodeElement nodeElem = node.createElement();
     nodeElem.setAttributeValue("Applid", wdContext.nodeEt_data().getEt_dataElementAt(i).getApplid());
     nodeElem.setAttributeValue("Apptext", wdContext.nodeEt_data().getEt_dataElementAt(i).getApptext());
     node.addElement(nodeElem);
In domodify method,
    if(firstTime)
       IWDTransparentContainer cont= (IWDTransparentContainer)view.getElement("menu");          
       for( int i=0; i<wdContext.nodeEt_Mobileportal().size(); i++)
       IWDLinkToAction link  = (IWDLinkToAction)view.createElement(IWDLinkToAction.class,"link"+i);
              link.setText(wdContext.nodeEt_Mobileportal().getEt_MobileportalElementAt(i).getApptext());
       link.setOnAction(wdThis.wdGetGotoappAction());                    
       cont.addChild(link);
Thanks,
Mugundhan

Similar Messages

  • How to access a dynamic created attribute in a context node?

    <i>Hello,</i>
    <i>who could help? I can't set a value for a dynamically created attribute which is bind to a table.</i>
    <i>My context of the view looks as follow (is defined in NetWeaver):</i>
      - Context
         - Availability (Node)
             - vctxService (Attribute)
             - vctxServiceDesc (Attribute)
             - ... (further predefined attributes)
             - ... (some have to be set dynamically as follows)
    <i>Then I have added attributes dynamically in the wdDoModifyView(...) - method, as follows:</i>
    for (int i = 0; i < max; i++) {
       // some code to dynamically create table columns
       // adding attributes dynamically
       IWDAttributeInfo attrInfo =       wdContext.nodeAvailability().getNodeInfo().      addAttribute("vctxAvailability_" + i, "ddic:com.sap.dictionary.string");
       tv.bindText(attrInfo); // bind to TextView in table
    <i>In the method onPlugFrom... I tried to set the values for the attributes "vctxAvailability_ + i" as follows:</i>
    for (int i = 0; i < max; i++) {
       IAvailabilityElement newAvailNodeElement =     wdContext.createAvailabilityElement();
       // some values will be set for the
       // predefined attributes of AvailabilityNode
       // newAvailNodeElement.set...( value );
       // newAvailNodeElement.setVctxService( xy.getServ() );
       // now the values of dynamically created and added
       // attributes in AvailabilityNode will be added
       // THIS DOESN'T WORK
       newAvailNodeElement.setAttributeValue    ("vctxAvailability_" + i, "value" + i);
    <i>It would be great if someone could help me.
    Thanks in advance.
    Kind regards,
    Carsten</i>

    Carsten,
    Here is a sample code that creates context attributes dynamically and also sets values:
    //Creates a node
    IWDNodeInfo nodeInfo = wdContext.wdGetAPI().getRootNodeInfo().addChild("TestNode", null, true, true, false, true, false, true, null, null, null);
    //If you want to bind the node to a model node then the
    //second argument to the above method should be the
    //model class.
    //Creates an attribute under the node just created.
    IWDAttributeInfo testAttrib = wdContext.wdGetAPI().getRootNodeInfo().getChild("TestNode").addAttribute("testAttrib", "ddic:com.sap.dictionary.string");
    IWDNodeElement testNode = wdContext.getChildNode("TestNode", IWDNode.LEAD_SELECTION).getCurrentElement();
    IWDNode testNode2 = wdContext.getChildNode("TestNode", IWDNode.LEAD_SELECTION);
    //Now you can bind testNode with the Model Node
    //You can also set a value to the newly created attribute
    testNode.setAttributeValue("testAttrib", new String("Value"));
    Hope this helps.
    Shakeel

  • Accessing Dynamically created Button

    Hi,
    Can someone give me an example how to access dynamically created button? 
    I know how to create a button dynamically but don't know how to access from AS3.
    Thanks!

    Hi,
    Please go through following links.
    1) http://www.daveoncode.com/2009/05/20/objectcollector-accessing-dynamic-generated-flex-obje cts-by-id/
    2) http://stackoverflow.com/questions/6740813/flex-assigning-events-to-dynamically-created-bu ttons
    3) http://www.justskins.com/forums/adding-click-event-to-35785.html
    Thanks and Regards,
    Vibhuti Gosavi | [email protected] | www.infocepts.com

  • Accessing dynamically created movieclips

    I have an application that I am adding movieclips to a
    container movieclip through a for loop and repeatedly calling
    myClip.addChild(theNewClip). Now I have a dozen clips in my
    container and it seems like the only way to access the clip is to
    use the getChildByName() method and cast it into a temporary clip
    so I can get at the its properties.
    Is this the best and/or only way to do this? Does the old AS2
    myContainer["theName"].property not work with dynamically created
    movieclips? It doesn't seem to work for me anymore.
    Anyway I am getting the clips now, but I was hoping someone
    could show me a better way to access a dynamically created movie
    clip.

    In AS3, this is probably not much better, but you can
    generically loop through all movie clips:

  • Accessing Dynamically created Context

    Hi,
    I want to actually read the context which is dynamically created. I have a basic doubt that, will that context contain all the records or just metadata in context? How to read certain records from the context. I dont want to populate them to view via some textbox etc, actually using that data I want to create some xml. so I need to read all the records which are available in that context.
    Please let me know your inputs asap.
    Best REgards,
    Ritesh

    Hi Mehta,
    You can create both nodes as well as attributes in context dynamically. If you are creating a context attribute it will have only a single value.If you are creating context nodes it will have multiple values
    IWDNode node = wdContext.getChildNode("<node name>",IWDNode.LEAD_SELECTION);
    IWDTextview text = (IWDTextview)view,createElement(IWDTextview.class,null)
    text.bindText(node.getElementAt(<give index>).getAttribute())
    Hope this helps you
    Try to create context attributes and nodes statically
    Hope this helps you
    Regards
    Rohit

  • Access dynamically created JTextField

    i need to create an unknown number of JTextField in my GUI, and this number depends on a user-input value.
    Subsequently, i will need to read the strings from the JTextField. This is how I dynamically created my JTextField:
    while (i < num-1) {
    rangePanel.add(new JTextField("0")); // 0 is merely a default value
    how can i access the created JTextFields?
    thanx

    Is this the preferred style?
    I currently have an array of JTextFields but am having real grief (input on screen not availble fro getText(), etc.), code fragment:
    JTextField [] tf = new JTextField[10];
    for (i=0, i<10; i++) {
    ft[i] = new JTextField(15);
    user enters data on screen...
    String str = tf[0].getText() returns blank. Also <tab>ing jumps between first position and where ever mouse originally landed in field.

  • Accessing dynamically created fields

    Hi,
    I have a html that has an input field on it. Say we enter a number( e.g. 5) and submit the html.
    The html transfers control to 1. jsp which creates input fields based on the number entered. In the above example 5 input(text) fields are created dynamically.
    Once I submit 1.jsp, it transfers control to another 2.jsp.
    In 2.jsp, I need to access the values entered in the 5 fields on 1.jsp.
    request.getparameter() returns value only from the 1st field (out of the 5 fields). How to access the remaining fields ?
    Any help is really appreciated.
    Thanks,

    Thanks a lot. That worked!!!!
    Even the ordering seem to be ok.
    With your other suggestion, I had tried that before but that did not work.
    I created field names as field1,field2..etc on the fly and stored this in a String variable - fileName.
    <% fileName = fileName concatinated with number %>
    <input type = "text" name=fileName > Note: There are no quotes around fileName. So fileName could be fileName1, fileName2 etc
    (I don't think the quotes around name attribute really matters.)
    When I say request.getparameter("fileName") it returned only the 1st fileName. Let me know what youythink.
    Thanks again.

  • Modify dynamically created attributes.

    Hi,
    I have created dynamically many check boxes based on a sql query result.
    I have created also a dynamic node with many attributes to make the binding to my check_boxes.
    I want know to acces my check_boxes to perform action : check, uncheck ...
    how can i proceed?
    Thanks.

    Hi ,
    try getting the IF_WD_CONTEXT_NODE_INFO instance for the node.
    DATA : lo_node_info TYPE REF TO IF_WD_CONTEXT_NODE_INFO.
    my_node->GET_NODE_INFO().
    IF_WD_CONTEXT_NODE_INFO has a method GET_ATTRIBUTES().
    Which returns a table of type WDR_CONTEXT_ATTR_INFO_MAP.
    The line type of this table is WDR_CONTEXT_ATTRIBUTE_INFO.
    This structure has fields like name and all the properties of the attribute.
    Check if this method could help you out.
    Although I cannot guarantee if this method works for dynamic nodes and attributes.
    But worth a try.
    Thanks,
    Aditya.

  • How to delete dynamically created attribute

    Hi,
      I am creating table dynamically according to no of columns. first time its displaying correctly, second time once i changed the no of columns its throwing error message like:
    com.sap.tc.webdynpro.progmodel.context.ContextException: DataNodeInfo(DynamicView.TableNode): duplicate name for attribute name0.
    Everytime before creating table i tried  following commands.
    table.removeAllColumns();
    but still i am getting error.
    Help me out in this....
    Regards
    Suresh KB

    hi suresh
    table.removeAllColumns();
    will remove all the columns from the view.
    but when u create the context attributes they are already existing. So it is giving the duplicate context exception.
    To solve this problem, first delete all the attributes created dynamically. using below code.
    wdcontext.node<urnode>().reset(<b>False</b>).
    it will delete all the attrbutes created at runtime.
    to delete attrbutes created at designtime use.
    wdcontext.node<urnode>().reset(<b>True</b>).
    Regards
    Brahmanandam.A
    collections created at design time will be preserved.  All dynamically
    added nodes and attributes are destroyed from the metadata.<p>
    Calling reset(true) is functionally equivalent to calling reset().<p>

  • How to bind dynamically created attributes

    Hi all,
    i hv created an appl where all the attributes hv been created dynamically..
    wdContext.getNodeInfo().addAttribute("From","ddic:com.sap.dictionary.string");
        wdContext.getNodeInfo().addAttribute("To","ddic:com.sap.dictionary.string");
        wdContext.getNodeInfo().addAttribute("Subject","ddic:com.sap.dictionary.string");
        wdContext.getNodeInfo().addAttribute("Message","ddic:com.sap.dictionary.string");
    bt nw i am nt able to retrieve those.
    For ex: if i hv to set the from field to null ,hw to do so?
    (   As we used  to get it:
      wdcontext.currentContextElement().setFrom(" ");
    Plz help.
    Thanks and Regards,
    Ankita
    Edited by: Ankita Padhi on Jul 14, 2008 8:48 AM

    Hi,
    here i m giving code for your reference of a dynamic checkbox:
    IWDCheckBox checkBox =
    (IWDCheckBox) view.createElement(IWDCheckBox.class,
                                  "checkBox" + count);
    IWDMatrixHeadData checkHeadData =
    (IWDMatrixHeadData) checkBox.createLayoutData(
                                  IWDMatrixHeadData.class);
    IWDAttributeInfo attrInfo;
    info=               wdContext.nodeCheckBox().getNodeInfo().addAttribute(
         "Check" + count,          "ddic:com.sap.dictionary.boolean");
                        checkHeadData.setVAlign(WDCellVAlign.TOP);
    checkHeadData.setWidth("6%");
    checkHeadData.setColSpan(1);
    this line used to bind the context to the element:-
    checkBox.bindChecked(info);
    checkBox.setEnabled(true);
    TitleRow.addChild(checkBox);
    Hope this may help you.
    Regards,
    Deepak
    Edited by: Deepak Arora on Jul 14, 2008 9:09 AM

  • Accessing dynamically created objects

    If objects are created dynamically in AS3, using code like
    this:
    for (var num:Number = 0; num<10; num++){
    var txtFld:TextField = new TextField();
    txtFld.text = 'This is the original text';
    this.addChild(txtFld);
    then later, i want to changet the text of one of the
    TextFields, how can I do that? The only instance listed in the
    variables is a single instance of "txtFld" and it is the last one
    that is created. How can I access the others?
    Thanks

    Two ways pop to my mind.
    Give them a name property when you create them and then use
    getChildByName().
    Push each instance into an array/vector as you create it and
    then iterate over the values in the array.
    A combination of both?

  • Access dynamically created objects

    Hello!
    I create some images dynamically by running a for from 1 to a
    variable preset. The pictures have the IDs image1, image2 ...
    ("image"+i). I then add other properties.
    Problem is for each I need an onMouseOverHandler thant will
    swap the image with another.
    I can get the target image with event.currentTarget.id. But I
    cannot set it's properties with this["image"+i].source (I need to
    change the ones up to that as well) and I cannot access it with
    this.getChildByName("image"+i).source either.
    What am I doing wrong please?

    "M*A*S*H 4077" <[email protected]> wrote in
    message
    news:go74q6$fbb$[email protected]..
    > Hello!
    >
    > I create some images dynamically by running a for from 1
    to a variable
    > preset.
    > The pictures have the IDs image1, image2 ...
    ("image"+i). I then add other
    > properties.
    >
    > Problem is for each I need an onMouseOverHandler thant
    will swap the image
    > with another.
    > I can get the target image with event.currentTarget.id.
    But I cannot set
    > it's
    > properties with this["image"+i].source (I need to change
    the ones up to
    > that as
    > well) and I cannot access it with
    this.getChildByName("image"+i).source
    > either.
    >
    > What am I doing wrong please?
    ID is about as useful as your appendix when you create
    objects dynamically.
    The event.target property will contain a reference to your
    image.

  • Problem with accessing dynamically created movie clips, returns null...

    Hopefully this is a stupid question with an easy answer, if my code is straight forward enough.
    I am using this snippet of code to create menu items, and then use the jCount variable below to give the clips an index number, like so (which seems to be working just fine):
    for(var j:Number=0;j<xmlSubMenuLength;j++){ 
        var mcSubMenuItem:mcSubMenu=new mcSubMenu();   
        addChild(mcSubMenuItem);    
        jCount++;   
        mcSubMenuItem.name = "mcSubMenuItem" + jCount;
        //traces out names correctly
        trace ("---------------------------------jCount NAME = "+ mcSubMenuItem.name);
        mcSubMenuItem.x=mcMenuHolder.x+20;
        mcSubMenuItem.y =mcMenuHolder.y;
        mcSubMenuItem.y+= nextBtnY;
        nextBtnY+=subtopicSpace;
        global_subi.text = String(jCount); //i see the proper count of 10 in the text field
    However, when I try to access the clips using this snippet:  
    for(var j:Number=0;j<Number(global_subi.text);j++)//
      trace("GLOBAL SUBI = "+ String(global_subi.text));  //traces out 10, which it should
      var scSubMenuItem:String = "mcSubMenuItem" + j;  
      var scSubContent:Object = this.getChildByName(scSubMenuItem);
      trace(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>scSubContent:Object = "+ scSubContent); //returns null!
    My last trace statement returns null. Can anyone see my error, or explain why I can't access my clips after they have been created?
    Thank you muchly,
    ~Chipleh

    Hi kglad,
    Thanks for the response.
    "it's not clear from the shown code that jCount is initialized." - I've posted the relevant code below, which shows that I'm initializing jCount.
    "and it's not clear why you don't use j instead of jCount in that for-loop" - j is used as loop for creating the subtopic movie clips within the i for-loop. So, for each topic in i for-loop, create a group of suptopics using the j for-loop. The j for-loop re-initiates j every time the length of the subtopics is reached(if that makes any sense) - i.e. topic1>subtopic 1,2,3,4 : topic2>subtopic>1,2 : topic3>subtopic1,2,3,4
    jCount is used to keep a running count of the total number of subtopcs created - i.e. per the example above, jCount will display 10.
    var topicSpace:uint=button_mc.height;
    var subtopicSpace:uint = button_mc.height;
    var nextBtnY:uint = 0;//whatever;
    var jCount:Number = 0;
    function createXMLMenu(menuLength:Number,itemName:XMLList):void{
         var navItemText:XMLList = itemName;
          for(var i:Number=0;i<menuLength;i++)
               var mcMenuItem:mcMenu=new mcMenu();        
               addChild(mcMenuItem); 
               mcMenuItem.btnTxt.htmlText = i+1 +". " +navItemText[i];  
               mcMenuItem.ivar = i;  
               mcMenuItem.name = "mcMenuItem" + i;  
               mcMenuItem.x=mcMenuHolder.x;
               mcMenuItem.y =mcMenuHolder.y;
              //kglad's addition
               mcMenuItem.y+= nextBtnY;
               nextBtnY+=topicSpace; 
               var subVar:Number = i;//mcMenuItem.ivar 
               //Submenu content
               var xmlSubMenuLength:Number = xml.sim.bodyText.page[i].subpage.length()
               var menuItemAttachment:MovieClip = MovieClip(mcMenuItem); 
               for(var j:Number=0;j<xmlSubMenuLength;j++)
                     var xmlSubPageNumber:XMLList = xml.sim.bodyText.page[subVar].subpage;
                     var subNavLinkNumber:Number = xmlSubPageNumber[j];
                     var subTitleText:String = xml.sim.bodyText.page[subVar].subpage.subNavItem[j];
                     var mcSubMenuItem:mcSubMenu=new mcSubMenu();
                     trace("mcSubMenuItem.ivar = "+ j+1);
                     var mc2Attach2:MovieClip = MovieClip(menuItemAttachment);
                     mcSubMenuItem.btnTxt.htmlText = j+1 +". " +subTitleText;   
                     mcSubMenuItem.ivar = Number(subVar);
                     mcSubMenuItem.jvar = Number(j);
                     addChild(mcSubMenuItem);
                     jCount++;   
                     mcSubMenuItem.name = "mcSubMenuItem" + jCount;
                     trace ("---------------------------------jCount NAME = "+ mcSubMenuItem.name);
                     mcSubMenuItem.x=mcMenuHolder.x+20;
                     mcSubMenuItem.y =mcMenuHolder.y;
                     //kglad's addition
                     mcSubMenuItem.y+= nextBtnY;
                     nextBtnY+=subtopicSpace;    
                     global_subi.text = String(jCount);
                mcSubMenuItem.lExtend.visible = false;  
    global_i.text = String(i);
    Then I try to access the clips like so:
    -The first for-loop access the topic movie clips, no problem, and traces out scContent correctly.
    -The second for-loop traces out null everytime, when I would expect it to be tracing out the names of the subtopic movie clips.
    function accessClips(){
         //This will access the topic movie clips
         for(var i:Number=0;i<Number(global_i.text);i++)
               var scMenuItem:String = "mcMenuItem" + i;
               var scContent:Object = this.getChildByName(scMenuItem);            
               trace(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>scContent:Object = "+ scContent);
         //This is supposed to access the subtopic movie clips
         for(var j:Number=0;j<Number(global_subi.text);j++)//
               var scSubMenuItem:String = "mcSubMenuItem" + j;
               var scSubContent:Object = this.getChildByName(scSubMenuItem);
               trace(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>scSubContent:Object = "+ scSubContent);
    Hope this makes sense, Chipleh confused. If the code is not clear enough, let me know and I'll try to further clarify.
    Thanks again,
    ~Chipleh

  • Problem accessing dynamically created table line

    Hi everyone.
    I'm unable to solve the following problem:
    In an offline scenario I have a table which contains one line at creation time. The form offers a button to add lines to the table using javascript and the instanceManager of the table.
    If the added lines are beeing filled by the user I can extract that data without a problem.
    But I cannot acces the newly generated fields with java script.
    I'm not sure, what the problem is. Here is the code, which should do the job:
    xfa.resolveNode("xfa.form.data.Inhalt.CONTACTS.DATA.NAMEV[" + position + "]").rawValue = 'Andreas';
    This works fine, for the table line, that exists right from the beginning(position = 0), but not for any added line.
    I keep getting this error: xfa.resolveNode("xfa.form.data.Inhalt.CONTACTS.DATA.NAMEV[" + position + "]") has no properties
    What am I doing wrong?
    Thanks for any hints,
    Andreas.

    Solved the problem now and it was fairly easy looking at it now.
    I don't know, why the above mentioned adressing does not work, but it works like this:
    var tab = xfa.resolveNodes("xfa.form.data.Inhalt.CONTACTS.DATA[*]");
    // get the last position
    var last = xfa.resolveNodes("xfa.form.data.Inhalt.CONTACTS.DATA[*]").length - 1;
    // fill values
    tab.item(last).NAME1.rawValue = "Andreas";
    Edited by: Andreas Heckele on May 17, 2010 11:07 AM

  • How to set a value to a dynamically created node/attribute?

    Hi,
    I dynamically created attributes using the following method,
    IWDNodeInfo cbOptions = wdContext.getNodeInfo().addChild("cbOpt"+count, null, true, true, false, false, false, true, null, null, null);
    cbOptions.addAttribute("opt"+critEle.getQuest_Critid(), "ddic:com.sap.dictionary.string");
    How do i assign a  value to it now, since the node/attribute cannot be accessed via wdcontext?
    On a side note, it seems really troublesome if i need to use a checkbox grp(s) dynamically. I actually need to dynamically create a seperate node + attribute for each checkbox grp i have. Is there any better way to do this?
    Thanx in advance

    Hi
    Steps:
    1) Create the  action click is done statically (you cannot create action dyanmically)
    2) binding the  action click to checkbox dynamically 
    code
    public static void wdDoModifyView(IPrivateDynamicProgrammingView wdThis, IPrivateDynamicProgrammingView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
        //@@begin wdDoModifyView
         if(firstTime){
                      IWDTransparentContainer con=(IWDTransparentContainer)view.getElement("RootUIElementContainer");
              IWDCheckBox checkBox=(IWDCheckBox)view.createElement(IWDCheckBox.class,"ck");
              IWDAction act=wdThis.wdCreateAction(IPrivateDynamicProgrammingView.WDActionEventHandler.CLICK,"");
              checkBox.setOnToggle(act);
              con.addChild(checkBox);
        //@@end
    Thanks and Regards,
    Arun

Maybe you are looking for