UnsupportedOperationException with List.add(Object obj)

List statusCodes = Arrays.asList(OcsCustomDicInfo.acctRefundStatusCodes);
          List statusNames = Arrays.asList(OcsCustomDicInfo.acctRefundStatusNames);
          // Add an additional item          statusCodes.add(Integer.toString(statusCodes.size()));           statusNames.add("All");
          String[] statusCodesArray = (String[]) statusCodes.toArray();
          String[] statusNamesArray = (String[]) statusNames.toArray();I used the Arrays.asList to convert an Array(which is String[]) to a List,then add one item to the List with add(Object obj).
But when the debuger run to the "statusCodes.add(Integer.toString(statusCodes.size())); " breakpoint, it throws UnsupportedOperationException.
I checked the API, the relative statement is:
UnsupportedOperationException - if the add method is not supported by this list.
Why? Doesn't the Arrays.asList() return a "List" Interface,and "List" support "add()" operation,but why not support in this case?

Sorry,i have made a mistake when posting the code.
This is the code:
List statusCodes = Arrays.asList(OcsCustomDicInfo.acctRefundStatusCodes);
List statusNames = Arrays.asList(OcsCustomDicInfo.acctRefundStatusNames);
// Add an additional item          
statusCodes.add(Integer.toString(statusCodes.size()));
statusNames.add("All");
String[] statusCodesArray = (String[]) statusCodes.toArray();
String[] statusNamesArray = (String[]) statusNames.toArray();

