SCRIPT5022: The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

Hi,
i have a simple javascript which throws me the following error:
SCRIPT5022: The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
I am using it under O365 inside an Content Editor WebPart. I have a list called "myTestList" with several items and one column called "points". I want to retrieve only the items which
i have created and sum the points to show it inside a div. This is my code.
<div id="myPoints" style="font-size: 50px;">0​</div>
<script language="javascript" type="text/javascript">
SP.SOD.executeOrDelayUntilScriptLoaded(retrieveMyItems, "sp.js");
function retrieveMyItems() {
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('myTestList');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml("<View><Query><Where><Eq><FieldRef Name='Author' /><Value Type='Integer'><UserID /></Value></Eq></Where></Query></View>");
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem, 'Include(points)');
clientContext.executeQueryAsync(Function.createDelegate(this, this.onMyItemsQuerySucceeded), Function.createDelegate(this, this.onMyItemsQueryFailed));
function onMyItemsQuerySucceeded(sender, args) {
var listItemInfo = 0;
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
listItemInfo = listItemInfo + parseInt(oListItem.get_item('points'));
var div = document.getElementById("myPoints");
div.innerHTML = listItemInfo;
function onMyItemsQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
</script>​
Whats wrong here?
Best Regards
Bog
Developers Field Notes | www.bog1.de

Solved!
The set_viewXml line must be:
camlQuery.set_viewXml("<View><Query><Where><Eq><FieldRef Name='Author' /><Value Type='Integer'><UserID Type='Integer'/></Value></Eq></Query></Where></View>");
Best Regards
Bog
Developers Field Notes | www.bog1.de

Similar Messages

  • The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested

    hi sir,
    I have try to update task assignments using csom model.
     erro message ::The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested
     foreach (PublishedAssignment assignItem in item.Assignments)
                                Guid id =assignItem.Id;
                               cc.Load(assignItem, a => a.Resource,a=>a.PercentWorkComplete);
                               cc.ExecuteQuery();
                               EnterpriseResource er = cc.EnterpriseResources.GetByGuid(assignItem.Resource.Id);
                               cc.Load(item.Assignments,c=>c.Where(uu=>uu.Id==id).IncludeWithDefaultProperties( l=> l.Task.Assignments,l=>l.Work));
                               cc.ExecuteQuery();
                               er.Assignments.Single(ll => ll.Id == id).Work = "9";
                               cc.Load(er);
                               cc.ExecuteQuery();
                               StatusAssignmentCollection sac = er.Assignments;
                               sac.Update();
                               sac.SubmitAllStatusUpdates("hello vijay");
    vijay

    Hi Vijay,
    You didn't load the 'er.Assignments' collection.
    Make sure it's loaded and it should work
    Hope this helps

  • Error during project server 2013 The property or field 'StartDate' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

    Hi sir,
    when I have try to fetch the value of project start date and finish date and some other field value , I have recived error message like The property or field 'StartDate' has not been initialized. It has not been requested or the request has not been
    executed. It may need to be explicitly requested.
    I have used client context for project server 2013.
    I have also load and execute query.but fail to resolve it Please suggest me and provide solution.
    vijay

    Hi,    
    If you use the Include<TSource> Method in the Load method, we will retrieve only the ids of items in this query, so
    the listItems.ListItemCollectionPosition will not be initialized.
    You can use the <ViewFields> tag in CAML Query to specify the field values to return with each item instead.
    Best regards
    Patrick Liang
    TechNet Community Support

  • Csom error The property or field 'LoginName' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

    Hi sir,
    When I have get the value of project owner the error is occured
    The property or field 'LoginName' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
    vijay

    Hi Vijay,
    The owner details are not loaded by default when you load all projects.
    You have to make sure the details of the project owner are loaded before you can access them:
    foreach (PublishedProject pubProj in projContext.Projects){
    User owner = pubProj.Owner;
    projContext.Load(owner);
    projContext.ExecuteQuery();
    Console.WriteLine(owner.LoginName);

  • The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

    After installed February
    2015 CU for SharePoint 2013 appear error when click on 'Shared
    With' in list item.
    The screenshots see here: 1 and 2
    Is this a bug?

    Yes, this is a known bug introduced with the November 2014 CU. There is no solution as of yet.
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • Adding custom webpart throwing Javascript error -The collection has not been initialized.

    Hi,
    I created a Javascript CSOM visual webpart and added to page. In the IE developer tools console, I am getting an error as below:
    "SCRIPT5022: The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
    SP.Runtime.js, line 2 character 35853".
    My code is as below:
    <script type="text/javascript" src="../../_layouts/15/MicrosoftAjax.js"></script>
    <script type="text/javascript" src="../../_layouts/15/SP.Runtime.js"></script>
    <script type="text/javascript" src="../_layouts/15/sp.js"></script>
    <script type="text/javascript" src="../_layouts/15/sp.ui.controls.js"></script>
    <script type="text/javascript" src="/_layouts/15/test/Scripts/jquery-1.8.2.js"></script>
    <script type="text/javascript" src="/_layouts/15/test/Scripts/Rotator.js"></script>
    <script type="text/javascript" src="/_layouts/15/test/Scripts/bjqs-1.3.js"></script>
    <link rel="stylesheet" type="text/css" href="/_layouts/15/test/CSS/bjqs.css" />
    <SharePoint:FormDigest ID="FormDigestRotator" runat="server">
    </SharePoint:FormDigest>
    <div id="banner-fade">
    <ul id="carousel" class="bjqs">
    </ul>
    </div>
    // In Rotator.js
    $(document).ready(function () {
    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', loadConfigData);
    function loadConfigData() {
    var clientcontext = new SP.ClientContext.get_current();
    var oweb = clientcontext.get_site().get_rootWeb();
    var olist = oweb.get_lists().getByTitle("LibName");
    var configquery = SP.CamlQuery.createAllItemsQuery();
    Allpictures = olist.getItems(configquery);
    clientcontext.load(Allpictures, 'Include(Title,ImgSubURL)');
    clientcontext.executeQueryAsync(Function.createDelegate(this, this.Configsuccess), Function.createDelegate(this, this.Configfailed));
    How to fix this javascript error? Due to this, the "Check-in" option is not working.
    Update: i believe the error is with "executeQueryAsync". How to fix this?
    Thanks

    Hi,
    I suggest you create a simple demo first, once it works, then add other customization into your project gradually. It will be easier to composite the correct code.
    Please apply the code below in your project for a try:
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
    _spBodyOnLoadFunctionNames.push("callCSOM");
    var clientContext;
    var website;
    var str="";
    // Make sure the SharePoint script file 'sp.js' is loaded before your
    // code runs.
    function callCSOM()
    //alert("call");
    $("#Button1").click(function()
    ExecuteOrDelayUntilScriptLoaded(sharePointReady, "sp.js");
    // Create an instance of the current context.
    function sharePointReady() {
    clientContext = SP.ClientContext.get_current();
    website = clientContext.get_web();
    clientContext.load(website);
    clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
    function onRequestSucceeded() {
    str="website.get_title(): "+website.get_title();
    alert(str);
    function onRequestFailed(sender, args) {
    alert('Error: ' + args.get_message());
    </script>
    <input id="Button1" type="button" value="Run Code"/>
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Patrick Liang
    TechNet Community Support

  • "The property or field has not been initialized" Error, when debbuging app

    Hello,
    I'm  following the instructions of a dev book but I get the following error message when debugging the app.
    "The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested."
    The code:
    var collListItems;
    $(document).ready(function () {
    getConfigValues();
    function getConfigValues() {
    var context = SP.ClientContext.get_current();
    var configList = context.get_web().get_lists().getByTitle('Configuration Values');
    var camlQuery = new SP.CamlQuery();
    collListItems = configList.getItems(camlQuery);
    context.load(collListItems);
    context.executeQueryAsync(onGetConfigValuesSuccess, onGetConfigValuesFail);
    function onGetConfigValuesSuccess() {
    var OrgLogoUrl;
    var OrgName;
    var listItemEnumerator = collListItems.getEnumerator();
    while (listItemEnumerator.moveNext()) {
    var oListItem = listItemEnumerator.get_current();
    var current = oListItem.get_item('Title');
    switch (current) {
    case 'OrganizationName':
    OrgName = oListItem.get_item('Value');
    break;
    case 'OrganizationLogoUrl':
    OrgLogoUrl = oListItem.get_item('Value');
    break;
    if (OrgName && OrgName.length > 0) {
    $('#DeltaPlaceHolderPageTitleInTitleArea').html(OrgName);
    $('.ms-siteicon-img').attr('title', OrgName);
    if (OrgLogoUrl && OrgLogoUrl.length > 0)
    $('.ms-siteicon-img').attr('src', OrgLogoUrl);
    else
    $('.ms-siteicon-img').attr('src', '../Images/AppLogo.png');
    function onGetConfigValuesFail(sender, args) {
    alert('Failed to get the Configuration Values. Error:' + args.get_message());
    What it have to do is to replace the Title and Site logo, using the "Title" and "Value" fields of the "Configuration Values" list.
    My dev environment: SharePoint online, Azure, VS2013 Ultimate (trial)
    I've tried to reach the author of the book but it's being 4 days and no response, maybe somebody here can help me.
    Thanks in advance.
    Jimmy

    Jaydeep, I don't get the values, see the HTML code below.
    <%@ Page Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" MasterPageFile="~masterurl/default.master" Language="C#" %>
    <%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%-- The markup and script in the following Content element will be placed in the <head> of the page --%>
    <asp:Content ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.js"></script>
    <!-- Add your CSS styles to the following file -->
    <link rel="Stylesheet" type="text/css" href="../Content/App.css" />
    <!-- Add your JavaScript to the following file -->
    <script type="text/javascript" src="../Scripts/App.js"></script>
    </asp:Content>
    <%-- The markup in the following Content element will be placed in the TitleArea of the page --%>
    <asp:Content ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server">
    KA Online Klas
    </asp:Content>
    <%-- The markup and script in the following Content element will be placed in the <body> of the page --%>
    <asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <div id="menu">
    <ul>
    <li><a href="../Lists/Configuration Values">Site Configuration</a></li>
    <li><a href="../Lists/Site Assets">Site Assets</a></li>
    </ul>
    </div>
    </asp:Content>

  • The license key library has not been initialized yet." message.

    Hello you ABAP guys knows everything (amost).
    I am facing problems with licensing the ECC6.0 server. I got a file via e-mail. when trying to install it via "new license" I browse for file sent to me by SAP.
    When trying to install it I get the "The license key library has not been initialized yet." message.
    I tried to find relevant note. The most close note is note 982056  saying to look in trace file (which I do not find).
    i adjusted sec/libsapsecu , ssf/ssfapi_lib and ssf/name parameters and restarted the server but the problem persisted.
    What to do?

    Hi ! I am having the same problem .
    I wanted to extend the demo license of the NSP the first time. When trying to import the license file nsp.txt under transaction SLICENSE, I am getting the message that the license key library has not been initialized yet.
    Could anyone please help ?

  • TS1410 MY LAP TOP DOES NOT RECOGNIZE MY IPOD. AFTER ABOUT 20 MINUTES I GET A MESSAGE THAT SAYS MY IPOD HAS BEEN CORRUPTED AND NEEDS TO BE RESTORED. ALSO THE IPOD ITSELF HAS FROZEN AND CAN NOT BE TURNED OFF OR RE-SET BUY HOLDING THE MIDDLE BUTTON.

    MY LAPTOP DIES NOT RECOGNIZE MY IPOD. AFTER ABOUT 20 MINUTES I GET A MESSAGE THAT SAYS MY IPOD HAS BEEN CORRUPTED AND NEEDS TO BE RESTORED. ALSO AFTER THE IPOD HAS BEEN CONNECTED TO THE COMPUTER THE IPOD WILL FREEZE. I AM ONLY ABLE TO USE IT AFTER THE BATTERY HAS RUN OUT. WHAT COULD BE CAUSING THESE PROBLEMS AND HOW DO I RESTORE MY IPOD!!!!!

    Hey gwscrt,
    Since iTunes directed to you to restore your iPod, I'd check out the following article that goes over the steps to do so:
    Restoring iPod to factory settings
    http://support.apple.com/kb/ht1339
    I would read the document in full, but here are the applicable steps for you:
    How to restore iPod
    Verify that you have an active Internet connection, because you may need to download new versions of the iTunes and iPod Software.
    Download and install the latest version of iTunes if necessary.
    Open iTunes. Connect your iPod to your computer using the USB or FireWire cable that came with your iPod.
    After a few moments, your iPod will appear in the Source panel in iTunes.
    Select your iPod in the Source panel. You will see information about your iPod appear in the Summary tab of the main iTunes window.
    Click Restore.
    If you are using a Mac, you will be asked to enter an administrator’s name and password.
    A progress bar will appear on the computer screen, indicating that stage one of the restore process has begun. When this stage is done, iTunes will present one of two messages with instructions specific to the iPod model you are restoring.
    Disconnect iPod and connect it to iPod Power Adapter (typically applies to older iPod models).
    Leave iPod connected to computer to complete restore (typically applies newer iPod models).
    During stage two of the restore process, the iPod displays an Apple logo as well as a progress bar at the bottom of the display. It is critical that the iPod remain connected to the computer or iPod power adapter during this stage.
    Note: The progress bar may be difficult to see, because the backlight on the iPod display may be off.
    After stage two of the restore process is complete, the iTunes Setup Assistant window will appear. It will ask you to name your iPod and choose your syncing preferences, as it did when you connected your iPod for the first time.
    Have a good one,
    David

  • The collection you specified does not exists or is not registered with the ColdFusion Search Service.

    While upgrading to CF7 from CF5, I am creating the new collections from Cf Admin. After creating, I indexed it from cf admin and then trying to search for the documents in that collection, and i am getting the following error. This was working yesterday. I have cheched the logs etc and nothing seems helpful in discovering what the issue is.
    Document count is 11,745 and the size is 25,948 kb, which is not too much for a collection. I have tried to restart Cold Fusion Search Services and then ColdFusion Application services, but all in vain.
    Any help on this would be greatly appreciated.
    Detail
    The collection you specified does not exists or is not registered with the ColdFusion Search Service.
    Message
    The collection rc_collectiom does not exist.
    StackTrace
    coldfusion.tagext.search.CollectionDoesNotExistException: The collection rc_collectiom does not exist. at coldfusion.tagext.search.SearchTag.verifyLocale(SearchTag.java:819) at coldfusion.tagext.search.SearchTag.doSearch(SearchTag.java:200) at coldfusion.tagext.search.SearchTag.doStartTag(SearchTag.java:159) at coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:1915) at cfeFull2dText2dReDirect2ecfm511389924.runPage(C:\Inetpub\wwwroot\External\FullText\eFull- Text-ReDirect.cfm:43) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349) at coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:1915) at cfApplication2ecfc179940445$funcONREQUEST.runFunction(C:\Inetpub\wwwroot\External\Applica tion.cfc:114) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:344) at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:290) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:254) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:56) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:207) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:169) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:194) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:146) at coldfusion.runtime.AppEventInvoker.invoke(AppEventInvoker.java:72) at coldfusion.runtime.AppEventInvoker.onRequest(AppEventInvoker.java:178) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:215) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:51) at coldfusion.filter.PathFilter.invoke(PathFilter.java:86) at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:69) at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:52) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:2 8) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:115) at coldfusion.CfmServlet.service(CfmServlet.java:107) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78) at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257) at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541) at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204) at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:318) at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:426) at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:264) at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

    So at last I figured this out myself and found a temporary resolution for this kind of problem. Majority of the times try creating the Collection through Cfcollection tag and then index it using cfindex tag, rather than performing these operations from the Cold Fusion 7 administrator.
    The only reason I can think of which might have caused the issue is – I have thousands of documents in the collection which I indexed. So while indexing the page gets expired. So I tried again to index it. This time the collection got indexed fairly quickly and I got the response that the collection has been indexed successfully. So for the first time when I tried to index the collection, there might be some piece of code, which did not register the collection properly and hence giving this error.
    When I did the same function using the code, with exactly same set of documents, it did not throw any error, even when I executed it for the first time. So the collection indexed properly.
    I am not claiming that technically this theory is correct, but this seems to be the problem.
    If someone knows technically what has happened at the back, please share it. For the time being, this is the fix – if you experience any problem in creating/indexing collections through cfadmin in CF7, do it thorough code.

  • Variable theContract might not have been initialized

    import java.text.*;
    import java.util.Date;
    import javax.swing.*;
    import java.lang.*;
    class Employer {
         private String name = "";
         public Employer(String na) {
              name=na;
         public Employer() {
              this("");
         public void setName(String na) {
              name=na;
         public String getName() {
              return name;
    class Maid {
         private String name = "";
         public Maid(String na) {
              name=na;
         public Maid() {
              this("");
         public void setName(String na) {
              name=na;
         public String getName() {
              return name;
    class MaidAgency {
         private String registrationNo = "";
         public MaidAgency(String no) {
              registrationNo=no;
         public MaidAgency() {
              this("");
         public void setRegistration(String reg) {
              registrationNo=reg;
         public String getRegistration() {
              return registrationNo;
    abstract class Contract {
         private String contractID = "";
         private String contractDate ="";
         private Employer employer;
         private Maid maid ;
         private MaidAgency agency;
         public Contract(String id, String date, Employer em , Maid ma, MaidAgency m) {
              contractID=id;
              contractDate=date;
              employer=em;
              maid=ma;
              agency=m;
         public Contract() {
              this("","",null,null,null);
         public void setEmployer(Employer em) {
              employer=em;
         public Employer getEmployer() {
              return employer;
         public void setMaid(Maid ma) {
              maid=ma;
         public Maid getMaid() {
              return maid;
         public void setAgency(MaidAgency m) {
              agency=m;
         public MaidAgency getAgency() {
              return agency;
         public void setID(String id) {
              contractID=id;
         public String getID() {
              return contractID;
         public void setDate(String date) {
              contractDate=date;
         public String getDate() {
              return contractDate;
         public abstract double commission();
    class NewMaid extends Contract {
         private double airFare = 0;
         public NewMaid(String id, String date, Employer em , Maid ma, MaidAgency m, double fare) {
              super(id, date, em, ma, m);
              airFare=fare;
         public NewMaid() {
              this("","",null,null,null,0);
         public void setFare(double fare) {
              airFare=fare;
         public double getFare() {
              return airFare;
         public double commission() {
              return 900;
    class TransferMaid extends Contract {
         private double commissionRate = 0;
         public TransferMaid(String id, String date, Employer em , Maid ma, MaidAgency m, double comm) {
              super(id, date, em, ma, m);
              commissionRate=comm;
         public TransferMaid() {
              this("","",null,null,null,0);
         public void setCommission(double comm) {
              commissionRate=comm;
         public double getCommission() {
              return commissionRate;
         public double commission() {
              return 350;
    public class Try {
         public static void main(String[] args) {
              String theEmployerName;
              String theMaidName;
              String theRegistrationNo;
              String theContractID;
              String theContractDate;
              String contractType;
              double theCommisionRate;
              double theAirFare;
              Employer theEmployer = new Employer();
              Maid theMaid = new Maid();
              MaidAgency theAgency=new MaidAgency();
              Contract theContract;
              theEmployerName=Console.readString("Employer Name : ");
              theEmployer.setName(theEmployerName);
              theMaidName=Console.readString("Maid Name : ");
              theMaid.setName(theMaidName);
              theRegistrationNo=Console.readString("Registration No. : ");
              theAgency.setRegistration(theRegistrationNo);
              theContractID=Console.readString("Contract ID :");
              theContractDate=Console.readString("Contract Date :");
              contractType= Console.readString("Contract Type (<N>ew Maid / <T>ransfer Maid) : ");
              while (!contractType.equals("N") && !contractType.equals("T")) {
                   JOptionPane.showMessageDialog(null,"Wrong Contract Type!");
                   contractType= Console.readString("Contract Type (<N>ew Maid / <T>ransfer Maid) : ");
              if (contractType.equals("N")) {
                   theAirFare=Console.readDouble("Air Fare : ");
                   theContract=new NewMaid(theContractID,theContractDate,theEmployer,theMaid,theAgency,theAirFare);
              else {
                   if (contractType.equals("T")) {
                        theCommisionRate=Console.readDouble("Commission Rate : ");
                        theContract=new TransferMaid(theContractID,theContractDate,theEmployer,theMaid,theAgency,theCommisionRate);
              System.out.println("Contract ID = " + theContract.getID());  // error
    }I think theContract has been initialized after i choose N or T, but it's not???
    aww..my head's spinning.
    help!

    By the way, my name is Monica. Ron is my last
    name. No problem, though--it's a common mistake
    here. :)That reminds me about a funny thing. I was driving from Miami to Canada a couple of years ago, and each night I had to try to find a hotel and check in. Most people didn't know how to write my last name so I usually just gave them my (Swedish) drivers license so that they would be able to fill out the forms. I usually didn't read what they wrote when I checked in, but used to take a look at the papers when I checked out. One of the hotels had checked me in as:
    First name: K�rkort
    Last name: Sverige
    which means:
    First name: Drivers license
    Last name: Sweden
    Kaj Bjurman

  • Redesigning the Collections Framework

    Hi!
    I'm sort of an experienced Java programmer, in the sense that I program regularly in Java. However, I am not experienced enough to understand the small design specifics of the Collections Framework (or other parts of Javas standard library).
    There's been a number of minor things that bugged me about the framework, and all these minor things added up to a big annoyance, after which I've decided to (try to) design and implement my own framework.
    The thing is however, that since I don't understand many design specifics about the Collection Framework and the individual collection implementations, I risk coming up short with my own.
    (And if you are still reading this, then I thank you for your time, because already now I know that this entry is going to be long. : ) )
    Since I'm doing my Collection framework nearly from scratch, I don't have to worry too much about the issue of backwards compatibility (altough I should consider making some parts similar to the collection framework as it is today, and provide a wrapper that implements the original collection interfaces).
    I also have certain options of optimizing several of the collections, but then again, there may be very specific design issues concerning performance and usability that the developers of the framework (or other more experienced Java progammers) knew about, that I don't know.
    So I'm going to share all of my thoughts here. I hope this will start an interesting discussion : )
    (I'm also not going to make a fuss about the source code of my progress. I will happily share it with anyone who is interested. It is probably even neccessary in order for others to understand how I've intended to solve my annoyances (or understand what these annoyances were in the first place). ).
    (I've read the "Java Collections API Design FAQ", btw).
    Below, I'm going to go through all of the things that I've thought about, and what I've decided to do.
    1.
    The Collections class is a class that consists only of static utility methods.
    Several of them return wrapper classes. However the majority of them work on collections implementing the List interface.
    So why weren't they built into the List interface (same goes for methods working only with the Collection interface only, etc)? Several of them can even be implemented more efficiently. For example calling rotate for a LinkedList.
    If the LinkedList is circular, using a sentry node connecting the head and tail, rotate is done simply by relocating the sentry node (rotating with one element would require one single operation). The Collections class makes several calls to the reverse method instead (because it lacks access to the internal workings of a LinkedList).
    If it were done this way, the Collections class would be much smaller, and contain mostly methods that return wrapped classes.
    After thinking about it a while, I think I can answer this question myself. The List interface would become rather bloated, and would force an implementation of methods that the user may not need.
    At any rate, I intend to try to do some sort of clean-up. Exactly how, is something I'm still thinking about. Maybe two versions of List interfaces (one "light", and the other advanced), or maybe making the internal fields package private and generally more accessible to other package members, so that methods in other classes can do some optimizations with the additional information.
    2.
    At one point, I realized that the PriorityQueue didn't support increase\decrease key operations. Of course, elements would need to know where in the backing data structure it was located, and this is implementation specific. However, I was rather dissapointed that this wasn't supported somehow, so i figured out a way to support this anyway, and implemented it.
    Basically, I've wrapped the elements in a class that contains this info, and if the element would want to increase its key, it would call a method on the wrapping class it was contained in. It worked fine.
    It may cause some overhead, but at least I don't have to re-implement such a datastructure and fiddle around so much with the element-classes just because I want to try something with a PriorityQueue.
    I can do the same thing to implement a reusable BinomialHeap, FibonacciHeap, and other datastructures, that usually require that the elements contain some implementation-specific fields and methods.
    And this would all become part of the framework.
    3.
    This one is difficult ot explain.
    It basically revolves around the first question in the "Java Collections API Design FAQ".
    It has always bothered me that the Collection interface contained methods, that "maybe" would be implemented.
    To me it didn't make sense. The Collection should only contain methods that are general for all Collections, such as the contains method. All methods that request, and manipulate the Collection, belonged in other interfaces.
    However, I also realized that the whole smart thing about the current Collection interface, is that you can transfer elements from one Collection to another, without needing to know what type of Collection you were transferring from\to.
    But I still felt it violated "something" out there, even if it was in the name of convenience. If this convenience was to be provided, it should be done by making a separate wrapper interface with the purpose of grouping the various Collection types together.
    If you don't know what I'm trying to say then you might have to see the interfaces I've made.
    And while I as at it, I also fiddled with the various method names.
    For example, add( int index, E element), I felt it should be insert( int index, E element). This type of minor things caused a lot of confusion for me back then, so I cared enough about this to change it to somthing I thought more appropriate. But I have no idea how appropriate my approach may seem to others. : )
    4.
    I see an iterator as something that iterates through a collection, and nothing else.
    Therefor, it bothered me that the Iterator interface had an optional remove method.
    I myself have never needed it, so maybe I just don't know how to appreciate it. How much is it used? If its heavily used, I guess I'm going to have to include it somehow.
    5.
    A LinkedList doesnt' support random access. But true random access is when you access randomly relative to the first index.
    Iterating from the first to the last with a for statement isn't really random access, but it still causes bad performance in the current LinkedList implementation. One would have to use the ListIterator to achieve this.
    But even here, if you want a ListIterator that starts in the middle of the list, you still need to traverse the list to reach that point.
    So I've come up with LinkedList that remembers the last accessed element using the basic methods get, set, remove etc, and can use it to access elements relatively from it.
    Basically, there is now an special interal "ListIterator" that is used to access elements when the basic methods are used. This gives way for several improvements (although that may depend how you look at it).
    It introduces some overhead in the form of if-else statemenets, but otherwise, I'm hoping that it will generally outperform the current LinkedList class (when using lists with a large nr of elements).
    6.
    I've also played around with the ArrayList class.
    I've implemented it in a way, that is something like a random-access Deque. This has made it possible to improvement certain methods, like inserting an element\Collection at some index.
    Instead of always shifting subsequent element to the right, elements can be shifted left as well. That means that inserting at index 0 only requires a single operation, instead of k * the length of the list.
    Again, this intrduces some overhead with if-else statements, but is still better in many cases (again, the List must be large for this to pay off).
    7.
    I'm also trying to do a hybrid between an ArrayList and a Linked list, hopefully allowing mostly constant insertion, but constant true random access as well. It requires more than twice the memory, since it is backed by both an ArrayList and a LinkedList.
    The overhead introduced , and the fact that worst case random access is no better than that of a pure LinkedList (which occurs when elelements are inserted at the same index many times, and you then try to access these elements), may make this class infeasible.
    It was mostly the first three points that pushed my over the edge, and made me throw myself at this project.
    You're free to comment as much as you like.
    If no real discussion starts, thats ok.
    Its not like I'm not having fun with this thing on my own : )
    I've started from scratch several times because of design problems discovered too late, so if you request to see some of the source code, it is still in the works and I would have to scurry off and add a lot of java-comments as well, to explain code.
    Great. Thanks!

    This sort of reply has great value : )
    Some of them show me that I need to take some other things into consideration. Some of them however, aren't resolved yet, some because I'm probably misunderstanding some of your arguments.
    Here goes:
    1.
    a)
    Are you saying that they're were made static, and therefor were implemented in a utility class? Isn't it the other way around? Suppose that I did put them into the List interface, that would mean they don't need to be static anymore, right?
    b)
    A bloated List interface is a problem. Many of them will however have a default not-so-alwyas-efficient implementation in a abstract base class.
    Many of the list-algorithms dump sequential lists in an array, execute the algorithm, and dump the finished list back into a sequential list.
    I believe that there are several of them where one of the "dumps" can be avoided.
    And even if other algorithms would effectively just be moved around, it wouldn't neccesarily be in the name of performance (some of them cannot really be done better), but in the name of consistency\convenience.
    Regarding convenience, I'm getting the message that some may think it more convenient to have these "extra" methods grouped in a utility class. That can be arranged.
    But when it comes to consistency with method names (which conacerns usability as well), I felt it is something else entirely.
    For example take the two methods fill and replaceAll in the Collections class. They both set specific elements (or all of them) to some value. So they're both related to the set method, but use method names that are very distinguished. For me it make sense to have a method called setAll(...), and overload it. And since the List interface has a set method, I would very much like to group all these related methods together.
    Can you follow my idea?
    And well, the Collections class would become smaller. If you ask me, it's rather bloated right now, and supports a huge mixed bag of related and unrelated utitlity methods. If we should take this to the extreme, then The Collections class and the Arrays class should be merged.
    No, right? That would be hell : )
    2,
    At a first glance, your route might do the trick. But there's several things here that aren't right
    a)
    In order to delete an object, you need to know where it is. The only remove method supported by PriorityQueue actually does a linear search. Increase and decrease operations are supposed to be log(n). Doing a linear search would ruin that.
    You need a method something like removeAt( int i), where i would be the index in the backing array (assuming you're using an array). The elemeny itself would need to know that int, meaning that it needs an internal int field, even though this field only is required due to the internal workings of PriorityQueue. Every time you want to insert some element, you need to add a field, that really has nothing to with that element from an object-oriented view.
    b)
    Even if you had such a remove method, using it to increase\decrease key would use up to twice the operations neccesary.
    Increasing a key, for example, only requires you to float the element up the heap. You don't need to remove it first, which would require an additional log(n) operations.
    3.
    I've read the link before, and I agree with them. But I feel that there are other ways to avoid an insane nr of interfaces. I also think I know why I arrive at other design choices.
    The Collection interface as it is now, is smart because it can covers a wide range of collection types with add and remove methods. This is useful because you can exchange elements between collections without knowing the type of the collection.
    The drawback is of course that not all collection are, e.g modifiable.
    What I think the problem is, is that the Collection interface is trying to be two things at once.
    On one side, it wants to be the base interface. But on the other side, it wants to cast a wide net over all the collection types.
    So what I've done is make a Collection interface that is infact a true base interface, only supporting methods that all collection types have in common.
    Then I have a separate interface that tries to support methods for exchanging elements between collections of unknown type.
    There isn't neccesarily any performance benefit (actually, it may even introduces some overhead), but in certainly is easier to grasp, for me at least, since it is more logically grouped.
    I know, that I'm basically challenging the design choices of Java programmers that have much more experience than me. Hell, they probably already even have considered and rejected what I'm considering now. In that case, I defend myself by mentioning that it isn't described as a possiblity in the FAQ : )
    4.
    This point is actually related to point 3., becausue if I want the Collection interface to only support common methods, then I can't have an Iterator with a remove method.
    But okay....I need to support it somehow. No way around it .
    5. 6. & 7.
    The message I'm getting here, is that if I implement these changes to LinkedList and ArrayList, then they aren't really LinkedList and ArrayList anymore.
    And finally, why do that, when I'm going to do a class that (hopefully) can simulate both anyway?
    I hadn't thought of the names as being the problem.
    My line of thought was, that okay, you have this arraylist that performs lousy insertion and removal, and so you avoid it.
    But occasionally, you need it (don't ask me how often this type of situation arises. Rarely?), and so you would appreciate it if performed "ok". It would still be linear, but would often perform much better (in extreme cases it would be in constant time).
    But these improvements would almost certainly change the way one would use LinkedList and ArrayList, and I guess that requires different names for them.
    Great input. That I wouldn't have thought of. Thanks.
    There is however some comments I should comment:
    "And what happens if something is suibsequently inserted or removed between that element and the one you want?"
    Then it would perform just like one would expect from a LinkedList. However if that index were closer to the last indexed position, it would be faster. As it is now, LinkedList only chooses either the first index or the last to start the traversal from.
    If you're working with a small number of elements, then this is definitely not worth it.
    "It sounds to me like this (the hybrid list) is what you really want and indeed all you really need."
    You may be right. I felt that since the hybrid list would use twice as much memory, it would not always be the best choice.
    I going to think about that one. Thanks.

  • Due to impossibility to upgrade the i tunes version installated on my computer, i decided to remove it because i had needed to sincronize my new iphone 4s. But when i try to install the i tunes newer version the installation hangs on the collecting produc

    Hi everybody.
    Im still hanged by the same problem i reorted in the message listed below ten days ago.
    Is there anyone can hep me ?
    Due to impossibility to upgrade the i tunes version installated on my computer, i decided to remove it because i had needed to sincronize my new iphone 4s. But when i try to install the i tunes newer version the installation hangs on the collecting product information and only after a long wait i receive the following message :
    An error occurred during the installation of assembly ‘Microsoft.VC80.CRT.type=”win32”,version=”8.0.50727.6195”,publicKey Token=”1fc8b3b9a1e18e3b”,processorArchitecture=”x86”.Please refer to Help and Support for more information. HRESULT: 0x800736B3

    What version of Windows are you using? This is not a problem with iTunes. It may have to do with an issue of the compatibility of a newer version of iTunes with an older Windows system/older hardware.
    What do you want to synchronize? If you were previously using iCloud you should be able to restore most of your oringinal content onto your new phone via was was last synched with the iCloud on your previous phone/device.

  • I am getting a pop up window that says "The Calendar calendar does not support events" You can't add events to the Calendar calendar

    I recently did some HD clean up and I'm plagued by this window. I can get it to go away briefly if I restart the computer but it always comes back.
    Weird!

    Hi wcb82,
    If you keep getting these messages, you may need to delete the subscription to that calendar. You may find the following article useful:
    Cal 5.x: Delete a calendar or reminder list
    http://support.apple.com/kb/PH4720
    Regards,
    - Brenden

  • I am running 4 ipod classica through one computer and one itunes account/profile.  The ipods belong to me, husband and 2 kids.  How can the kids now get their own accounts but keep the stuff I have already downloaded for them?  They have their own laptops

    I am currently running 4 ipod classics through my own account/profile on itunes.  They belong to me, my husband and 2 kids. 
    The kids are getting older now and have their own laptops.  I would like them to have their own itunes accounts as they will be away from home much of the time and will want to make their own puchases. 
    How can I set them up so that they are independent from my account, but not lose the content that I have downloaded for them over the years?  (A lot of content).

    You and your husband can share a store account and still have seperate iCloud accounts for your contacts, bookmarks and stuff like that.  Click here for instructions to make an apple account without entering a credit card.  Make sure you use a different email address for each apple account. 
    Set up your iPhone/iPad whatever using the new account for iCloud.  Then go into settings/store and sign in with your purchasing account, you may need to sign out of the other account.  To the best of my knowledge, your household is allowed to share purchased legally, someone please correct me if I'm wrong.
    Once you each have your own devices set to your own accounts you can set them to backup to that account and it will keep all your contacts seperate.

Maybe you are looking for

  • Three database or multiple Database adapters in One Composite

    Hi All, I have below requirement: 1) I have two applications A and B.I am integrating them with SOA.I have to recieve data from A and update that data into application B for different Device IDs. I am using one database adapter(insert operation) to r

  • Marking green screen video to know where to place background images

    My students want to create short green screen movies using a number of background photos that will change as they talk about their topic. How can they mark their green screen video so they will know where to place each photo?  We are using iMovie 11.

  • Rename particular XML Tag

    Hi Indesign Experts,           I'm confused a lot in the below issue. I'm have a indesign document. In the xml structure, If i select a element, and trying to rename the selected item's markupTag.name, it's changing all the elements with the selected

  • Blocking the cancellation of customs declaration once process is completed

    Hi All, I 've a requirement that the users should not be able to cancel custom declaration doc. using T.code /SAPSLL/CL_CUS_02(Cancel/Cancel request option) once border crossing for goods is passed and the process completed. Currently it is possible

  • Minimize upgrade time

    Dear all, One of my client has a database around 6TB, and they are planning to upgrade the database version from 10.2.0.4 to 11.2.2 . OS is Solaris 10. How do I minimize the downtime of the database upgrade ? . In this scenario, how to proceed with h