Weird add/remove child layout behavior

I'm trying to build an an app that allows the user to toggle
certain panels on and off. These panels are in Divider containers.
It seems that at startup, when I remove and add a panel flex
doesn't properly validate layout. For example 2 panels are added to
a VDivided container. I then call removeChild on the second panel
(at the bottom of the container), and the first panel then properly
occupies all the visible space. When I add the second panel back,
it is re-added but has not retained its original size and is
instead compressed at the bottom. If I then remove the top panel
and add it again, then remove the bottom panel and add it,
everything works as I expect. It's almost like their is a one-time
initialization not occurring somewhere. Here is the code sample I
am using to demonstrate the problem:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" width="1000" height="800">
<mx:VBox height="100%" top="0" left="0" right="0">
<mx:ApplicationControlBar x="0" y="0" width="100%"
height="58">
<mx:CheckBox label="Panel 1" id="panel1CheckBox"
selected="true" click="modifyViewPanel1()"/>
<mx:CheckBox label="Panel 2" id="panel2CheckBox"
selected="true" click="modifyViewPanel2()"/>
</mx:ApplicationControlBar>
<mx:VDividedBox x="0" y="0" width="100%" height="90%"
id="vDivideBox">
<mx:Panel width="100%" height="50%" layout="vertical"
title="Panel 1" id="panel1">
</mx:Panel>
<mx:Panel width="100%" height="50%" layout="vertical"
id="panel2" title="Panel 2">
</mx:Panel>
</mx:VDividedBox>
</mx:VBox>
<mx:Script>
<![CDATA[
private function modifyViewPanel1():void {
trace("modifyView...");
if (panel1.parent) panel1.parent.removeChild(panel1);
if (panel1CheckBox.selected) {
vDivideBox.addChildAt(panel1, 0);
private function modifyViewPanel2():void {
trace("modifyView...");
if (panel2.parent) panel2.parent.removeChild(panel2);
if (panel2CheckBox.selected) {
vDivideBox.addChildAt(panel2,
vDivideBox.getChildren().length);
]]>
</mx:Script>
</mx:Application>

The properties you set with MXML tags are the initial values,
they aren't used to reset the controls. They would have to be
dynamic properties like width="{comp1.width/2}" for them to change
as the program runs. Setting a component's width to "50%" just
means it will initially be calculated to have 50% of the width of
its parent. As the program runs the component's width can change
which it what's happened.
Removing a child only removes the component from the parent's
display list. The component still exists and adding it back causes
the parent to recalculate its layout. This means it may change the
size of the children.
You have a couple of choices. You can give the Panel a
minHeight and the Divider will respect that. Or you can calculate
the Panel's height, set it to that value, then add it back to the
Divider.

Similar Messages

  • Tweens/add/remove childs works fine, but after a few clicks it goes to the crapper

    I keep checking this and checking this, but its obvious I'm missing something. after a few clicks the entire design breaks down. Anyone have any insight? Here's the code...
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;
    whitePanel_mc.addEventListener(Event.ENTER_FRAME, startUpAni);
    greyPanel_mc.addEventListener(Event.ENTER_FRAME, startUpAni);
    greyPanel2_mc.addEventListener(Event.ENTER_FRAME, startUpAni);
    redPanel_mc.addEventListener(Event.ENTER_FRAME, startUpAni);
    bgPanel_mc.addEventListener(Event.ENTER_FRAME, startUpAni);
    banner_mc.buttonMode = true;
    websites_mc.buttonMode = true;
    content_mc.buttonMode = true;
    contact_mc.buttonMode = true;
    var startAd_mc:StartAd = new StartAd();
    var return_mc:Return = new Return();
    var infoText1_mc:Info = new Info();
    var infoText2_mc:Info2 = new Info2();
    function getReturnBtn(e:TweenEvent):void
    banner_mc.removeEventListener(MouseEvent.CLICK, startBanText);
    contact_mc.removeEventListener(MouseEvent.CLICK, startConText);
    content_mc.removeEventListener(MouseEvent.CLICK, startContText);
    websites_mc.removeEventListener(MouseEvent.CLICK, startWebText);
    return_mc.buttonMode = true;
    return_mc.x = 100;
    return_mc.y = 466;
    return_mc.addEventListener(MouseEvent.CLICK, restoreMainMenu);
    addChild(return_mc);
    function startWebText(e:MouseEvent):void
    var contMenuTween:Tween = new Tween(content_mc, "x", Strong.easeOut, content_mc.x, 0, 6, false);
    var conMenuTween:Tween = new Tween(contact_mc, "x", Strong.easeOut, contact_mc.x, 0, 6, false);
    var banMenuTween:Tween = new Tween(banner_mc, "x", Strong.easeOut, banner_mc.x, 0, 6, false);
    var wTween:Tween = new Tween(whitePanel_mc, "x", Strong.easeOut, whitePanel_mc.x, 899, 12, false);
    var gTween:Tween = new Tween(greyPanel_mc, "x", Strong.easeOut, greyPanel_mc.x, 899, 12, false);
    var g2Tween:Tween = new Tween(greyPanel2_mc, "x", Strong.easeOut, greyPanel2_mc.x, 899, 12, false);
    infoText1_mc.x = 25;
    infoText1_mc.y = 25;
    infoText1_mc.gotoAndStop("websites");
    addChild(infoText1_mc);
    infoText2_mc.x = 458;
    infoText2_mc.y = 120;
    infoText2_mc.gotoAndStop("websites");
    addChild(infoText2_mc);
    removeChild(startAd_mc);
    banMenuTween.addEventListener(TweenEvent.MOTION_FINISH, getReturnBtn);
    function startContText(e:MouseEvent):void
    var webMenuTween:Tween = new Tween(websites_mc, "x", Strong.easeOut, websites_mc.x, 0, 6, false);
    var conMenuTween:Tween = new Tween(contact_mc, "x", Strong.easeOut, contact_mc.x, 0, 6, false);
    var banMenuTween:Tween = new Tween(banner_mc, "x", Strong.easeOut, banner_mc.x, 0, 6, false);
    var wTween:Tween = new Tween(whitePanel_mc, "x", Strong.easeOut, whitePanel_mc.x, 899, 12, false);
    var gTween:Tween = new Tween(greyPanel_mc, "x", Strong.easeOut, greyPanel_mc.x, 899, 12, false);
    var g2Tween:Tween = new Tween(greyPanel2_mc, "x", Strong.easeOut, greyPanel2_mc.x, 899, 12, false);
    infoText1_mc.x = 25;
    infoText1_mc.y = 25;
    infoText1_mc.gotoAndStop("content");
    addChild(infoText1_mc);
    infoText2_mc.x = 458;
    infoText2_mc.y = 120;
    infoText2_mc.gotoAndStop("content");
    addChild(infoText2_mc);
    removeChild(startAd_mc);
    banMenuTween.addEventListener(TweenEvent.MOTION_FINISH, getReturnBtn);
    function startConText(e:MouseEvent):void
    var webMenuTween:Tween = new Tween(websites_mc, "x", Strong.easeOut, websites_mc.x, 0, 6, false);
    var contMenuTween:Tween = new Tween(content_mc, "x", Strong.easeOut, content_mc.x, 0, 6, false);
    var banMenuTween:Tween = new Tween(banner_mc, "x", Strong.easeOut, banner_mc.x, 0, 6, false);
    var wTween:Tween = new Tween(whitePanel_mc, "x", Strong.easeOut, whitePanel_mc.x, 899, 12, false);
    var gTween:Tween = new Tween(greyPanel_mc, "x", Strong.easeOut, greyPanel_mc.x, 899, 12, false);
    var g2Tween:Tween = new Tween(greyPanel2_mc, "x", Strong.easeOut, greyPanel2_mc.x, 899, 12, false);
    infoText1_mc.x = 25;
    infoText1_mc.y = 25;
    infoText1_mc.gotoAndStop("contact");
    addChild(infoText1_mc);
    removeChild(startAd_mc);
    banMenuTween.addEventListener(TweenEvent.MOTION_FINISH, getReturnBtn);
    function startBanText(e:MouseEvent):void
    var webMenuTween:Tween = new Tween(websites_mc, "x", Strong.easeOut, websites_mc.x, 0, 6, false);
    var contMenuTween:Tween = new Tween(content_mc, "x", Strong.easeOut, content_mc.x, 0, 6, false);
    var conMenuTween:Tween = new Tween(contact_mc, "x", Strong.easeOut, contact_mc.x, 0, 6, false);
    var wTween:Tween = new Tween(whitePanel_mc, "x", Strong.easeOut, whitePanel_mc.x, 899, 12, false);
    var gTween:Tween = new Tween(greyPanel_mc, "x", Strong.easeOut, greyPanel_mc.x, 899, 12, false);
    var g2Tween:Tween = new Tween(greyPanel2_mc, "x", Strong.easeOut, greyPanel2_mc.x, 899, 12, false);
    infoText1_mc.x = 25;
    infoText1_mc.y = 25;
    infoText1_mc.gotoAndStop("banners");
    addChild(infoText1_mc);
    infoText2_mc.x = 458;
    infoText2_mc.y = 120;
    infoText2_mc.gotoAndStop("banners");
    addChild(infoText2_mc);
    removeChild(startAd_mc);
    contMenuTween.addEventListener(TweenEvent.MOTION_FINISH, getReturnBtn);
    function restoreMainMenu(e:MouseEvent):void
    removeChild(return_mc);
    removeChild(infoText1_mc);
    if (infoText2_mc.visible == true)
      removeChild(infoText2_mc);
    return_mc.removeEventListener(MouseEvent.CLICK, restoreMainMenu);
    stage.addEventListener(Event.ENTER_FRAME, startMenuAni);
    whitePanel_mc.addEventListener(Event.ENTER_FRAME, startUpAni);
    function startUpAni(e:Event):void
    var wTween:Tween = new Tween(whitePanel_mc, "x", Strong.easeOut, whitePanel_mc.x, 330, 6, false);
    var gTween:Tween = new Tween(greyPanel_mc, "x", Strong.easeOut, greyPanel_mc.x, 356, 10, false);
    var g2Tween:Tween = new Tween(greyPanel2_mc, "x", Strong.easeOut, greyPanel2_mc.x, 393, 14, false);
    var rTween:Tween = new Tween(redPanel_mc, "x", Strong.easeOut, redPanel_mc.x, 428, 18, false);
    var bTween:Tween = new Tween(bgPanel_mc, "x", Strong.easeOut, bgPanel_mc.x, 454, 20, false);
    rTween.addEventListener(TweenEvent.MOTION_FINISH, removeAni);
    function removeAni(e:TweenEvent):void
    whitePanel_mc.removeEventListener(Event.ENTER_FRAME, startUpAni);
    greyPanel_mc.removeEventListener(Event.ENTER_FRAME, startUpAni);
    greyPanel2_mc.removeEventListener(Event.ENTER_FRAME, startUpAni);
    redPanel_mc.removeEventListener(Event.ENTER_FRAME, startUpAni);
    bgPanel_mc.removeEventListener(Event.ENTER_FRAME, startUpAni);
    stage.addEventListener(Event.ENTER_FRAME, startMenuAni);
    function startMenuAni(e:Event):void
    var contTween:Tween = new Tween(contact_mc, "x", Strong.easeOut, contact_mc.x, 100, 3, false);
    var webTween:Tween = new Tween(websites_mc, "x", Strong.easeOut, websites_mc.x, 150, 3, false);
    var conTween:Tween = new Tween(content_mc, "x", Strong.easeOut, content_mc.x, 200, 3, false);
    var banTween:Tween = new Tween(banner_mc, "x", Strong.easeOut, banner_mc.x, 250, 3, false);
    banTween.addEventListener(TweenEvent.MOTION_FINISH, removeMenuAni);
    banner_mc.removeEventListener(MouseEvent.CLICK, startBanText);
    contact_mc.removeEventListener(MouseEvent.CLICK, startConText);
    content_mc.removeEventListener(MouseEvent.CLICK, startContText);
    websites_mc.removeEventListener(MouseEvent.CLICK, startWebText);
    startAd_mc.x = 25;
    startAd_mc.y = 25;
    addChild(startAd_mc);
    function removeMenuAni(e:Event):void
    stage.removeEventListener(Event.ENTER_FRAME, startMenuAni);
    banner_mc.addEventListener(MouseEvent.CLICK, startBanText);
    contact_mc.addEventListener(MouseEvent.CLICK, startConText);
    content_mc.addEventListener(MouseEvent.CLICK, startContText);
    websites_mc.addEventListener(MouseEvent.CLICK, startWebText);
    Is it the tweens? do I have too many? Should I create variables for the exact destinations of the objects? Should I create some null references? Should I index some of it with array(s)? I know i'm missing something...
    This can actually be viewed here as well... www.calladorn.com

    Ideas anyone?

  • Surely SOMEONE HAS SEEN THIS BEHAVIOR???  Distorted Add Remove control!

    Lots of people have VIEWED this posting since I first posted it on Nov 30th,
    but I can't believe that NOBODY ELSE HAS SEEN THIS BEHAVIOR!
    So here it is again....
    Can anyone tell me why on some pc's my Add Remove list control appears stretched out - that is, the right-side 'selected' list box will extend to the left covering the add/remove buttons and the same 'selected' box is only half drawn from the left side (right side missing), including the title being truncated, and the title is then duplicated to the right in its entirety. (It is hard to describe but I can provide a screenshot if needed).
    As soon as an item is selected or de-selected, it re-adjusts itself to normalcy!
    It seems to be a browser independent problem which ONLY happens on SOME pc's and NEVER on others! This leads me to suspect an out-of-date jar or class file on the local pc but I can't seem to find anything inconsistent.
    CAN ANYONE HELP?! It is preventing us from putting this page into production and I would hate to have to write my own replacement, as it would take more time than we have.
    Thanks in advance for your assistance,
    <-j->
    PS - I have tried REPEATEDLY to add some Duke Dollars to this submission to no avail! The link just goes to a Pge Not Found or something similar

    As I mentioned in my original post, it seems to be a non-browser related problem - that is it shows up MOSTLY in IE, but has been seen also in Firefox.
    Any suggestions on what further to check would be GREATLY APPRECIATED!

  • Need help removing child

    Sorry to bring problems but i am trying to learn some as3 and so far i can not resolve this situation ,,,,,,
    this is the script i am using ,,,,,,,,,,,,,,
    Ent.buttonMode = true;
    Bio.buttonMode = true;
    ent.addEventListener(MouseEvent.CLICK, goEnt);
    function goEnt (e:MouseEvent):void
    var new Ent:MovieClip = new firstIntro();
    this.addChild(newEnt);
    newEnt.x = 659;
    newEnt.y = 428;
    Bio.addEventListener(MouseEvent.CLICK, goBio);
    function goBio (e:MouseEvent):void
    var newBio:MovieClip = new bioIntro();
    this.addChild(newBio);
    newBio.x = 659;
    newBio.y = 428;
    the problem is that when i click on first button the Movie Clip does load ok but when i click on second button the first movie cliip is visible ,,,, i have try everything i have read here but no luck ,,,,,,, i want to learn how to remove first child and allow only the second child to show up ,,,,,,, i am looking forward to add more buttons so the remove child should be for multiple buttons ,,,,, i am learning and so far did purchase a online tutorial but did not help me with this situation ,,,, thank you all in advance ,,,,,

    Create a variable to hold a reference to any child object that is added to the display list, then when any given button is used to add a new movieclip to the display list, use removeChild to get rid if any existing movie clip that was added through the reference in the variable. After the new movie clip is added to the display list, add a reference to that movie clip to the variable so that it can be used when the next movie clip will be added.
    Ent.buttonMode = true;
    Bio.buttonMode = true;
    // create a variable to hold a reference to the currently added child, if any...
    var currentChild: MovieClip;
    ent.addEventListener(MouseEvent.CLICK, goEnt);
    function goEnt (e:MouseEvent):void
    var new Ent:MovieClip = new firstIntro();
    // remove any child object currently in the display list...
    if(currentChild != null) {
    removeChild(currentChild);
    this.addChild(newEnt);
    // put a reference to the added child to the variable...
    currentChild = newEnt;
    newEnt.x = 659;
    newEnt.y = 428;
    Bio.addEventListener(MouseEvent.CLICK, goBio);
    function goBio (e:MouseEvent):void
    var newBio:MovieClip = new bioIntro();
    // remove any child object currently in the display list...
    if(currentChild != null) {
    removeChild(currentChild);
    this.addChild(newBio);
    // put a reference to the added child to the variable...
    currentChild = newBio;
    newBio.x = 659;
    newBio.y = 428;

  • Change button disabled in ESS add/remove dependents

    We are on version 4.7D and have noticed that ESS transaction PZ12 does not consistently allow changes to existing records. I can change a spouse, but I cannot change a child or an emergency contact via ESS.  I get the same results when accessing through R/3, but there are no messages as to what the problem is.  I have tried removing the dependents from all benefits plans, then trying to change the data in PZ12, but that does not work. I have checked for any authorization errors, and none exist. Does anyone have any ideas as to how to correct this and enable the change button in all cases?
    The dependent type 2 is set up with time constraint 3. I have checked table T591A_ESSEX and can see that the subtype is allowed to be maintained via ESS.
    Thanks in advance.

    OK. There are two ways to do this:
    1. Create a button facet in the Add remove component
    2. Modify the theme.
    For the first way here is a sampe:
    1. drag a add removelist onto the designer
    2. Edit the jsp to look like this:
                            <ui:addRemove availableItemsLabel="Available:" binding="#{Page1.addRemoveList1}" id="addRemoveList1"
                                items="#{Page1.addRemoveList1DefaultOptions.options}" moveButtons="true" selectAll="true"
                                selected="#{Page1.addRemoveList1DefaultOptions.selectedValue}" selectedItemsLabel="Selected:" style="left: 24px; top: 24px; position: absolute">
                                <f:facet name="addButton">
                                    <ui:button id="addRemoveList1_addButton" onClick="AddRemove_form1_addRemoveList1.add()" text="Lark Add"/>
                                </f:facet>
                            </ui:addRemove>3. deploy/run
    4. select an item and press the Lark Add button. The internal javascript gets called to add the item.
    The second way requires that you modify the themes. You can view these posts for information on modifying themes:
    http://blogs.sun.com/roller/page/gjmurphy?entry=quick_guide_editing_themes_for
    The default button lables are:
    AddRemove.add=Add
    AddRemove.remove=Remove
    Hope it helps,
    Lark

  • EJB-3 Shouldn't persiting/removing child objects be reflected in OneToMany?

    I'm a bit puzzled by behaviour I'm finding. (Toplink)
    I modify the list of children under an entity, removing some child entities and inserting others.
    The odd thing is that I seem to have to do two things each time. To add a child I set the child's parent pointer to the existing entity and persist is, but I also have to add the child to the OneToMany collection.
    Conversely, on delete, I have to remove the child both from the collection and the entityManager.
    Shouldn't the changes in the collection be automatic? Or, conversely, given that the parent link it mandatory, shouldn't removing the child from the collection suffice to delete it?
    ps. to clarify:
    If I don't change the OneToMany collection object the child changes aren't reflected even though I find the parent entity again.
    Message was edited by:
    malcolmmc

    I'm afarid not - a generic feature that will allow to
    delete orphan children didn't make it into the final
    spec.
    regards,
    -marinaDo you happen to have any links to public discussions about this feature with regard to the development of the spec? This is a very nice feature in Hibernate and it's absence in EJB 3.0 is rather disappointing.
    Thanks.

  • Rendering of tab row and pages is totally messed up when I add/remove/scroll through tabs

    After upgrading to 4b9 from 4b8, the rendering is totally messed up, whenever I add, remove or simply scroll through the tab row (if I'm calling it correctly). The tab row basically disappears and at least 5 seconds to come back, while lots of flashing and buggy behavior. During this time the rendering of the main page is also messed up.
    After it finishes rendering, the main page could still be in a bad state. At which I have to switch tabs or scroll the main page, to force a re-draw of the main page, to get the rendering looking correct.
    The only clue I have is that I have lots and lots of tabs open. And it looks like when I'm on the first few tabs it doesn't happen as badly.. This worked perfectly on 4b8.

    I'm sorry to hear that you have so many issues. What version of Firefox were you using before?
    The double title bar issue has been identified as an issue with the Tax Mix Plus extension but it doesn't affect everyone, it's an interaction with something else (not exactly clear what, although Norton Toolbar was mentioned in one thread).
    There is a new version available that you could try. If Firefox is stable enough to do it...
    orange Firefox button (or Tools menu) > Add-ons > "gear" icon > Check for Updates
    If your beta version won't update, you could try installing [https://addons.mozilla.org/en-us/firefox/addon/tab-mix-plus/ from the add-ons site].
    More generally, could I suggest disabling as many extensions as you can live without for 24 hours, and re-enable them gradually? This should help isolate interactions between them. As you know, you can do that here:
    orange Firefox button (or Tools menu) > Add-ons > Extensions category
    Finally, regarding your old session, if you haven't closed Firefox, you might find a sessionstore.bak file in your profile folder that contains your old session. To easily access that folder, try
    Help > Troubleshooting Information > "Show Folder" button
    Grab a copy of that file and save it somewhere outside the folder because it is overwritten when you close Firefox. Got to run, but if you find one with an appropriate date, someone can help you restore it.

  • BorderLayout clobbers child layouts.

    Smells like a bug to me. If you place child panels with, say GridBagLayouts inside a panel which has a BorderLayout, the parental BorderLayout clobbers the child layouts. So if you have a panel in the CENTER and you want a button anchored to the upper left hand corner with GridBagConstraints.NORTHWEST, you'll find that your GridBag is completely ignored and your component is centered.
    Check out the following code:
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Enumeration;
    public class Foo3 extends JPanel {
        public static void main(String[] args) {
            JFrame frame = new JFrame("Joe's Foo3");
            frame.addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent e) {
                    System.exit(0);
            // Here's your main panel with BorderLayout
            JPanel mainPanel = new JPanel();
            mainPanel.setLayout(new BorderLayout());
            // Here's your inner panel with a GridBag...you want the
            // "NorthWest" button to appear in the northwest corner
            // of the center panel.
            JPanel innerPanel = new JPanel(new GridBagLayout());
            innerPanel.setBackground(Color.black);
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.gridx = 0;
            gbc.gridy = 0;
            gbc.anchor = GridBagConstraints.NORTHWEST;
            gbc.fill = GridBagConstraints.BOTH;
            innerPanel.add(new JButton("NorthWest"), gbc);
            // Add a button to each of the layout areas
            mainPanel.add(new JButton("North"), BorderLayout.NORTH);
            mainPanel.add(new JButton("West"), BorderLayout.WEST);
            mainPanel.add(innerPanel, BorderLayout.CENTER);
            mainPanel.add(new JButton("East"), BorderLayout.EAST);
            mainPanel.add(new JButton("South"), BorderLayout.SOUTH);
            // Show
            frame.getContentPane().add("Center", mainPanel);
            frame.pack();
            frame.setSize(new Dimension(300, 300));
            frame.setVisible(true);

    Hmmm... I tried a few things with your app and nothing worked so far. Looks like you might not be the first to encounter this, but I haven't found a resolution other than don't use GridBag. :)
    http://forum.java.sun.com/thread.jsp?forum=5&thread=238875

  • Forms Designer - Unable to remove Child Table from the form

    Hello,
    While testing adding additional attributes, I have assigned an additional child table to the form. However I am not able to remove it. I get an error message: "This version has been made active. Add/Update/Delete not allowed."
    I tried creating new version and making it active to remove 'active' status from the form I modified, but still getting the same error. What am I doing wrong? Thank you in advance.

    creating new version and making it active to remove 'active+'
    Make new version then remove child form and then make version active..
    You are making version active b4 removing child table.
    Don't change the sequence which I have written above.

  • Remove Child does clean momery?

    Hi.
    I know that if you remove childs previously added with addChild to the stage they tend to stick in memory and thus reducing performance. For instance if i use a for statement every time i want to populate a list and remove them while i close the list do they remain in memory and thus doing more add and remove of different childs would clutter the memory? Because every time i would create new childs and then add them with addChild so i presume they stick in memory.
    Is there a way to safely remove them so that i free up memory every time  i remove Childs?
    Thank you.

    Take a look at this wonderful article about Resource Management in AS3.
    http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html
    Regards,
    CaioToOn!

  • HI Can I add a child node to an Element Node with a name that  exists

    HI,
    Can I add a child node to an Element Node with a name that is already existing in the Element Node.
    Let me explain what I need exactly.
    My Existing element Node looks like this:
    <form>
    <name>
    <FirstName></FirstName>
    <LastName></LastName>
    </name>
    </form>
    Can I add another child node with hte name 'FirstName' to the 'name' node ..?
    I want to put a attribute rvsn with a value 1 for the original 'FirstName' element Node.
    so the new Element Node should look like the foloowing:
    <form>
    <name>
    <FirstName rvsn="1"></FirstName>
    <FirstName></FirstName>
    <LastName></LastName>
    </name>
    </form>
    Hopefully this is valid XML !!
    when I tried to use appendChild, it removed the previous node and put the new one. Thats what is the documentation also said.. I read it after I tried it :(
    Anyway, ther should be another way to add a node like that.
    Any hints, ideas will be of great help.
    -Thanks in advance !!
    Murthy

    // this method will start marking the old values with a revision number.
         private void saveNodeDetails (Node node) {
    String Content = "";
    String nodeName = "";
    int rvsn = getRvsn();
    int type = node.getNodeType();
    int tempRvsn = 0;
    String tempNodeName = "";
    String tempParentNodeName = "";
    Node tempParentNode = null;
    // check if element
    if (type == Node.ELEMENT_NODE) {
    Node traverseNode = node;
    nodeName = getNodeName(traverseNode);
    if (nodeName != null && nodeName.trim().length() > 1)
    nodeName = nodeName.substring(0, nodeName.length() - 1);
    if (_debug)
    System.out.print("2. ELEMENT_NODE name## " + nodeName);
    // if the element has no children, its leaf node.
    // if its there in the Hashtble, then update the value from the hashtable.
    if (reqParams.containsKey(nodeName)) {
    if (_debug) System.out.println("3. Hash Value = " + reqParams.get(nodeName).toString());
    if (traverseNode == null)
    if (_debug) System.out.println("3A. traverseNode == null ");
    if (node == null)
    if (_debug) System.out.println("3B. node == null ::(((((");
    // get the node children
    NodeList children = node.getChildNodes();
    // end of getting children for the Node.
    if (_debug) System.out.println("4. Got ChildNodes ");
    if (children != null) {
    int length = 0;
    length = children.getLength();
    if (_debug) System.out.println("5. Got children Length = " + length);
    if( ((Element) node).hasAttribute("rvsn") ){
    System.out.println(" node has Attribute(rvsn) ");
    tempRvsn = Integer.parseInt( ((Element) node).getAttribute("rvsn") );
    if( tempRvsn == rvsn){
    // user is changing the same data again and again.
    // so remove the text node and append the new value as text node finally
    for (int index = 0; index < length; index++) {
    if (_debug) System.out.println("6. index = " + index);
    if (_debug) System.out.println(index + ": children.item( index )@saveNodeDetails@ContainerDoc = " + children.item(index).getNodeType() + " -- " + children.item(index).getNodeValue());
    if (children.item(index).getNodeType() == Node.TEXT_NODE)
    node.removeChild(children.item(index));
    }else{
    int l= 0; // do not do any thing if the current node rvsn is different from the rvsn of the DOM
    // programme logic could enter this part when ther are multiple revisions of the NODe in the DOM,
    // and we are traversing through the previous versions of it.
    } else{
    System.out.println(" node has no Attribute(rvsn) ");
    // the node has no rvsn attribute.
    // it is the initial version of the dom.
    // add the rvsn from the DOM to this NODE for the first time.
    ((Element) node).setAttribute("rvsn", (new Integer(rvsn)).toString() );
    // get parent node and add a new child node with the same name as current node.
    // so parent node will have the previous node with a rvsn and a new node without the rvsn !!
    tempNodeName = node.getNodeName();
    tempParentNode = node.getParentNode();
    tempParentNodeName = tempParentNode.getNodeName();
    System.out.println(" adding node: " + tempNodeName + " to : " + tempParentNodeName);
    node = addNode(tempParentNode, tempNodeName, "");
    getNodeName(node); // print the name of the node after modifying it !!!
    printSiblings(node);
    //System.out.println(" After adding the node : " + getNodeName(node));
    } else if (_debug) {
    System.out.println("7. Node name exist in the Hash but has no children to be removed..!!:: @saveNodeDetails ");
    if (_debug) System.out.println("7B. Update the dom from the hash value " + nodeName + ", " + reqParams.get(nodeName).toString());
    node.appendChild(document.createTextNode(reqParams.get(nodeName).toString()));
    if (node != null) {
    if ( ( (Element) node).hasAttribute("rvw"))
    ( (Element) node).removeAttribute("rvw");
    if ( ( (Element) node).hasAttribute("msg"))
    ( (Element) node).removeAttribute("msg");
    if ( ( (Element) node).hasAttribute("dor"))
    ( (Element) node).removeAttribute("dor");
    }// end of if (type == Node.ELEMENT_NODE)
    NodeList children = node.getChildNodes();
    if (children != null) {
    for (int i = 0; i < children.getLength(); i++) {
    saveNodeDetails(children.item(i));
         } // end of saveNodeDetails method
    public Node addNode(Node parentNode, String nodeName, String value){
    Node newNode = null;
    try{
    newNode = parentNode.appendChild( document.createElement(nodeName) );
    newNode.appendChild( document.createTextNode( value ) );
    }catch(Exception Ex){
    System.out.println("2. Exception@addNode@ContainerDoc = " + Ex);
    return newNode ;
    } // end of addNode method

  • [svn:osmf:] 9866: Adding '@throws' clauses to ILayoutRenderer add/ remove target methods, and adding a 'targets(target:ILayoutTarget)' method that allows checking addition/removal validity up front.

    Revision: 9866
    Author:   [email protected]
    Date:     2009-09-01 00:56:48 -0700 (Tue, 01 Sep 2009)
    Log Message:
    Adding '@throws' clauses to ILayoutRenderer add/remove target methods, and adding a 'targets(target:ILayoutTarget)' method that allows checking addition/removal validity up front.
    Modified Paths:
        osmf/trunk/framework/MediaFramework/org/openvideoplayer/layout/ILayoutRenderer.as
        osmf/trunk/framework/MediaFramework/org/openvideoplayer/layout/LayoutRendererBase.as

  • Tried to install newest itunes, crashed during install, and now crashes my computer every time i try to uninstall.  Itunes doesn't show up in the Add/remove prog list at all.  tried to roll back over a month, still crashing.

    So I tried to update to the newest Itunes.  It locked up my computer part way thru the install.  Black screen, computer turned itself off.  Now anytime i try to do anything with Itunes it shuts my computer down.  I can start up fine in safe mode but when i try to uninstall from there, Itunes doesn't exist.  the other apple programs do, but no itunes.  when i try to uninstall the other programs in safe mode it tells me it can't because the windows installer isn't loaded.  I have system restored to over a month ago and itunes still doesn't show up in add/remove programs.  however, i can open itunes.  it just tells me a file didn't get installed and to uninstall and reinstall.  So, how do i remove a progam that doesn't think it exists and crashes my computer when i try to do anything related to it???  I'm out of ideas.  running windows vista.

    I think my problem is fixed now.
    For the fun of it, I reinstalled iTunes 9.2.1 today (using the exact same installer as I did yesterday), but this time I didn't uninstall iTunes first. As expected, iTunes recognized my iPhone (as I expected it to, until my next reboot).
    A few minutes later, Software Update showed up and among the updates is "iPhone SDK Compatibility Update". The description indicates that installing this should fix an issue where iPhones and iPod touches aren't recognized by iTunes. Isn't that interesting?
    I installed that update and most of the others waiting for me (including Java, Safari 5.0.1, and a few others - not 10.6.4 though, due to the issues with nVidia graphics cards). After the reboot, I started iTunes, and it saw my iPhone!
    So, if you're having this same problem, I'd recommend tracking down this update and see if that does the trick for you. Hopefully it will.

  • I have installed Adobe Premiere Pro cc on my laptop, but I cant find a way to start the program. No Icon, and it is not showing up in the start meny. It is showing up in add/remove programs, but nt anywhere else.

    I have installed Adobe Premiere Pro cc on my laptop, but I cant find a way to start the program. No Icon, and it is not showing up in the start meny. It is showing up in add/remove programs, but nt anywhere else.

    If you are using a Mac, simply hit Command-Spacebar to bring up Spotlight Search.  Begin typing the name of the application and when you see what you are looking for, press enter.  You should get a hit by the second or third letter you type.  Great way to launch apps on computers that you are not familiar with.
    Windows 7 and 8 should have something similar.  I think you simply press the Windows key and begin typing.  Press enter when you see a match.
    Both Mac and Windows search tools can be customized to search for applications, files, emails and so forth.  For Windows, look for Taskbar and Start Menu Properties.  For Mac, go to Preferences Spotlight.  Turn off items you know you won't need to speed up searches.
    Make Windows 7 Start Menu Search Find Your Applications Faster

  • Add/Remove Programs - export to text file?

    Hello,
    I am wondering if it is possible to export a list of everything in add/remove programs to a text file for inventory purposes.
    I have not found any easy method to do this short of copying reg files or installer 3rd party software.  Since the idea is to save time neither of those are viable solutions.
    Does anyone have any ideas?
    -Justin

    You could try this vbs script that lists installed programs and add info to a text file.
    Michael Petersen
    Option Explicit  
    Dim sTitle  
    sTitle = "InstalledPrograms.vbs by Bill James" 
    Dim StrComputer  
    strComputer = InputBox("Enter I.P. or name of computer to check for " & _  
                           "installed software (leave blank to check " & _  
                           "local system)." & vbcrlf & vbcrlf & "Remote " & _  
                           "checking only from NT type OS to NT type OS " & _  
                           "with same Admin level UID & PW", sTitle)  
    If IsEmpty(strComputer) Then WScript.Quit  
    strComputer = Trim(strComputer)  
    If strComputer = "" Then strComputer = "." 
    'Wscript.Echo GetAddRemove(strComputer)  
    Dim sCompName : sCompName = GetProbedID(StrComputer)  
    Dim sFileName  
    sFileName = sCompName & "_" & GetDTFileName() & "_Software.txt" 
    Dim s : s = GetAddRemove(strComputer)  
    If WriteFile(s, sFileName) Then 
      'optional prompt for display  
      If MsgBox("Finished processing.  Results saved to " & sFileName & _  
                vbcrlf & vbcrlf & "Do you want to view the results now?", _  
                4 + 32, sTitle) = 6 Then 
        WScript.CreateObject("WScript.Shell").Run sFileName, 9  
      End If 
    End If 
    Function GetAddRemove(sComp)  
      'Function credit to Torgeir Bakken  
      Dim cnt, oReg, sBaseKey, iRC, aSubKeys  
      Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE  
      Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _  
                  sComp & "/root/default:StdRegProv")  
      sBaseKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" 
      iRC = oReg.EnumKey(HKLM, sBaseKey, aSubKeys)  
      Dim sKey, sValue, sTmp, sVersion, sDateValue, sYr, sMth, sDay  
      For Each sKey In aSubKeys  
        iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey, "DisplayName", sValue)  
        If iRC <> 0 Then 
          oReg.GetStringValue HKLM, sBaseKey & sKey, "QuietDisplayName", sValue  
        End If 
        If sValue <> "" Then 
          iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey, _  
                                    "DisplayVersion", sVersion)  
          If sVersion <> "" Then 
            sValue = sValue & vbTab & "Ver: " & sVersion  
          Else 
            sValue = sValue & vbTab   
          End If 
          iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey, _  
                                    "InstallDate", sDateValue)  
          If sDateValue <> "" Then 
            sYr =  Left(sDateValue, 4)  
            sMth = Mid(sDateValue, 5, 2)  
            sDay = Right(sDateValue, 2)  
            'some Registry entries have improper date format  
            On Error Resume Next   
            sDateValue = DateSerial(sYr, sMth, sDay)  
            On Error GoTo 0  
            If sdateValue <> "" Then 
              sValue = sValue & vbTab & "Installed: " & sDateValue  
            End If 
          End If 
          sTmp = sTmp & sValue & vbcrlf  
        cnt = cnt + 1  
        End If 
      Next 
      sTmp = BubbleSort(sTmp)  
      GetAddRemove = "INSTALLED SOFTWARE (" & cnt & ") - " & sCompName & _  
                     " - " & Now() & vbcrlf & vbcrlf & sTmp   
    End Function 
    Function BubbleSort(sTmp)  
      'cheapo bubble sort  
      Dim aTmp, i, j, temp  
      aTmp = Split(sTmp, vbcrlf)    
      For i = UBound(aTmp) - 1 To 0 Step -1  
        For j = 0 to i - 1  
          If LCase(aTmp(j)) > LCase(aTmp(j+1)) Then 
            temp = aTmp(j + 1)  
            aTmp(j + 1) = aTmp(j)  
            aTmp(j) = temp  
          End if  
        Next 
      Next 
      BubbleSort = Join(aTmp, vbcrlf)  
    End Function 
    Function GetProbedID(sComp)  
      Dim objWMIService, colItems, objItem  
      Set objWMIService = GetObject("winmgmts:\\" & sComp & "\root\cimv2")  
      Set colItems = objWMIService.ExecQuery("Select SystemName from " & _  
                                             "Win32_NetworkAdapter",,48)  
      For Each objItem in colItems  
        GetProbedID = objItem.SystemName  
      Next 
    End Function 
    Function GetDTFileName()  
      dim sNow, sMth, sDay, sYr, sHr, sMin, sSec  
      sNow = Now  
      sMth = Right("0" & Month(sNow), 2)  
      sDay = Right("0" & Day(sNow), 2)  
      sYr = Right("00" & Year(sNow), 4)  
      sHr = Right("0" & Hour(sNow), 2)  
      sMin = Right("0" & Minute(sNow), 2)  
      sSec = Right("0" & Second(sNow), 2)  
      GetDTFileName = sMth & sDay & sYr & "_" & sHr & sMin & sSec  
    End Function 
    Function WriteFile(sData, sFileName)  
      Dim fso, OutFile, bWrite  
      bWrite = True 
      Set fso = CreateObject("Scripting.FileSystemObject")  
      On Error Resume Next 
      Set OutFile = fso.OpenTextFile(sFileName, 2, True)  
      'Possibly need a prompt to close the file and one recursion attempt.  
      If Err = 70 Then 
        Wscript.Echo "Could not write to file " & sFileName & ", results " & _  
                     "not saved." & vbcrlf & vbcrlf & "This is probably " & _  
                     "because the file is already open." 
        bWrite = False 
      ElseIf Err Then 
        WScript.Echo err & vbcrlf & err.description  
        bWrite = False 
      End If 
      On Error GoTo 0  
      If bWrite Then 
        OutFile.WriteLine(sData)  
        OutFile.Close  
      End If 
      Set fso = Nothing 
      Set OutFile = Nothing 
      WriteFile = bWrite  
    End Function 
    Deploy deploy deploy

Maybe you are looking for