Similar Messages

  • Entity object attribute with a list of objects

    Does anyone know how one sets up an entity object that has an attribute with a list of objects as the type? (assuming that's supported)
    as in:
    CREATE TYPE phones AS VARRAY(10) OF varchar2(10);
    Create table suppliers (supcode number(5),
    Company varchar2(20),
    ph phones);
    The SOA Suite in jDeveloper (new Entity Object/attributes etc) has an ARRAY that can point to REF or OBJECT. Neither work. When I try to Create DB Object later from the Entity Object I've created I get an invalid type.

    What you suggested about "validation codes on the VO" is not written on the ADF Documentation.
    I try to blindly/strictly follow best practices (particularly on Validations, using Declartive and/or built in validators) on most ADF documentation and blogs but there are many scenarios on coding some large ADF projects that I think must veer away from the best practices stated on the documentation or maybe add new rules on the documentation depending on how complex an ADF project would be.
    I religiously followed best practices stated on the documentation to use Entity and Attribute Validators when performing validations. What I did was i had created lots of Custom Validators (by implementing JboVAlidatorInterface interface) for each of the attributes on an Entity Object that need validated. So those validator is valid only for one attribute, its not reusable. And those validation codes either have reference to a ViewObject or call some PL/SQL procedure. So at some point are codes became messy.
    Ultimately the whole project became harder to manage when the codes became large. Now I am trying to refactor the whole application by separating it into project/package and I am hoping to do it with little Re-coding as possible.
    Hope to get your opinion on this one.
    regards,
    Anton

  • Function to add Objects to transport piece list (CTS)

    Dear all,
    with function "TR_EXT_INSERT_IN_REQUEST" I can add objects to a transport request. Now I need to "fill" a piece list. The function module is not working for piece lists (documented).
    Does anybody please know a function to add objects to a piece list?
    Thanks and best regards for help.
    Roman

    Funny, German and English documentation is different:
    German:
    Kurztext
    Anhängen und Sperren von Objekten und Schlüsseln an eine Aufgabe
    Dieser Funktionsbaustein ist veraltet. Bitte verwendet Sie stattdessen
    TR_REQUEST_CHOICE für einen Transportanschluss oder
    TR_OBJECT_CHECK und TR_OBJECT_INSERT für die Änderungsaufzeichnung.
    Weitere Doku finden Sie bei diesen Bausteinen.
    This means: Do not use anymore instead use TR_OBJECT_CHECK  and TR_OBJECT_INSERT .
    Best regards
    Roman

  • Property List error: Unexpected character b at line 1 / JSON error: JSON text did not start with array or object and option to allow fragments not set.

    Hi,
    I have a MBP 13' Late 2011 and Yosemite 10.10.2 (14C1514).
    Until yesterday, I was using Garmin ConnectIQ SDK and all was working fine.
    Yesterday, I've updated my system with latest security updates and Xcode updates too (Version 6.2 (6C131e)).
    Since, I can't launch the ConnectIQ simulator app, I have this message in console :
    8/04/2015 15:19:04,103 mds[38]: There was an error parsing the Info.plist for the bundle at URL Info.plist -- file:///Volumes/Leto/connectiq-sdk-mac-1.1.0_2/ios/ConnectIQ.bundle/
    The data couldn’t be read because it isn’t in the correct format.
    <CFBasicHash 0x7fa64f44e9a0 [0x7fff7dfc7cf0]>{type = immutable dict, count = 2,
    entries =>
      0 : <CFString 0x7fff7df92580 [0x7fff7dfc7cf0]>{contents = "NSDebugDescription"} = <CFString 0x7fa64f44f0a0 [0x7fff7dfc7cf0]>{contents = "Unexpected character b at line 1"}
      1 : <CFString 0x7fff7df9f5e0 [0x7fff7dfc7cf0]>{contents = "kCFPropertyListOldStyleParsingError"} = Error Domain=NSCocoaErrorDomain Code=3840 "The data couldn’t be read because it isn’t in the correct format." (Conversion of string failed.) UserInfo=0x7fa64f44eda0 {NSDebugDescription=Conversion of string failed.}
    I have looked at this file and it looks like a binary plist
    bplist00ß^P^V^A^B^C^D^E^F^G^H
    ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_ !"$%&'()'+,^[\CFBundleNameWDTXcodeYDTSDKName_^P^XNSHumanReadableCopyrightZDTSDKBuild_^P^YCFBundleDevelopmentRegion_^P^OCFBundleVersi    on_^P^SBuildMachineOSBuild^DTPlatformName_^P^SCFBundlePackageType_^P^ZCFBundleShortVersionString_^P^ZCFBundleSupportedPlatforms_^P^]CFBundleInfoDictionaryVersion_^P^RCFBundleE    xecutableZDTCompiler_^P^PMinimumOSVersion_^P^RCFBundleIdentifier^UIDeviceFamily_^P^QDTPlatformVersion\DTXcodeBuild_^P^QCFBundleSignature_^P^ODTPlatformBuildYConnectIQT0611[iph    oneos8.1o^P-^@C^@o^@p^@y^@r^@i^@g^@h^@t^@ ^@©^@ ^@2^@0^@1^@5^@ ^@G^@a^@r^@m^@i^@n^@.^@ ^@A^@l^@l^@ ^@r^@i^@g^@h^@t^@s^@ ^@r^@e^@s^@e^@r^@v^@e^@d^@.V12B411RenQ1V14C109Xiphoneos    TBNDLS1.0¡#XiPhoneOSS6.0YConnectIQ_^P"com.apple.compilers.llvm.clang.1_0S8.1_^P^Tcom.garmin.ConnectIQ¡*^P^AW6A2008aT????^@^H^@7^@D^@L^@V^@q^@|^@<98>^@ª^@À^@Ï^@å^A^B^A^_^A?^AT^    A_^Ar^A<87>^A<96>^Aª^A·^AË^AÝ^Aç^Aì^Aø^BU^B\^B_^Ba^Bh^Bq^Bv^Bz^B|^B<85>^B<89>^B<93>^B¸^B¼^BÓ^BÕ^B×^Bß^@^@^@^@^@^@^B^A^@^@^@^@^@^@^@-^@^@^@^@^@^@^@^@^@^@^@^@^@^@^Bä
    I guess it is a normal format but my system seems to be unable to read binary plist ?
    I tried some stuff with plutil
    plutil -lint Info.plist
    Info.plist: Unexpected character b at line 1
    Same for convert
    plutil -convert xml1 Info.plist
    Info.plist: Property List error: Unexpected character b at line 1 / JSON error: JSON text did not start with array or object and option to allow fragments not set.
    I also try to download a fresh version of the connectIQ SDK and no changes.
    Any idea ?
    Thanks

    Step by step, how did you arrive at seeing this agreement?

  • KE30 decimal not display in quantity column with output type object list

    Hi everyone,
         I already set number format "0.000" in change form screen but when I execute report with output type object list (ALV) that report don't display decimal in quantities column e.g. 0.470 displayed to 0 .
        How can I set number format in output type object list on Transaction code KE30?
    Thanks in advance.
    Pipit

    Hi,
    Better to raise this issue in CO Forum. You can expect some solution.
    regards

  • [svn:bz-trunk] 18926: bug fix BLZ-570 Double linked list with lot of objects result in BlazeDS Error deserializing error  : StackOverflowError

    Revision: 18926
    Revision: 18926
    Author:   [email protected]
    Date:     2010-12-01 14:07:19 -0800 (Wed, 01 Dec 2010)
    Log Message:
    bug fix BLZ-570 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError
    We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml.
    This needs documentation.
    Checkintests pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-570
    Modified Paths:
        blazeds/trunk/modules/common/src/flex/messaging/errors.properties
        blazeds/trunk/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.java
        blazeds/trunk/modules/core/src/flex/messaging/io/SerializationContext.java
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/Amf0Input.java
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/Amf3Input.java
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/AmfIO.java

  • [svn:bz-4.0.0_fixes] 20451: backporting bug fix BLZ-570/ BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error  : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError .

    Revision: 20451
    Revision: 20451
    Author:   [email protected]
    Date:     2011-02-24 08:33:31 -0800 (Thu, 24 Feb 2011)
    Log Message:
    backporting bug fix BLZ-570/BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml. This needs documentation.  Checkintests pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-570
        http://bugs.adobe.com/jira/browse/BLZ-620
    Modified Paths:
        blazeds/branches/4.0.0_fixes/modules/common/src/flex/messaging/errors.properties
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.j ava
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/SerializationContext.java
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/Amf0Input.java
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/Amf3Input.java
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/AmfIO.java

    Dear Pallavi,
    Very useful post!
    I am looking for similar accelerators for
    Software Inventory Accelerator
    Hardware Inventory Accelerator
    Interfaces Inventory
    Customization Assessment Accelerator
    Sizing Tool
    Which helps us to come up with the relevant Bill of Matetials for every area mentioned above, and the ones which I dont know...
    Request help on such accelerators... Any clues?
    Any reply, help is highly appreciated.
    Regards
    Manish Madhav

  • [svn:bz-3.x] 20443: back porting bug fix BLZ-570/ BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error  : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError .

    Revision: 20443
    Revision: 20443
    Author:   [email protected]
    Date:     2011-02-23 21:19:22 -0800 (Wed, 23 Feb 2011)
    Log Message:
    back porting bug fix BLZ-570/BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml. This needs documentation.  Checkintests pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-570
        http://bugs.adobe.com/jira/browse/BLZ-620
    Modified Paths:
        blazeds/branches/3.x/modules/common/src/java/flex/messaging/errors.properties
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/endpoints/AbstractEndpoint.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/SerializationContext.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/Amf0Input.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/Amf3Input.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/AmfIO.java

  • Im having trouble with Object obj

    public int compareTo(Object obj){
              Customer aCustomer=Customer(obj);
              if (numJobs<aCustomer.numJobs)
                   return -1;
              if (numJobs==aCustomer.numJobs)
                   return 0;
              return 1;
    this is my code it seems that this line Customer aCustomer=Customer(obj); gives me an error
    Customer.java:53: cannot resolve symbol
    symbol : method Customer (java.lang.Object)
    location: class project3.Customer
              Customer aCustomer=Customer(obj);
    ^
    1 error
    i odnt know why that is i was hoping someone could help thanks

    Customer aCustomer=(Customer)obj;

  • Best Practice for caching global list of objects

    Here's my situation, (I'm guessing this is mostly a question about cache synchronization):
    I have a database with several tables that contain between 10-50 rows of information. The values in these tables CAN be added/edited/deleted, but this happens VERY RARELY. I have to retrieve a list of these objects VERY FREQUENTLY (sometimes all, sometimes with a simple filter) throughout the application.
    What I would like to do is to load these up at startup time and then only query the cache from then on out, managing the cache manually when necessary.
    My questions are:
    What's the best way to guarantee that I can load a list of objects into the cache and always have them there?
    In the above scenario, would I only need to synchronize the cache on add and delete? Would edits be handled automatically?
    Is it better to ditch this approach and to just cache them myself (this doesn't sound great for deploying in a cluster)?
    Ideas?

    The cache synch feature as it exists today is kind of an "all or nothing" thing. You either synch everything in your app, or nothing in your app. There isn't really any mechanism within TopLink cache synch you can exploit for more app specific cache synch.
    Keeping in mind that I haven't spent much time looking at your app and use cases, I still think that the helper class is the way to go, because it sounds like your need for refreshing is rather infrequent and very specific. I would just make use of JMS and have your app send updates.
    I.e., in some node in the cluster:
    Vector changed = new Vector();
    UnitOfWork uow= session.acquireUnitOfWork();
    MyObject mo = uow.registerObject(someObject);
    // user updates mo in a GUI
    changed.addElement(mo);
    uow.commit();
    MoHelper.broadcastChange(changed);
    Then in MoHelper:
    public void broadcast(Vector changed) {
    Hashtable classnameAndIds = new Hashtable();
    iterate over changed
    if (i.getClassname() exists in classAndIDs)
    classAndIds.get(i.getClassname()).add(i.getId());
    else {
    Vector vc = new Vector();
    vc.add(i.getId())
    classAndIds.add(i.getClassname(),vc);
    jmsTopic.send(classAndIds);
    Then in each node in the cluster you have a listener to the topic/queue:
    public void processJMSMessage(Hashtable classnameAndIds) {
    iterate over classAndIds
    Class c = Class.forname(classname);
    ReadAllQuery raq = new ReadAllQuery(c);
    raq.refreshIdentityMapResult();
    ExpressionBuilder b = new ExpressionBuilder();
    Expression exp = b.get("id").in(idsVector);
    roq.setSelectionCriteria(exp);
    session.executeQuery(roq);
    - Don

  • ADF DataControl for WebService with unexpected blank objects

    Hello experts!
    I'm developing for BPM Suite 11.1.1.5 PS4 Feature Pack using JDeveloper 11.1.1.5
    I am currently using Data Controls for web services that interact with SAP; I can retrieve information successfully displaying items in tables and selectOneChoice lists without a problem.
    There are no Java classes for the Data Controls, everything is handled by the XML files created by JDeveloper.
    The issue happens when creating the input parameters for a web service that updates data in the remote system. The web service has complex types with lists of complex types. I am currently using the iterator for the items on the complex types to create rows and add values to those rows. The problem is that for some reason the input for those lists always contain one extra object with no data (this was identified with the help of tcpmon).
    I'll use the example of the Barcodelist list of items; the corresponding iterators are BarcodelistIterator and itemIterator2. There's also an action binding for the creation of a new row.
    The bindings:
    <accessorIterator MasterBinding="ZPostInvoiceAndAttachment_parametersIterator"
    Binds="Barcodelist" RangeSize="25" DataControl="sapPost"
    BeanClass="sapPost.Types.ZPostInvoiceAndAttachment.Barcodelist"
    id="BarcodelistIterator"/>
    <accessorIterator id="itemIterator2" MasterBinding="BarcodelistIterator"
    Binds="item" RangeSize="25" DataControl="sapPost"
    BeanClass="sapPost.Types.ZPostInvoiceAndAttachment.Barcodelist.item"/>
    <action IterBinding="itemIterator2" id="CreateInsert2"
    InstanceName="sapPost.Types.ZPostInvoiceAndAttachment.Barcodelist.item"
    DataControl="sapPost" RequiresUpdateModel="true"
    Action="createRow"/>
    This is the definition for item.xml:
    <?xml version="1.0" encoding="UTF-8" ?>
    <JavaBean xmlns="http://xmlns.oracle.com/adfm/beanmodel" version="11.1.1.60.13"
    id="item"
    Package="sapPost.Types.ZPostInvoiceAndAttachment.Barcodelist"
    BeanClass="sapPost.Types.ZPostInvoiceAndAttachment.Barcodelist.item"
    isJavaBased="false">
    <Attribute Name="Barcode" IsNotNull="true" Type="java.lang.String"/>
    <Attribute Name="BarcodeId" IsNotNull="true" Type="java.lang.String"/>
    <Attribute Name="Contrep" IsNotNull="true" Type="java.lang.String"/>
    <Attribute Name="Docid" IsNotNull="true" Type="java.lang.String"/>
    <Attribute Name="Ardate" IsNotNull="true" Type="java.lang.String"/>
    <Attribute Name="Doctype" IsNotNull="true" Type="java.lang.String"/>
    </JavaBean>
    This is the code to insert a single item in the list. I clear all items for the iterator with a method I will show below
    //Barcode List
    DCIteratorBinding itr4 = ADFUtils.findIterator("itemIterator2");
    ADFUtils.clearAllRowsForIterator(itr4);
    OperationBinding createBarcodeList = ADFUtils.findOperation("CreateInsert2");
    createBarcodeList.execute();
    Row barcodeRow = itr4.getCurrentRow();
    barcodeRow.setAttribute("Barcode", "20120208114025");
    barcodeRow.setAttribute("BarcodeId", "01");
    barcodeRow.setAttribute("Contrep", "ZT"); //ZT for Test Documentum, ZD for Production
    barcodeRow.setAttribute("Docid", "DCTM3701E24080000D9A");
    barcodeRow.setAttribute("Ardate", "2011-09-01");
    barcodeRow.setAttribute("Doctype", "PDF");
    ADFUtils.clearAllRowsForIterator method:
    public static void clearAllRowsForIterator(DCIteratorBinding itr) {
    Row[] allItems = itr.getAllRowsInRange();
    for( int i = 0; i < allItems.length; i++ ) {
    itr.removeCurrentRow();
    The code below is implemented in an ActionListener for a button which calls the web service method:
    public void postToSAP(ActionEvent actionEvent) {
    setPostInput(); //sets all input parameters
    OperationBinding op = ADFUtils.findOperation("ZPostInvoiceAndAttachment");
    Object returned = op.execute();
    When I monitor what is being sent in the SOAP envelop using tcpmon I get 2 items for the barcodelist (and similarly an additional blank item for every list in the input parameters):
         <Barcodelist>
              <item>
                   <Barcode>20120208114025</Barcode>
                   <BarcodeId>01</BarcodeId>
                   <Contrep>ZT</Contrep>
                   <Docid>DCTM3701E24080000D9A</Docid>
                   <Ardate>2011-09-01</Ardate>
                   <Doctype>PDF</Doctype>
              </item>
              <item>
                   <Barcode/><BarcodeId/><Contrep/><Docid/><Ardate/><Doctype/>
              </item>
         </Barcodelist>
    This causes the web service to return an error as there's a blank item in the list.
    I have checked the number of rows in the barcode list before and after the web service call and it is always 1. I can't find where this blank item is coming from. I searched the web but all I found which would address this would be to implement java classes; but the goal here would be to achieve this with as less java programming effort as possible.
    Any help is greatly appreciated.
    Bruno

    user1113055 wrote:
    ... the consequent adaptation of the existing JSPXs based on the previous definition of the view objects was quite painful: i found very hard to reflect the changes to the JSPXs and, in some cases, i had to rewrite the pages from scratch! You will need to be more specific about the issues that you have encountered. Synchronization and refactoring is supported in JDeveloper for the model, the view and the controller. For what it's worth, take a look at these entry-level posts that could provide some additional inside:
    http://jdeveloperfaq.blogspot.com/2010/02/faq-15-how-to-synchronize-adf-entity.html
    http://jdeveloperfaq.blogspot.com/2010/04/faq-20-how-to-refactor-adf-components.html

  • Best method for scrollable list of objects

    I was attempting to create a list of objects in a scrollable pane with the ScrollPane object. I am having a very hard time customizing what is actually scrolling in that pane, though. By using a custom renderer class, I am able to change what it looks like and even add objects to it, but I am having trouble passing data to those objects at creation because it is loaded through the pane object itself.
    What I would like to do is create an object with buttons on it (relative to that object) and be able to add multiple ones to a scrollable pane. I tried to figure out a way to be able to simply add my object as the item, but it seems to require a specific object. Is there any work around to this? What would be the best way of going about this?
    Thanks for any help.

    Class: java.sql.DatabaseMetadata
    Method: getSQLKeywords
    Desc: Returns a comma-delimited list of all non-SQL92 keywords used by the database
    Example (Source http://javaalmanac.com/egs/java.sql/GetSqlKeywords.html?l=rel ):
    import java.sql.Connection;
    import java.sql.DatabaseMetaData;
    public String[] getSQLKeywords(Connection connection) {  
       String[] keywords = null;  
       try {       
          DatabaseMetaData dbmd = connection.getMetaData();       
          keywords = dbmd.getSQLKeywords().split(",\\s*");   
       } catch (SQLException e) {
          // Handle Exception   
       return keywords;
    SQL92 Keywords
    The SQL92 specification is available for purchase. However, if you just want the full list of reserved words / keywords for a particular type of database, there is usually documentation provided by the database vendor.
    Full Keyword List Oracle 8.0:
    http://www-rohan.sdsu.edu/doc/oracle/server803/A54656_01/vol2_wor.htm#421705
    For Other Oracle Versions:
    - Visit technet.oracle.com
    - Register for free
    - Go to Documentation
    - Look under K for Keywords in index for newer versions of Oracle
    - Look under Programmer's Guide to the Oracle Call Interface for older versions of Oracle

  • UI not getting change update when working with LIST and INotifyPropertyChanged

    i was trying to know two way data binding. i have simple car class which extend INotifyPropertyChanged for notify the change to update UI. bind List object to few textboxes and notice when one textbox value change then other textbox value not updated. all
    textboxes bind to same property. so one's value change should propagate to other textboxes.
    this is my code
    public class Car : INotifyPropertyChanged
    private string _make;
    private string _model;
    private int _year;
    public event PropertyChangedEventHandler PropertyChanged;
    public Car(string make, string model, int year)
    _make = make;
    _model = model;
    _year = year;
    public string Make
    get { return _make; }
    set
    _make = value;
    this.NotifyPropertyChanged("Make");
    public string Model
    get { return _model; }
    set
    _model = value;
    this.NotifyPropertyChanged("Model");
    public int Year
    get { return _year; }
    set
    _year = value;
    this.NotifyPropertyChanged("Year");
    private void NotifyPropertyChanged(string name)
    if (PropertyChanged != null)
    PropertyChanged(this, new PropertyChangedEventArgs(name));
    This way i bind
    Car carTest;
    private void Form1_Load(object sender, EventArgs e)
    carTest = new Car("Ford", "Mustang", 1967);
    List<Car> ol = new List<Car>();
    ol.Add(carTest);
    this.textBox1.DataBindings.Add("Text", ol, "Make", true, DataSourceUpdateMode.OnPropertyChanged);
    this.textBox2.DataBindings.Add("Text", ol, "Make", true, DataSourceUpdateMode.OnPropertyChanged);
    this.textBox3.DataBindings.Add("Text", ol, "Make");
    when run the code then Ford was showing as make name but when change value in any textbox then that change is not shown in other textboxes.
    the moment i change this line List<Car> ol = new List<Car>(); to
    BindingList<Car> ol = new BindingList<Car>(); then code started to work fine.
    My Question
    1) what is the difference between List and BindingList class ?
    2) can't we use List<> for my situation instead of BindingList
    3)
    this.textBox2.DataBindings.Add("Text", ol, "Make", true, DataSourceUpdateMode.OnPropertyChanged);
    this.textBox3.DataBindings.Add("Text", ol, "Make");
    see the above code and tell me what is the advantage of using DataSourceUpdateMode.OnPropertyChanged because i have seen if we do not use this code
    DataSourceUpdateMode.OnPropertyChanged then also data change is propagated to other textbox when cursor focus change.

    I would have thought that'd work with List<t>, in fact I think there must be something wrong in your code there.  I can't spot it though.
    I recommend use of ObservableCollection rather than BindingList.
    The default on bindings is that changes are propagated from the target ( view ) to source ( vm ) when the control loses focus.
    If you want to do the equivalent to a keydown event handler in a viewmodel then onpropertychanged is the way to go.
    You want to avoid creating bindings in code unless you really really have to, it's way easier to put them in xaml.
    Even if your ui is dynamic, you can build xaml and use that to create the ui objects:
    http://social.technet.microsoft.com/wiki/contents/articles/28797.aspx
    The difference between BindingList and List is, literally, iBindingList.
    See
    https://msdn.microsoft.com/en-us/library/system.componentmodel.ibindinglist%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
    What probably isn't very obvious is that BindingList fires an event - iirc  itemchanged when properties on objects in it change.
    Maybe you did something wrong in your implementation of inotifypropertychanged.  I must admit, I can't see anything there though.
    You don't really need those magic strings since .net4.5 and you also don't need to explicitly implement inotifypropertychanged you could use:
    public event PropertyChangedEventHandler PropertyChanged;
    public void RaisePropertyChanged([CallerMemberName] String propertyName = "")
    if (PropertyChanged != null)
    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    As used in this:
    https://gallery.technet.microsoft.com/WPF-Dynamic-Fonts-ad3741ca
    If you try that sample you can have:
    public class FontDetails : INotifyPropertyChanged
    or
    public class FontDetails
    And you can see it still notifies change successfully to both windows.
    Most wpf devs will use observablecollection rather than List or bindinglist.
    Observablecollection notifies addition or removal of entries.  It can be used to notify an entry has changed, but does not detect change of property.  You would have to raise the event in code if you want to tell it an item changed.
    Hope that helps.
    Technet articles: Uneventful MVVM;
    All my Technet Articles

  • Problem with fetching Map object from ObjectInputStream

    Hi, please can you help me with the following...I've never seen this before (with my limited experience of JDK1.5)
    ObjectInputStream is = new ObjectInputStream(new FileInputStream(store));
    Map<Integer, Report> readObject = (Map<Integer, Report>) is.readObject();This code gives me a warning...
    Type safety: The cast from Object to Map<Integer,Report> is actually checking against the erased type Map
    How can I get rid of this warning?

         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream( baos );
         List<String> list = new LinkedList<String>();
         list.add( "one" );
         list.add( "two" );
         oos.writeObject( list );
         oos.flush(); oos.close();
         ObjectInputStream ois = new ObjectInputStream
             ( new ByteArrayInputStream( baos.toByteArray() ) );
         List<String> list2 = (List<String>)ois.readObject();Give me 1 compile time error (Test.java:109: warning: [unchecked] unchecked cast), and no runtime errors.
    Removing the <String> from "list" add some more [uncheked], but still runs fine (no runtime warning). Adding a none-String only causes a problem when I try to "get" it. (class cast).
    When do you get this warning?

  • PLEASE help with my add function

    I am very new to Java. Sigh, All i want to do is allow the user to input the details for the patient and then add the new patient to a priority queue.
    However, i get the error message "cannot find symbol" , "variable testPq" at the following line... "testPq.add(x, x.priority, x.id);"
    The relevant bit of the code is as follows, if anyone can help it would be much appreciated.......
    import java.io.*;
    import java.util.*;
    class Clinic {
         int ctime;
         public static void main(String[] args) throws PqException {     
                   int age,
                        timearv,
                        choice,
                        id,
                        tl;
                   String name;
                   Scanner input = new Scanner( System.in );
              Clinic c = new Clinic();
                   System.out.println("Create patient's ID");
                   id = input.nextInt();
                   System.out.println("Add patient's age");
                   age = input.nextInt();
                   System.out.println("Add patient's trauma level");
                   tl = input.nextInt();
                   System.out.println("Time of arrival?");
                   timearv = input.nextInt();
                   System.out.println("Add patient's Name");
                   name = input.nextLine();
                   Patient x = new Patient(id, name, age, tl, timearv);
                   System.out.println(x);
    //THIS IS WHERE THE PROBLEM ARISES               
    System.out.println("Add patient to queue?");
                   choice = input.nextInt();
                        if (choice==1){
                        testPq.add(x, x.priority, x.id);
                        else {
                             System.out.println("Do nada");
         }//end of main
         Clinic(){
              //create priority queue that will hold 10 objects     
         Pq testPq  = new Pq(10);
         }//end of constructor
    }//end of clinic
         class Pq {
         static private int maxQueue = 100; // max possible size of queue
      private int size,       // size as created by used
                   nq,         // current number of objects in queue
                  selector;   // index of selected object
      private PObject q [] = new PObject [maxQueue];
      // Constructor for the Priority queue *****************************
      public Pq(int m) {
        if (m <= maxQueue) size = m;
         else { size = maxQueue;
                System.out.println("Warning: size set to max =100\n");
        nq =0;
      } // of Pq constructor
         //add
         public void add(Object x, int priority, int id) throws PqException {
        if (!(this.isFull())) {
          PObject y = new PObject(x,priority,id);
          q[nq] = y;
           selector = nq; // default setting for the selector
           nq++;
         else throw new PqException("queue is full");
      } // of add
    }//end of Pq class
    class PObject{
      /* An ancilliary class used to 'wrap up ' objects in the queue and
         so enable a priority and id to be associated with each one. */
      Object obj;
      int priority;
      int id;
      // Constructor method
      PObject(Object x, int p, int s) {
        obj = x;  priority = p; id = s;
      } // of Priority Object constructor
    } // of class PObject
    class PqException extends Exception {
      PqException (String s) {super(s);}
    } // of class PqException ************

    2. where does that "isFull" method come from ?His class implements the IOsmosis interface.don't get me started on the whole
    "I-prefix-for-interfaces-convention" thing ! Class
    names should start with a "C" !i omitted this from the code previously, to save on space....
    i have declared the queue in the clinic constructor because a menu driven class when run will create a new clinic, when this new clinic is created it will need to have a Pq in it....everything works fine until i add the line "testPq.add(x, x.priority, x.id);" PLEASE REMEMBER I AM VERY NEW TO ALL OF THIS.....
    public boolean isEmpty ()  {return nq == 0;}
         public boolean isFull ()   {return nq == size;}
         public int length()        {return nq;}     

Maybe you are looking for