AddItem() adds item to all JComboBoxes

I dynamically generate a series of JComboBoxes using a loop.
inside my loop i test if a certain condition is true, if true i add an item.
The problem is that when the condition tests true, the item I add is added to all my dynamically generated JComboBoxes.
Hopefully some fresher eyes can spot my error.
thanks in advance,
Pete
Here's the offending code:
for(int i = 0; i < counter; ++i)
unitField[i] = new JTextField(5);
boxWeights[i] = new JComboBox(vecWeightText);
String tempName = FCProItem.ingredients.getNameOfIngredient();
lblIngredients[i] = new JLabel(tempName);
if(FCProItem.ingredientsi].hasConversiontempName,FCProMenuItem.CONVERSION_FILE_PATH_TEST) )
System.out.println("Add conversion to combo-box for: " + FCProItem.ingredients[i].getNameOfIngredient());
Vector hold = FCProItem.ingredients[i].getIngredientConversions(tempName);
     for(int z = 0; z < hold.size(); z++)
     if(z % 3 == 0)
     boxWeights[i].addItem(hold.elementAt(z));
.... more code...

In my efforts to solve this I've ruled out as mcu as i can think of.
My problem remains, however, slightly improved. Now I add the correct items, yet still to very JComboBox.
Latest code:
for(int i = 0; i < counter; ++i)
               unitField[i] = new JTextField(5);
               boxWeights[i] = new JComboBox(vecWeightText);
               String tempName = FCProItem.ingredients.getNameOfIngredient();
               lblIngredients[i] = new JLabel(tempName);
               boolean flag = FCProItem.ingredients[i].hasConversion(tempName, FCProMenuItem.CONVERSION_FILE_PATH_TEST);
               if( flag )// we have a conversion
                         Vector hold = FCProItem.ingredients[i].getIngredientConversions(tempName);
                         for(int z = 0; z < hold.size(); z=z+2)
                              boxWeights[i].addItem(hold.elementAt(z));

Similar Messages

  • Using AddItem from A repeater Component item to Add Items to a 'Shopping Cart'

    In my app I previously used a product choice tilelist to display all my products and then as each product is clicked a product details screen popped up showing all of that product's details but my client decided he wants all of the items to be displayed at once so I had to simply use a repeater component around the original product details screen so that it repeats the screen for every product one below the other and I've scrapped the product choice tilelist.
    Previously I used to be able to add item's to a cart/array collection dataprovider by clicking the add item to cart button within the product details screen using the additem method but this needs to be done by assigning text properties to variables as far as I know because you can't put text values into a array collection but it doesn't seem possible to do this from within a repeater item.
    In each of my repeater items I have the values productPrice, productImage, productAddon1 and productAddon2 which are all text components which obviously all vary depending on the repeater item. What I need is when I click on the add item to cart buttons inside each item in the repeater for these details (text component text properties) of that particular item to be added to an array collection. How can I go about doing this?
    Basically the objective is to get dynamic text values from within items of a repeater component into an array collection. Is this possible?

    If any of you guys were to go about doing this how would you do it?
    Basically I have a repeater component display a list of items each of which contains a product. I want it so that when the add to cart button is clicked within the each item it can be added to an array collection but it doesn't seem possible.
    Can anyone help me out or give me a hint on this?

  • Why can't i add playlists to my iPhone from my mac while they are connected? I keep getting the following message "some items (meaning all of them) were not transferred because iTunes match is enabled." This is incredibly frustrating.

    I keep getting the following message "some items (meaning all of them) were not transferred because iTunes match is enabled." when I try to drag and drop a playlist, song, or album to my iPhone. This was NEVER a problem before iTunes match or the last iOS update. So what is the deal? Why can't i just add music to my phone from the mac? There is space on the phone. The only way I have found to get the music i want to the phone is to have it download from the phone. This is not something i want to have to do: go through and manually add every album and recreate a playlist on the phone when its there on the mac. And, even more irritating, since the new update, when the phone is plugged into the mac i can't actually view from the mac what music is on the phone. This is incredibly frustrating and any help would be much appreciated in managing my music libraries for each device.

    Hi,
    You cannot manually manage music with match turned on on your iOS device. If you want to manage music manually, you will need to turn off match on your iPhone.
    Jim

  • Can not add item to the shopping Cart with FireFox 8.0

    I can not add items to the shopping cart with Firefox 8.0. Switch to IE everything works then.

    Such details are stored in a cookie, so make sure that you do not block cookies on that site.
    *Tools > Page Info > Permissions
    You can inspect and manage the permissions for all domains on the <b>about:permissions</b> page via the location bar.
    *http://kb.mozillazine.org/Cookies
    *http://kb.mozillazine.org/Websites_report_cookies_are_disabled

  • How do I read txt file and add items to dropdownlist or checkbox

    I want to add items to a dropdown or check box by reading from a text file(and select one of them). (I donot use any table or database). The list of items is sometimes upto 20MB and hence cannot populate using session bean.I want items to be added to either checkbox or listbox during a button action. I have done this for textarea but unable so far to acheive for checkbox or listbox. I use following code which does not work:
    public String button3_action() {       
    try{           
    FileReader fr = new FileReader "F:/CreatorProjects/checkboxtst.prs");
    BufferedReader br = new BufferedReader(fr);
    String s;
    while((s=br.readLine())!=null) {
    dropdown1.setValue(s);
    br.close();
    fr.close();
    }catch(Exception e) {
    e.printStackTrace();
    return null;
    I know I cant just transplant textarea code for dropdownlist or checkbox.
    Any help is greatly appreciated.
    Thanks.
    Dr.AM.Mohan Rao

    I am able to read from txt file to a listbox if i write in sessionsbean1:
    try{
    FileReader fr = new FileReader("F:/CreatorProjects/checkboxtst.prs");
    BufferedReader br = new BufferedReader(fr);
    String s1="";
    String s="";
    while((s=br.readLine())!=null) {
    s1 = s1+s;
    s1= s1+"\n";
    disOptions = new com.sun.rave.web.ui.model.Option[] {              
    new Option(s1,s1)};
    diseases = new String[] {};
    fr.close();
    br.close();
    catch(Exception e) {
    e.printStackTrace();
    But I get all data in one line!! if I click submit button text area gets all. How to display items in each line????Please help...
    Dr.AM. Mohan Rao

  • DataGrid - Create at runtime - How to Add Items??

    I create a DataGrid at runtime and then and columns to it as need be. How Can I add items with the correct dataField if I don't if I don;t know this till runtime? In other word I'm having trouble constructing the Object to send to AddItem becase the dataField Name needs to be hard coded...
    Below does not work for me because if I have more than one column then I can seem to figure out out to create  ItemObjFinal dynnamically.
    var ItemObjFinal:Object = {ThisNameNeedsToBeDynamic: "text", ThisNameNeedsToBeDynamic: "value" };
    I also tried creating an array of Objects like this:
    var ItemObjFinal:Object = new Object;
    var obj:Object= dgc.dataField;
    ItemObjFinal [0] = {(obj.valueOf()):  dgc.headerText };
    ItemObjFinal [1] = {(obj.valueOf()):  dgc.headerText };
    =========================================================================================
                  ac.addItemAt(dgc, int(ac.length));
                  dataGrid_preview.columns = ac.toArray();
                  var obj:Object= dgc.dataField;
                  var ItemObjFinal:Object = {(obj.valueOf()):  dgc.headerText };
                  var obj2:Object= dgc.dataField;
                  var ItemObjFinal2:Object = {(obj2.valueOf()): dgc.headerText};
                  //K Now add it!
                  //IList(dataGrid_preview.dataProvider).removeAll();
                  IList(dataGrid_preview.dataProvider).addItemAt(ItemObjFinal,0);
                 //IList(dataGrid_preview.dataProvider).addItemAt(ItemObjFinal2,1);

    Ahh answered my own question:
                 ac.addItemAt(dgc, int(ac.length));
                  dataGrid_preview.columns = ac.toArray();
                  var ItemObjFinal:Object = new Object;
                  var ItemObjFinal2:Object = new Object;
                  for each(var col:DataGridColumn in ac)
                    ItemObjFinal[col.dataField] = col.headerText;
                    ItemObjFinal2[col.dataField] = col.headerText;
                  ItemObjFinal[dgc.dataField] = dgc.headerText;
                  ItemObjFinal2[dgc.dataField] = dgc.headerText;
                  //K Now add it!
                  if(IList(dataGrid_preview.dataProvider).length > 1)
                      IList(dataGrid_preview.dataProvider).removeItemAt(0);
                      IList(dataGrid_preview.dataProvider).removeItemAt(1);
                  IList(dataGrid_preview.dataProvider).addItemAt(ItemObjFinal,0);
                  IList(dataGrid_preview.dataProvider).addItemAt(ItemObjFinal2,1);
    This code may still need some tweaking as I get an RTE at  "IList(dataGrid_preview.dataProvider).removeItemAt(1);"   but at least I'm able to solve my original question. Thanks Alex!

  • Cannot add item in A/P Invoice

    Hi, all,
    I want create a A/P invoice without copy from PO or GRPO. However, after I input BP Code, I am not able to add item in Matrix row. Seems that it is blocked
    Any ideas?
    Thanks

    Hello kimmycheng,
    The marketing document can be of 2 types ..Item or Service...this is indicated by the Item / Service type drop down just above the matrix/grid
    If you want to add an Item..this drop down should be set to Item.  If it is of type Service then you might not see the ItemCode column.
    If does not reflect / help what you are referring to ....then please explain your issue ina bit more detail
    Suda

  • Error message when trying to add item in change BOM goup

    Hi I went to transaction cs05,and trying to add item to specific material with BOM group,an error message popped up and saying assign the item to an alternative,what does it mean? How to solve?

    Hi,
    A finished material can have multiple alternative BOMS which can be stored in a common BOM group number. CS05 is used to change these multiple boms.
    When you add a new item in CS05, system will ask - to which alternative bom the new item should be assigned and that's how you are getting this message. For example, if in a bom group you have 3 differnet alternatvie boms for a FG material, when you add new item in CS05, you will see 3 checkbox at the right hand side of the screen. If you want to assign new item to all the three alternative BOMs , than select all the three check box and save.
    Regards,
    Ravi Thakkar.

  • Open Add Item Form as Dialog

    Hi All - I have a custom button on the click of which I am trying to open a Add Item form. When the display form opens I want to hide all the masterpage items( viz. Quick Launch, header, foooter, etc). I tried below but it's not opening and giving error
    when the masterpage is Oslo. It works fine when masterpage is Seattle. 
    <asp:LinkButton OnClientClick ="javascript:SP.UI.ModalDialog.showModalDialog({ url: '../Lists/AddAccount/NewForm.aspx', title: 'Add Account' }); return false;" CausesValidation="false"   CssClass="orange-btn" Text="Post"
    runat="server" ID="btnPost"></asp:LinkButton>
    Does anything know why is it happening?
    Regards,
    Khushi
    Khushi

    You need to set the URL of SharePoint link button like this
    http://<Site Name>/Lists/AddAccount/NewForm.aspx?isDlg=1
    to open that in modal dialog use below jScript.
    <script type="text/javascript">
    function openDialog(listUrl, frmTitle) {
    var options = {
    url: listUrl,
    title: frmTitle,
    allowMaximize: false,
    height: 500,
    width: 600,
    showClose: true
    //SP.UI.ModalDialog.showModalDialog(options);
    SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
    </script>
    And your anchor tag should be like
    <asp:LinkButton OnClientClick ="javascript:openDialog('/Lists/<List Name>/NewForm.aspx?IsDlg=1', 'Add Account')" CausesValidation="false" CssClass="orange-btn" Text="Post" runat="server" ID="btnPost"></asp:LinkButton>
    Adnan Amin MCT, SharePoint Architect | If you find this post useful kindly please mark it as an answer.

  • How to customize the default add item in a content area

    Hi!! I want to know what can I do to introduce a file in a content area, but I don't want to use the default page that portal use. I want to customize the add item option, the same that I have done with the folders. The problem that I have is that I need the user to have the file on his/her pc, and the api add_item needs the file on unix, where de DB is installed.
    If anyone has any idea, please help me.

    Hi All,
    Thanks for all your reply, but maybe i didn't describe my problem clear. My problem for the combobox is that once the combobox has a selected value, then there is no way to clear it in the UI even I remove all the items in its ValidValues. From the user interface, the selected value still stays there but actually this combobox is empty and does not have any items. My question is how can I remove the current selected item in the combobox.
    Thanks,
    Lan

  • ADD ITEMS TO DROPDOWN BOX FROM A TEXT FIELD(USER ENTERS THE ITEM) AND BOUND VALUE ALSO

    I WANT TO ADD ITEMS  THE DROPDOWN BOX FROM THE TEXT FIELD(ITEM NAME) WHERE USER ENTER'S THE ITEM DESCRIPTION
    AND BOUND VALUE ALSO SHOULD BE ADDED TO THE SAME ITEM.
    SAME WAY REMOVE ITEMS FROM DROPDOWN BOX
    PLEASE GIVE SAMPLE FORM OR JAVASCRIPT FOR THE ABOVE SCENARIO.....
    INDEED HELPFUL FOR MY PROJECT PLEASE SEND ATTACHED PDF FORM

    Hi Praveen,
    Your form is not shared so I have not been able to access it.  But I have updated mine.  There are now two approaches, one that follows on from the above method and updates each drop down list in each row.  The second updates a separate dataset that the drop down list is bound to.  This second approach requires the remerge() method which can cause problems if your code has updates some form properties like a borders color as these will be reset, but the code is simplier and you will only have one list to maintain.  The add button click code is;
    var particulars = xfa.datasets.resolveNode("particulars");
    if (particulars === null)
        particulars = xfa.datasets.createNode("dataGroup","particulars");
        xfa.datasets.nodes.append(particulars);    
    var particular = xfa.datasets.createNode("dataValue","particular");
    particular.value = ItemName.rawValue;
    var boundValue = xfa.datasets.createNode("dataValue","id");
    boundValue.value = BoundValue.rawValue;
    particular.nodes.append(boundValue);
    boundValue.contains = "metaData";
    // find sorted position to insert
    for (var i = 0; i < particulars.nodes.length; i++)
        p = particulars.nodes.item(i);
        if (p.value > particular.value)
          particulars.nodes.insert(particular, p);       
                 break;
    // add to end if greater than all existing items
    if (particular.parent === null)
        particulars.nodes.append(particular);
    // clear source fields
    ItemName.rawValue = null;
    BoundValue.rawValue = null;
    // remerge form data to pick up new item
    xfa.form.remerge();
    And the binding looks like;
    I have updated my sample to include both methods, https://workspaces.acrobat.com/?d=OwysfJa-Q3HhPtFlgRb62g
    Regards
    Bruce

  • Content Cannot Be Displayed in a Frame When Trying to Add Item

    We have a user that is trying to add an item to a SharePoint Calendar.  She using using IE9 browser in IE9 compatibility mode.  When she selects a date then clicks on "add item", the dialog box pops up, but it displays "The Content
    cannot be displayed in a frame".  When I try adding and item it works fine for me. 
    I'm at a loss on this one.  Has anyone experienced this or know what is going on?
    Thanks

    To resolve this issue, follow these steps:
    Click Start, click Control
    Panel, and then click Internet Options.
    Note Make sure that you view Control Panel by
    using either small icons or large icons.
    Click the Security tab, click Trusted
    sites, and then click Sites.
    Enter your SharePoint Url, click Add,
    then click Close.
    Make sure that the Enable Protected Mode check
    box isn't selected.
    Close all web browsers, and then try again with a new session.
    Ibrahim Sukari, Technical Consultant | SharePoint | Dynamics CRM |
    LinkedIn Profile

  • Add Item in Shopping cart

    Hi All,
    I want to know which is the screen in which the button 'Add Item to Shopping Cart' appears. The function code associated with it is 'ADDI' .
    The reason why I want this is that I am trying to add my own button on the same screen .
    Regards,
    Poonam

    In SRM 4.0, for the EBP scenario, ITS is used. Hence no BSP applications are available as per my understanding. Pls correct me if I am wrong.
    Further, we have noticed that when clicking the Catalog link from the create shopping cart screen, screen 250 is called. However, if the same functionality is executed from the Change mode of the Approvers login, then the HTML code is generated by some FM.
    Regards,
    Poonam

  • How to used BAPI_SALESORDER_CHANGE to add items

    Hi, I am trying to use the above bapi to add items to a sales order, but I can't get the qty to map across.  I had the same problem using the create bapi whcih I resolved by populating the schedule tables, but in change this just causes an "unhandled exception" to occur, so i can;t even step into the FM to see the problem.  Has anyone got any ideas.
    s_header_inx-updateflag  = 'U'.
    *   set item data
        s_items-itm_number     = s_stock-item_no.
        s_items-material       = s_stock-material_no.
        s_items-target_qty     = s_stock-quantity.
        s_items-target_qu      = s_stock-uom.
        s_items-ref_doc        = s_stock-agreement.
        s_items-ref_doc_it     = s_stock-agreement_item.
        s_items-batch          = s_stock-batch.
        s_items-plant          = s_stock-plant.
        s_items-store_loc      = s_stock-storage_location_no.
        append s_items to it_items.
    *   set flag to add items (I)
        s_itemsx-updateflag    = insert.
        s_itemsx-itm_number    = s_items-itm_number.
        s_itemsx-material      = abap_true.
        s_itemsx-target_qty    = abap_true.
        s_itemsx-ref_doc       = abap_true.
        s_itemsx-ref_doc_it    = abap_true.
        s_itemsx-batch         = abap_true.
        s_itemsx-plant         = abap_true.
        s_itemsx-store_loc     = abap_true.
        append s_itemsx to it_itemsx.
        s_sched-itm_number    = s_items-itm_number.
        s_sched-sched_line    = '0001'.
        s_sched-REQ_DATE      = sy-datum + 30.
        s_sched-req_qty       = s_items-target_qty.
        append s_sched to it_sched.
    *   set flag to add items (I)
    *    s_schedx-updateflag    = 'I'
        s_schedx-itm_number    =  s_items-itm_number.
        s_schedx-sched_line    = '0001'.
        s_schedx-REQ_DATE      = 'X'.
        s_schedx-req_qty       = abap_true.
        append s_schedx to it_schedx.
    * Now call the BAPI to add the items
      call function 'BAPI_SALESORDER_CHANGE'
        exporting
          salesdocument             = me->number
    *   ORDER_HEADER_IN             =
        order_header_inx            = s_header_inx
        SIMULATION                  = ' '
    *    BEHAVE_WHEN_ERROR           = 'P'
    *   INT_NUMBER_ASSIGNMENT       = ' '
    *   LOGIC_SWITCH                =
    *   NO_STATUS_BUF_INIT          = ' '
       tables
        return                      = it_return
        order_item_in               = it_items
        order_item_inx              = it_itemsx
    *   PARTNERS                    =
    *   PARTNERCHANGES              =
    *   PARTNERADDRESSES            =
    *   ORDER_CFGS_REF              =
    *   ORDER_CFGS_INST             =
    *   ORDER_CFGS_PART_OF          =
    *   ORDER_CFGS_VALUE            =
    *   ORDER_CFGS_BLOB             =
    *   ORDER_CFGS_VK               =
    *   ORDER_CFGS_REFINST          =
        order_schedules_in          = it_sched
        order_schedules_inx         = it_schedx
    *   ORDER_TEXT                  =
    *   ORDER_KEYS                  =
    *   CONDITIONS_IN               =
    *   CONDITIONS_INX              =
    *   EXTENSIONIN                 =

    hi,
    BAPI_SALESORDER_CHANGE didn't work for me either though i'm 100% sure the bapi works
    See SAP note 366265 which tells you how to fill the structures but
    you can use your program which you used to create the sales order to change the order and all you need to
    do is change a few parameters
    CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
      EXPORTING
       SALESDOCUMENTIN               =  P_VBELN
        ORDER_HEADER_IN               = ORDER_HEADER_IN
        ORDER_HEADER_INX              = 'U'
    (make sure your partners are blank, otherwise you'll get a duprec on VBPA)
    -( PS , yes, i;m saying , see if BAPI_SALESORDER_CREATEFROMDAT2 works for you)
    I hope this helps
    Paul Q
    Edited by: Paul Quinn on Jun 2, 2011 11:10 PM

  • Unable to add items to dropdown list using javascript

    Hi,
    I'm trying to add additional items to a dropdown list at runtime using javascript.
    I'm doing this by invoking the addItem method on the dropdown list field during its initialize event.
    However when I run the generated pdf in Acrobat Pro, I get the following error in the console -
    GeneralError: Operation failed.
    XFAObject.addItem:3:XFA:form1[0]:#subform[0]:field0[0]:initialize
    Method: 'addItem' cannot be called because doing so would violate this document's permissions settings.
    The pdf form has no signatures or any other stuff in it.
    What additional permissions do I need to add and how ?
    You can view the pdf here -
    https://dl.dropboxusercontent.com/u/8022836/xfa3_test.pdf
    Thanks,
    Joel

    Is there a reason to use the code you did? It looks like the problem is with the variable's permissions when going through the template.
    This code works just fine in that same event:
    this.addItem("new item");
    As does:
    var f = xfa.resolveNode("form1.#subform1[0].field0");
    f.additem("new item");

Maybe you are looking for