Code returns "null" and "0"s in main module - why?

I am coding a program that is in two modules. The main module serves it's standard function. The inventory class/module has three functions - 1) request stock input on 4 data points (1 String and 3 integers, one of which is a double) - 2) calculate the value of the inventory, and - 3) return string which reads out the 4 data points and the calculation showing the total value of the inventory. I've created the 3 functions in the inventory class/module, but obviously don't have them referring to each other correctly because when we come to the end of the program the output is null for the String and "0"s for the int/doubles. The code is below - any ideas about how to overcome the empty output? The code compiles fine and acts like it is going to work, but when it comes to the final command line it outputs
"null, which is item number 0, has 0 currently in stock at a price of 0.00 each. The total value of inventory in stock is 0.00"
Main module:
public class Main {
    @SuppressWarnings("static-access")
    public static void main(String[] args) {
        Inventory inventory = new Inventory(); //call Inventory class
        inventory.inventoryInput();
        Inventory results = new Inventory();
        results.inventoryResults(); //call for inventoryResults in Inventory class
}Inventory module:
import java.util.Scanner;
import static java.lang.System.out;
public class Inventory
  //declare and initialize variables
   int itemNumber = 0;
   String productName;
   int stockAmount = 0;
   double productCost = 0;
   double totalValue = 0;
   String inventoryResults;
   //initialize scanner
   Scanner input = new Scanner(System.in);
   public void inventoryInput ()
   out.println("Please enter item number: "); //prompt for item number
      itemNumber = input.nextInt();
   out.println( "Enter product name/description: "); //prompt for product name
      productName = input.next();
   out.println("Quantity in stock: ");
      stockAmount = input.nextInt(); // prompt for stock quantity
   out.println("What is the product cost for each unit? ");
      productCost = input.nextDouble(); // prompt for product cost
    } // end inventoryInput
    public double totalValue( double stockAmount, double productCost )
      totalValue = stockAmount * productCost;
      return totalValue; // return stock value
    } // end totalValue
    public void inventoryResults()
    out.printf("%s, which is item number %d, has %d currently in stock at a " +
     "price of %.2f each. The total value of inventory in stock is " +
     "%.2f\n.", productName, itemNumber, stockAmount, productCost, totalValue);
    } // end inventoryResult
}// end method

justStartingOut wrote:
Actually my final solution was quite simple - I moved the calculation and final formated print text statements into the body of Inventory's class code. It now works. "Works" scares me a bit.
Someone cooking dinner might rummage about in the fridge and the cupboards to see what's there. Do imaginative things with what they come up with. And, with a bit of luck come up with something tasty or, at any rate edible.
A physician deciding on a medical treatment would do well to try a more cautious approach. A specific aim would be a good thing. And a calculated appreciation of the documented effects of each medicine. And how they interact.
It's up to you to determine which approach your coding should resemble. But it seems to me that your original Main class had a perfectly good reason to exist. It was a driver class whose purpose seemed to be to create and use an Inventory. (And using an Inventory is a very different thing from being an Inventory, so it made perfect sense to have two different classes.) To me it works or not, depending on whether it fufills that purpose. And what you have done is not so much solve the problem of it not working, as avoid that problem.
(If by "moved" you mean that the outputting now occurs as part of - or is called from - inventoryInput() then that is not a good thing. The input method should input: just input.)
I think that is because once the original input was loaded into the program (when I entered product number, name, price and value), the entries were dropped when the code switched to the next step. I think your intuition is entirely correct. In particular look at what your original main() method does (my comments replacing yours):
Inventory inventory = new Inventory(); // (A) Create an inventory...
inventory.inventoryInput(); // ... and put stuff into it
    // (B) Create some new entirely different (and empty) inventory...
Inventory results = new Inventory();
results.inventoryResults(); // ... and print its contentsInstead of creating a second inventory, try printing the results of the first one.
Edited by: pbrockway2 on Apr 22, 2008 12:37 PM
Whoops ... just read reply 2.
It might sense, though to call totalValue() at the end your input method (because at that point the total value has changed). Or do away with that method - which you worked on getting right in your other thread ;)

Similar Messages

  • Code returning NULL

    T1 (Table and columns & data ) used in my example
    create table T1 (col1 number,col2 number);
    col1 col2
    1 5
    2 5
    3 5
    4 5
    11 6
    12 6
    13 6
    14 6
    CREATE OR REPLACE FUNCTION TEST (par NUMBER) RETURN VARCHAR2 IS
    l_concat VARCHAR2(32767) ;
    BEGIN
    select wm_concat(col1) into l_concat from t1 where col2=par;
    RETURN l_concat;
    END;
    select TEST(5) from dual;
    The above example always returns a NULL as opposed to (1,2,3,4);
    CREATE OR REPLACE FUNCTION TEST (par NUMBER) RETURN VARCHAR2 IS
    l_concat VARCHAR2(32767) ;
    l_str varchar2(32767);
    BEGIN
    l_str:='select wm_concat(col1) from t1 where col2=:b';
    execute immediate l_str into l_concat using par;
    RETURN l_concat;
    END;
    select TEST(5) from dual;
    This returns the correct answer .i.e. (1,2,3,4);
    My question is why my first code returning NULL? Is there any restriction using aggregate functions inside
    plsql code ?

    BluShadow wrote:
    The in paramter has the same name as one of the column . Thus the select query was not taking the filtering predicate as the in parameter col1 ,rather it was
    using the column's value for filtering each row and hence the wm_concat was not getting any row to concatenate .That's why you should use a good coding standard and perhaps prefix parameters with "p" or "p_" and local variables with "v" or "v_" etc.Smacks too much of archaic Hungarian notation. :-)
    Explicit scope definition is supported by PL/SQL. So why invent a new manual standard for scope, when there exists one already?
    SQL> create or replace procedure FooProc( empNo emp.empno%Type ) is
      2          empRow  emp%RowType;
      3  begin
      4          select
      5                  e.* into empRow
      6          from    emp e
      7          where   e.empno = FooProc.empNo;
      8 
      9          dbms_output.put_line(
    10                  'Employee '||empNo||' is '||empRow.ename||
    11                  ', and employed as '||empRow.job
    12          );
    13  end;
    14  /
    Procedure created.
    SQL>
    SQL>
    SQL> exec FooProc(7369)
    Employee 7369 is SMITH, and employed as CLERK
    PL/SQL procedure successfully completed.
    SQL> Personally, I find the v_ and p_ prefix approach quite silly - attempting to address an issue that is already solved by explicit PL/SQL scope.
    Never mind that the approach of using different prefixes, attempts to identify scope - and goes down the exact same slippery scope that Hungarian notation did. Which resulted in the death of this misguided standard, many years ago.
    Frustrates me to no end to see the exact SAME mistakes made in PL/SQL that were made a decade or more ago - where lessons learned since then are conveniently ignored when it comes to PL/SQL programming.
    It is still seems to be the Dark Ages when it comes to PL/SQL development.... :-(

  • ObjectInputStream() returning null and EOFException - need help

    I have been working on this little snippet of code all day and I cannot understand why I get null values when I run a display application. The code is posted below for 3 file. PhoneList.java is for serialization. CreatePhoneList is to populate a saved file with phone numbers and names of contacts. DisplaySavedPhoneList.java is to display the saved names and numbers. I'm not looking for the correct code, put for someone to point me in the right direction on why I'm getting these results so I can find a solution.
    Here is the PhoneList class:
    import java.io.*;
    public class PhoneList implements Serializable
        private String name;
        private String num;
        private String phName;
        private String phNum;
        PhoneList(String phNum, String phName)
            setName(phName);
            setNum(phNum);
        public String getName()
            return phName;
        public String getNum()
            return phNum;
        public void setName(String phName)
            name = phName;
        public void setNum(String phNum)
            num = phNum;
    }Here is the CreatePhoneList class
    import java.io.*;
    import java.util.*;
    public class CreatePhoneList
        public static void main(String[] args) throws IOException
            ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream("PhoneList.txt"));
            PhoneList list;
            String phName;
            String phNum;
            final String QUIT = "QUIT";
            Scanner in = new Scanner(System.in);
            System.out.println("Enter a phone number or " + QUIT + " to quit.");
            phNum = in.next();
            while(!phNum.equals(QUIT))
                System.out.println("Enter the contact name.");
                phName = in.next();
                list = new PhoneList(phNum, phName);
                output.writeObject(list);
                System.out.println("Enter a phone number or " + QUIT + " to quit.");
                phNum = in.next();
            output.close();
    }and this is the DisplaySavedPhoneList class:
    import java.io.*;
    import java.util.*;
    public class DisplaySavedPhoneList
        public static void main(String[] args) throws IOException, ClassNotFoundException
            ObjectInputStream input = new ObjectInputStream(new FileInputStream("PhoneList.txt"));
            PhoneList list;
            final int SHOW = 1;
            int showList;
            int count = 0;
            Scanner in = new Scanner(System.in);
            try
                System.out.print("To display Phone List enter " + SHOW);
                showList = in.nextInt();
                while(showList == SHOW)
                    list = (PhoneList)input.readObject();
                    System.out.println("Name: " + list.getName() + " Phone Number: " + list.getNum());
                    count++;
            catch(EOFException e)
                System.out.println("Oops, something broke!");
                input.close();
    }This is the result from running the DisplaySavedPhoneList application:
    To display Phone List enter 1
    1
    Name: null Phone Number: null
    Name: null Phone Number: null
    Oops, something broke!

    ok, I did that, and its pointing me to the line commented below. I did a practical exercise where the code was almost identical and it worked fine. The only difference are the variables.
    try
                System.out.print("To display Phone List enter " + SHOW);
                showList = in.nextInt();
                while(showList == SHOW)
                    list = (PhoneList)input.readObject(); //this is the line that was identified in the stacktrace
                    System.out.println("Name: " + list.getName() + " Phone Number: " + list.getNum());
                    count++;
            catch(EOFException e)
                System.out.println("Stack Trace");
                e.printStackTrace();
                input.close();
            }here is the total stack trace, in case you were wondering...
    To display Phone List enter 1
    1
    Name: null Phone Number: null
    java.io.EOFException
    Name: null Phone Number: null
    Stack Trace
            at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2554)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1297)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
            at DisplaySavedPhoneList.main(DisplaySavedPhoneList.java:21)I'm still not quite sure what this is telling me though.

  • FindNode returning Null And XML Not Accepting Special Characters

    Hi All,
    i am trying the get the attribute value in the element "ns4:InfoCFDi" using FindNode method, but the method is returning NULL. I used the same code for other sample as well and was successfull. but for this specific XML file(which is below) I am getting a Null.
    i can get till S:Body, but when i try to use FindNode for ":Body/s4:ResponseGeneraCFDi" I get Null value.
    And I used "S:Body/*[local-name()=" | "ns4:ResponseGeneraCFDi" | "]";
    as mentioned in other post but still no success.
    ==>I Have one more question relating to special characters. I need to use characters such as - ó in my XML to read as well as write. When I try to read i am getting XML parse error and when writing, i cannot open the file properly.
    Your help is much appreciated.
    My code is here:
    Local XmlDoc &inXMLDoc, &reqxmldoc;
    Local XmlNode &RecordNode;
    &inXMLDoc = CreateXmlDoc();
    &ret = &inXMLDoc.ParseXmlFromURL("D:\Agnel\Mexico Debit Memo\REALRESPONSE.xml");
    If &ret Then
    &RecordNode = &inXMLDoc.DocumentElement.FindNode("" );
    If &RecordNode.IsNull Then
    Warning MsgGet(0, 0, "Agnel FindNode not found.");
    rem MessageBox(0, "", 0, 0, "FindNode not found");
    Else
    &qrValue = &RecordNode.GetAttributeValue("asignaFolio ");
    Warning MsgGet(0, 0, "asignaFolio." | &qrValue);
    End-If;
    Else
    Warning MsgGet(0, 0, "Error. ParseXmlString");
    End-If;
    XML File:
    - <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    - <S:Body>
    - <ns4:ResponseGeneraCFDi xmlns="http://www.xxl.com/ns/xsd/bf/rxx/52" xmlns:ns2="http://www.sat.gob.mx/cfd/3" xmlns:ns3="http://www.xx/ns/bf/conector/1&quo t; xmlns:ns4="http://www.xx/ns/xsd/bfxx/xx/32&qu ot; xmlns:ns5="http://www.xxcom/ns/xsd/bf/xxxxx&q uot; xmlns:ns6="http://wwwxx.com/ns/referenceID/v1">
    - <ns3:Result version="1">
    <ns3:Message message="Proceso realizado con exito." code="0" />
    </ns3:Result>
    - <ns4:InfoCFDi noCertificadoSAT="20001000000100003992" refId="STORFAC20121022085611" fechaTimbrado="2012-10-22T08:56:45" qr=" "
    uuid="a37a7d92-a17e-49f4-8e4d-51c983587acb" version="3.2" tipo="XML" archivo="xxx" sello="B8WjuhYLouSZJ6LU2EjxZ0a4IKyIENZNBx4Lb4 jkcAk6wA+EM477yz91/iDdsON0jm8xibBfom5hvHsH7ZK1ps3NnAXWr1LW 7ctmGsvYKAMvkCx/yOVzJTKFM2hN+OqCTE0WVfgv690vVy2CDQWKlMxbK+3idwG4t OKCMelrN9c=" fecha="2012-10-22T08:56:44" folio="281" serie="IICC">
    <InfoEspecial valor="Este documento es una representacin impresa de un CFDI." atributo="leyendaImpresion" />
    <InfoEspecial valor="||1.0|a37a7d92-a17e-49f4-8e4d-51c983587acb|2012-10-22T08:56:45|B8WjuhYLouSZJ6LU2EjxZ0a4IKyIENZNBx4Lb4 jkcAk6wA+EM477yz91/iDdsON0jm8xibBfom5hvHsH7ZK1ps3NnAXWr1LW 7ctmGsvYKAMvkCx/yOVzJTKFM2hN+OqCTE0WVfgv690vVy2CDQWKlMxbK+3idwG4t OKCMelrN9c=|20001000000100003992||" atributo="cadenaOriginal" />
    <InfoEspecial valor="Doscientos dieciocho mil cuatrocientos setenta y cinco pesos 00/100 M.N." atributo="totalConLetra" />
    </ns4:InfoCFDi>
    </ns4:ResponseGeneraCFDi>
    </S:Body>
    </S:Envelope>
    TIA

    First of all you have to supply a value you want to search for and this has to be the complete path to the value. You're saying you already tried that, but can you paste the code which you used for that? I don't see the path mentioned in the code you posted.
    *FindNode*
    Syntax
    FindNode(Path)
    Description
    Use the FindNode method to return a reference to an XmlNode.
    The path is specified as the list of tag names, to the node that you want to find, each separated by a slash (/).
    Parameters
    Path
    Specify the tag names up to and including the name of the node that you want returned, starting with a slash and each separated by a slash (/). This is known as the XPath query language.>
    Another option would be this snippet of code:
    &InfoCFDiArray = GetElementsByTagName("ns4:InfoCFDi");
    &InfoCFDiNode = &InfoCFDiArray [1];
    &attValue = &InfoCFDiNode.GetAttributeValue("noCertificadoSAT")
    Warning(&attValue);
    It creates an array of XML Nodes which match the name "ns4:InfoCFDi". Since there's only one in the XML it's safe to assume it will be the one and only node in the array. I've assigned that node to the variable &InfoCFDiNode and use that to retrieve the attribute "noCertificadoSAT" value. The warning message should display the value supplied there.
    Concering the special characters; you will have to change the encoding of the XML. Peoplecode sets this to UTF-8 by default, but doesn't include this in the header. There's a little hack for that somewhere on the web, I'll see if I can find it.

  • HelpSet.findHelpSet() returns null, and trapping ID errors

    I was having a problem initializing JavaHelp. HelpSet.findHelpSet() was returning null. I searched the forum, and found it was a common problem, but the answers were unhelpful. The answers pointed to a problem with CLASSPATH, but offered little in the way of advice for a newbie like myself on how to deal with it.
    A second issue concerns HelpBroker.enableHelpOnButton(). If you feed it a bogus ID, it throws an exception, and there's no way to trap it and fail gracefully. JHUG doesn't provide much in the way of alternatives.
    Now, having done a bit of research and testing, I'm willing to share a cookbook formula for what worked for me.
    I'm working in a project directory that contains MyApp.jar and the Help subdirectory, including Help/Help.hs. My first step is to copy jh.jar to the project directory.
    Next, in the manifest file used to generate MyApp.jar, I add the line:
        Class-Path: jh.jar Help/I'm working with Eclipse, so in Eclipse, I use Project - Properties - Java Build Path - Libraries to add JAR file jh.jar, and Class Folder Tony/Help
    I define the following convenience class:
    public class HelpAction extends AbstractAction
        private static HelpBroker helpBroker = null;
        private String label = null;
        public HelpAction( String name, String label )
            super( name );
            this.label = label;
        public void actionPerformed( ActionEvent event )
            displayHelp( label );
        public static boolean displayHelp( String label )
            if ( helpBroker == null )
                Utils.reportError( "Help package not initialized!" );
                return false;
            try
                helpBroker.setCurrentID( label );
                helpBroker.setDisplayed( true );
                return true;
            catch ( Exception e )
                Utils.reportError( e, "Help for " + label + " not found" );
                return false;
        public static boolean initialize( String hsName )
            URL hsURL = HelpSet.findHelpSet( null, hsName );
            if ( hsURL == null )
                Utils.reportError( "Can't find helpset " + hsName );
                return false;
            try
                HelpSet helpSet = new HelpSet( null, hsURL );
                helpBroker = helpSet.createHelpBroker();
            catch ( HelpSetException e )
                Utils.reportError( e, "Can't open helpset " + hsName );
                return false;
            return true;
    }If you use this class in your own code, you'll want to replace Utils.reportError() with something of your own devising.
    Finally, in my GUI class, I use the following:
        JPanel panel = ...
        JMenu menu = ...
        JToolbar toolbar = ...
        HelpAction.initialize( "Help.hs" )
        Action gsAction = new HelpAction( "Getting Started Guide", "gs.top" );
        menu.add( gsAction );
        JButton helpButton = new HelpAction( "Help", "man.top" );
        toolbar.add( helpButton );
        InputMap imap = panel.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
        imap.put( KeyStroke.getKeyStroke( "F1" ), "F1help" );
        ActionMap amap = panel.getActionMap();
        amap.put( "F1help", new HelpAction( null, "man.top" ) );

    Sorry, the sixth-from-last line of my example should read,
        JButton helpButton = new JButton( new HelpAction( "Help", "man.top" ) );

  • Get textFrame by label returns null and anchored objects

    I have the following two functions:
    function getByLabel(page, label)
        for(var i=0; i < page.allPageItems.length; i++)
            if( page.allPageItems[i].label == label )
                return page.allPageItems[i];
    and
    Object.prototype.findItems = function(/*obj*/props)
        if( !('everyItem' in this) )
            throw new Error("Error: " + this + " is not a collection.");
        var ret = this.everyItem().getElements(),
            i = ret.length,
            e, p;
        while( i-- && e=ret[i] )
            for( p in props )
                if( (p in e) && e[p]===props[p] ) continue;
                ret.splice(i,1);
        return ret;
    In my page structure, I got one main text frame (the content area) and two vertical text fromes on the sides of the page. There is also a small box textframe on top of the page. All these textboxes EXCEPT the main text frame are ALL "ANCHORED objects". I had to make them anchored objects, eitherwise after importing data, the boxes would jump around. (Example, the small box textframe that is on the top would get moved to the content area textframe etc). Not sure if using anchored objects is the proper way to fix this.
    When I try to get the small box text frame, it does not work using the findItems (returns null) but it works fine with the getByLabel method. Why is that?
    The calling syntax is:
    for( i=0 ; i < doc.pages.length ; ++i )
            var page = doc.pages.item(i);
            var textFrame = getByLabel(page, 'lblSection' ); //This works
            //   var textFrame = page.textFrames.findItems({ label:  'lblSection' })[0]; This does not work, returns null
            if( textFrame != null )
                textFrame.parentStory.contents = "";

    (function () {
        // Per the InDesign Scripting Guide, app.activeScript is only
        // valid when a script is directly executed from InDesign, not
        // from the ESTK, so a try/catch block is recommended to handle
        // it.
        var d;
        try {
            d = app.activeScript.parent.parent.fsName;
        } catch (e) {
            d = Folder.appPackage.parent.fsName+"/Scripts";
            return d;

  • Kff.where returns 'null'  and causes sql error - looking for a work around

    Hello,
    I am using BI 5.6.3 in EBS (11.5.10.2)
    I have created a kff.where as follows:
    <lexical
    type="oracle.apps.fnd.flex.kff.where"
    name="lp_location_where_clause"
    comment="Comment"
    application_short_name="OFA"
    id_flex_code="LOC#"
    id_flex_num=":lp_location_flex_structure"
    code_combination_table_alias="loc"
    segments="ALL"
    operator="BETWEEN"
    operand1=":p_location_low"
    operand2=":p_location_high"/>
    </lexicals>
    Everything works fine, as long as I have a values for the p_location_low and p_location_high. However, this is a parameter that comes in from a concurrent program and is optional. When the user doesn't pick a value, :p_location_low is the concatenated delimiters for the location '..'.
    When this runs, the kff.where is returning null which causes 'Invalid Relational Operation error' because 'AND null' is not valid.
    Warning in the log is :[091910_025232517][][STATEMENT] !!Warning: FlexAPI returns null for 'x_where_expression' lexical definition...
    Does anyone have a workaround for this since making the parameter required is not an option for my users?
    Thanks for reading.

    In your SQL*Plus session, make sure you
    SQL> set define offbefore trying to create the Java stored procedure. SQL*Plus assumes that any string that begins with an & is a substitution variable unless you tell it that you have no substitution variables (via set define off).
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Why this line of code returns null always??

    Dear All,
    Just a question.
    I have this snippet of code where a user is required to input a number.
    <af:panelGroupLayout layout="vertical" id="pgl1">
      <af:inputText label="number" id="it1"
                        value="#{MyBean.number}" immediate="true"/>
      <af:commandButton text="Submit" id="cb1" partialSubmit="true"
                        immediate="true"
                        actionListener="#{MyBean.handleAction}"/>
    </af:panelGroupLayout>The immediate attribute at both inputtext and button are needed as I am bypassing validation on the other form components.
    Here is my bean defined in request scope.
    public class MyBean
      private String number;
      public void handleAction(ActionEvent actionEvent)
        AdfFacesContext ctx = AdfFacesContext.getCurrentInstance();
        Map<String, Object> pageFlowMap = ctx.getPageFlowScope();
        pageFlowMap.put("number", getNumber());               //Problem line getNumber is always null
      public void setNumber(String number)
        this.number = number;
      public String getNumber()
        return number;
    }I am having problem on the above line. I always get a null value on the number input text.
    Why is that so as I think I have already place a value on my Bean.
    For completeness sake, here's how I defined my managed bean
      <managed-bean id="__12">
        <managed-bean-name id="__9">MyBean</managed-bean-name>
        <managed-bean-class id="__11">com.testing.MyBean</managed-bean-class>
        <managed-bean-scope id="__10">request</managed-bean-scope>
      </managed-bean>Not sure but any workaround to this?
    Thanks
    Jdev 11G PS4

    Mohammad Jabr wrote:
    try to bind your input text to a property in your bean and use getValue() method.
    check this nice post [url http://adfpractice-fedor.blogspot.com/2012/02/understanding-immediate-attribute.html]Understanding the Immediate Attribute
    Edited by: Mohammad Jabr on Feb 22, 2012 8:25 AM
    Hi, Apparently this does work. Putting a binding on the input components.
    But somehow, I am reluctant to make use of any bindings as I am encountering issues when I expose this Taskflow as portlet in a Webcenter Application.
    But, as I have read the article, I made changes with the code. I am not using any bindings but just making use of the valuechangelistener.
    From the article, I have realized that the reason why the setter method of the bean was not called is because the Update Model Values was skipped.
    Very nice article.
    Thanks.

  • I am trying to raise event at UserControl, and catch it at Main program, But the event always return null

    I am trying to raise a event in one of classes of userControl, and Fire it in the Main class. I tried two different ways to fire this event, one of them works, But I still want to know why other way cannot work, and how to fix it.
    My userContol class:
    public partial class UserControl1 : UserControl
    public UserControl1()
    InitializeComponent();
    if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
    return;
    Class1 c = new Class1();
    Thread accept = new Thread(
    () =>
    c.connection();
    accept.Start();
    And the Class1:
    public class Class1
    public delegate void myhandler(object sender, EventArgs e);
    public event myhandler test;
    public Class1()
    public void connection()
    test(this, new EventArgs());
    In the Main, I just simply add into referent, and add
    xmlns:my="clr-namespace:WpfControlLibrary1;assembly=WpfControlLibrary1"
    then I try to subscribe this event in the main
    public partial class SurfaceWindow1 : SurfaceWindow
    /// <summary>
    /// Default constructor.
    /// </summary>
    public SurfaceWindow1()
    InitializeComponent();
    Class1 c = new Class1();
    c.test+=new Class1.myhandler(c_test);
    // Add handlers for window availability events
    AddWindowAvailabilityHandlers();
    public void c_test(object sender, EventArgs e)
    MessageBox.Show("fire");
    If I only raise this event not into thread, it works fine, but If I try to let it raise in this thread, this test event only return null, and shows:
    Object reference not set to an instance of an object.
    looks like I did not subscribe it ever. So How to fix it if I must use it in thread.

    Subscribing to events window to class is not a great approach.
    You have to then go un subscribe those handlers in order to allow your instance to be disposed.
    Forget that and you'll eventually notice you have memory leaks.
    The way I do this sort of thing is using mvvm light messenger.
    You can keep everything decoupled then.
    http://social.technet.microsoft.com/wiki/contents/articles/26070.aspx
    I just did a bit of code for someone else which shows how to do cross thread stuff with this approach.
    public partial class MainWindow : Window
    public MainWindow()
    InitializeComponent();
    Messenger.Default.Register<String>(this, (action) => ReceiveString(action));
    private void ReceiveString(string msg)
    MessageBox.Show(msg);
    Dispatcher.BeginInvoke((Action)delegate()
    tb.Text = msg;
    private void Button_Click(object sender, RoutedEventArgs e)
    Task.Factory.StartNew(() => {
    Messenger.Default.Send<String>("Hello World");
    Note that the message arrives on the thread it was sent from. That's not the ui thread because it was sent from that task.factory.startnew to deliberately put it on a different thread.
    In order to change UI controls, it uses dispatcher.begininvoke to run code on the UI thread.
    Although this is in one piece of code behind publisher and subscriber can be in two totally different classes which have no reference of knowledge of each other.
    Meaning you can send a message<t> from any class1 or whatever you like and your mainwindow can subscribe and act of receipt of a message<t>.
    It is the type which defines which message one is. You put data you want to send in t and use it in the subscriber.
    Hope that helps.
    Technet articles: Uneventful MVVM;
    All my Technet Articles

  • Naming.lookup() returns null???? Why??

    I read about this in a previous forum but there was no answer given to someones question about it. Sometimes Naming.lookup() returns null and a later call will succeed. Is there a recognised reason for this? Is it a recognised bug or undocumented feature?
    I have seen some sample RMI source on the Internet and sometimes the code checks for null and gives and error. The sample programs from Sun regarding RMI don't check for null.
    Has anyone ever encountered this and found a way around it?
    Thanks for you help,
    Anthony

    hi
    are you using an Activatable object??
    then, it can happens, since you won't have your object until the ActivationSytem is running.
    And it takes little time for the activation system to run.
    If u are using an 'Activatable object, i will suggest to write a loop in which you check if hte ActivationSystem was started.
    something like this
    boolean display = false;
    ActivationGroupID agi = null;
    while(true) {
    try {
    if(!display) {
    System.err.println("Trying to connect to ActivationSystem...");
    display = !display;
    agi = ActivationGroup.getSystem().registerGroup(exampleGroup);
    break;
    } catch(Exception e) {
    continue;
    }

  • Select query on table rcv_lots_interface is always returning null

    Hi ,
    I need a help on the below issue.
    The issue is after creating PO in Oracle 11i I receive it in MSCA application.
    When we receive it at that point data gets inserted in the table " rcv_transactions_interface " and we have written a trigger on it.
    From the trigger on table " rcv_transactions_interface " we are calling a package and in the package we have select query on "rcv_lots_interface."
    But the select query is always returning null even though we are passing the correct "interface_transaction_id " and also after the "Receiving Transaction Processor" is executed i can see data in the table " RCV_LOT_TRANSACTIONS " for the same transaction.
    Below is the sample code i am using.
    CREATE OR REPLACE TRIGGER inv.RCV_TRAN_TRIGGER
    AFTER UPDATE
    ON po.rcv_transactions_interface
    FOR EACH ROW
    WHEN (NEW.processing_status_code='PENDING'
    AND NEW.destination_type_code IN ('INVENTORY','RECEIVING')
    AND NEW.mobile_txn = 'Y')
    DECLARE
    PRAGMA AUTONOMOUS_TRANSACTION;
    v_user_id NUMBER;
    v_interface_transaction_id NUMBER;
    v_organization_id NUMBER;
    v_item_id NUMBER;
    v_quantity NUMBER;
    v_resp_id NUMBER;
    v_mobile_txn VARCHAR2(5);
    v_shipment_header_id NUMBER;
    v_bill_of_lading VARCHAR2(100);
    v_group_id NUMBER;
    v_header_interface_id NUMBER;
    BEGIN
    v_interface_transaction_id := :NEW.interface_transaction_id;
    v_organization_id := :NEW.to_organization_id;
    v_user_id := :NEW.created_by;
    v_item_id := :NEW.item_id;
    v_quantity := :NEW.quantity;
    v_resp_id :=fnd_profile.VALUE('RESP_ID');
    v_transaction_type := :NEW.transaction_type;
    v_mobile_txn := :NEW.mobile_txn;
    v_bill_of_lading := :NEW.bill_of_lading;
    v_group_id := :NEW.group_id;
    v_header_interface_id := :NEW.HEADER_INTERFACE_ID;
    INV.INV_RCV_TRX_PKG.INV_RCV_LABEL_GEN_PRC( v_user_id,
    v_interface_transaction_id,
    v_item_id,
    v_quantity,
    v_organization_id,
    v_resp_id,
    v_shipment_header_id,
    v_bill_of_lading,
    v_header_interface_id,
    v_group_id);
    END;
    CREATE OR REPLACE PACKAGE BODY INV.INV_RCV_TRX_PKG
    AS
    PROCEDURE INV_RCV_LABEL_GEN_PRC( p_user_id IN NUMBER,
    p_interface_transaction_id IN NUMBER,
    p_item_id IN NUMBER,
    p_quantity IN NUMBER,
    p_organization_id IN NUMBER,
    p_resp_id IN NUMBER,
    p_shipment_header_id IN NUMBER,
    p_bill_of_lading IN VARCHAR2,
    p_header_interface_id IN NUMBER ,
    p_group_id IN NUMBER
    IS
    v_user_id NUMBER;
    v_print BOOLEAN;
    v_resp_id NUMBER;
    v_resp_appl_id NUMBER;
    v_lot_num VARCHAR2(50);
    BEGIN
    BEGIN
    SELECT application_id
    INTO v_resp_appl_id
    FROM apps.fnd_responsibility_tl frt
    WHERE responsibility_id=p_resp_id;
    END;
    apps.fnd_global.apps_initialize(p_user_id, p_resp_id, v_resp_appl_id);
    BEGIN
    SELECT rli.lot_num , rli.expiration_date
    INTO v_lot_num ,
    v_expiration_date
    FROM apps.rcv_lots_interface rli
    WHERE rli.interface_transaction_id = p_interface_transaction_id ;
    EXCEPTION
    WHEN OTHERS THEN
    v_lot_num :=NULL;
    v_expiration_date :=NULL;
    apps.fnd_file.put_line(fnd_file.log,'Exception while deriving LOT Number ######### '||p_interface_transaction_id||'------'||SQLERRM);
    END;
    END;
    Need your help to understand why the below query is always returning null and what is the solution for it ?
    SELECT rli.lot_num , rli.expiration_date
    FROM apps.rcv_lots_interface rli
    WHERE rli.interface_transaction_id = p_interface_transaction_id ;
    Thanks
    Jaydeep
    Edited by: user10454886 on Mar 25, 2013 6:31 AM
    Hi ,
    I need a solution to this issue at the earliest.
    Appreciate all of your help
    Thanks
    Jaydeep

    Centinul wrote:
    There are a lot of bugs listed in Metalink with respect to wrong results and function-based indexes.
    Here are a few:
    Bug 4028186 Wrong results if function based index exists
    Bug 4717546 Wrong results / poor plan when function based index exists
    Bug 5092688 Wrong results if function based index exists
    Based on reviewing them the workarounds range from dropping the index to setting "_disable_function_based_index" to TRUE.Facinating. It seems to me that if you use the undocumented intitialization parameter you might just as well drop the FBIs too.
    Another hazard of FBIs is the Law of Unintended Consequences. 2 years ago we tried to use one to speed up a query in a PL/SQL package. Worked OK for that purpose, but an unrelated loader on the affected table ran and rand but never finished until the FBI was dropped.

  • Component binding return null value

    I'm migrating a JSF 1.2 application to JSF 2.1, specificly I'm currently using mojorra 2.1.24.
    The application consists of request scoped beans, and in order to pass data between requests, it embeds the data inside UI components.
    The following behaviour works well with JSF 1.2, but not with JSF 2.1.
    The application has the following configuration:
    <context-param>
      <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
      <param-value>client</param-value>
    </context-param>
    The page contains the following snippet:
    <h:form prependId="false">
         <h:inputHidden binding="#{bean.inputHidden}" />
         <h:panelGroup rendered="#{bean.rendered}">
          <h:commandLink value="onAction" action="#{bean.onAction}" />
         </h:panelGroup>
    </h:form>
    The bean is the following:
    @ManagedBean
    @RequestScoped
    public class Bean {
      private UIInput inputHidden;
      private AItem item;
      public setInputHidden(UIInput inputHidden){
        this.inputHidden = inputHidden;
        if(item != null){ this.inputHidden.setValue(item); }
      public AItem getItem(){
        return (AItem) getInputHidden().getValue();
      // other getter/setter
      public String onNavToPage(AItem item){ this.item = item; return "page"; }
      public String onAction(){ //... do something return ""; }
      public boolean isRendered(){ return getProcessItem() != null; }
    The steps are the following:
    to navigate to page page the method bean.onNavToPage is invoked from within another page;
    upon page rendering the bean.item is set as bean.inputHidden value;
    after the page is diplayed, the command link is pressed.
    At this point no command link is invoked, because the bean.inputHidden.getValue() returns null, and the command link is not processed.
    I noticed that the inputHidden parameter passed to the setInputHidden method during restore view phase has, inputHidden.getValue() == null, no value has been saved previously in the view.
    I would guess that something has changed in the component state management, but debugging the JSF code I didn't find what.
    Debugging JSF code I found that the component state has been masked before the state has been saved in the view, so the ComponentStateHelper.saveState saves the deltaMap and not the defaultMap, where all the state has been put.
    public Object saveState(FacesContext context) {
            if (context == null) {
                throw new NullPointerException();
            if(component.initialStateMarked()) {
                return saveMap(context, deltaMap);
            else {
                return saveMap(context, defaultMap);
    is this a bug?
    If not, how can I restore JSF 1.2 behaviuor and save the defaultMap?
    Thanks in advance for the help.

    0.10: Saved session state: 6385226710016200 "P327_OU_NAME" changedValue="test"
    0.10: ...P327_FK_ORGUNIT session state saving same value: "%null%"
    0.15: Saved session state: 6388922235040486 "P327_OU_DESC" changedValue=""
    0.15: Processing point: ON_SUBMIT_BEFORE_COMPUTATION
    0.15: Branch point: BEFORE_COMPUTATION
    0.15: Computation point: AFTER_SUBMIT
    0.15: Perform Branching for Tab Requests
    0.15: Branch point: BEFORE_VALIDATION
    0.15: Perform validations:
    0.16: Branch point: BEFORE_PROCESSING
    0.16: Processing point: AFTER_SUBMIT
    0.16: ...PLSQL (AFTER_SUBMIT) INSERT INTO INDIT_PS_ORGUNIT ( OU_ID, FK_ORGUNIT, OU_NAME, OU_DESC ) VALUES ( INDIT_PASS_SEQ_GENERIC_ID.NEXTVAL, :P327_FK_ORGUNIT, :P327_OU_NAME, :P327_OU_DESC )
    0.16: Show ERROR page...
    0.17: Processing point: AFTER_ERROR_HEADER
    0.18: Processing point: BEFORE_ERROR_FOOTER
    ORA-01722: invalid number
    the table was created with:
    CREATE TABLE INDIT_PS_ORGUNIT (
    OU_ID NUMBER(15) PRIMARY KEY,
    FK_ORGUNIT NUMBER(15) NULL,
    OU_NAME VARCHAR2(30) NOT NULL,
    OU_DESC VARCHAR2(30) NULL,
    OU_DELETED DATE NULL
    what i see is that the status is "%null%" and not really "" (NULL, nothing, ...).
    so what can i do to insert a null value from a select list?
    i gave up RTFM. because i found nothing (NULL) ?!?!

  • GetAttribute() method of a view object is returning NULL

    Hi ,
    I am trying to implement PPR in one of my OAF page and I have taken the following approach.
    I have declared the follwing transient boolean attribute in the VO() apart from the existing attribute "Meaning" .
    1.MfgEnttity
    2.MfgAcct
    3.MfgSubAcct
    4.MfgCc
    5.MfgProj
    In the page I have used these attributes in the rendered property as "${oa.XXR2RMfgproSegVO.MfgSubAcct}" like this.
    Now in the CO I have written the following code.
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    am.invokeMethod("initializeXXR2RMfgproSegVO");
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    String event = pageContext.getParameter(EVENT_PARAM);
    String source = pageContext.getParameter(SOURCE_PARAM);
    OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean);
    am.invokeMethod("handleSegmentChangeEvent");
    And the AM code is as follows:
    public void initializeXXR2RMfgproSegVO()
    OAViewObject vo = getXXR2RMfgproSegVO();
    if(!vo.isPreparedForExecution())
    vo.executeQuery();
    Row row = vo.createRow();
    vo.insertRow(row);
    row.setNewRowState(Row.STATUS_INITIALIZED);
    public void handleSegmentChangeEvent()
    OAViewObject pVO = (OAViewObject)findViewObject("XXR2RMfgproSegVO");
    OARow hdrRow = (OARow)pVO.getCurrentRow();
    String status = (String)hdrRow.getAttribute("Meaning");
    System.out.println("poRow "+ hdrRow.toString());
    System.out.println("value of the status is "+ status);
    if("Entity".equals(status))
    hdrRow.setAttribute("MfgEnttity", Boolean.TRUE);
    hdrRow.setAttribute("MfgAcct", Boolean.FALSE);
    hdrRow.setAttribute("MfgSubAcct", Boolean.FALSE);
    hdrRow.setAttribute("MfgCc", Boolean.FALSE);
    hdrRow.setAttribute("MfgProj", Boolean.FALSE);
    } else
    if("Account".equals(status))
    hdrRow.setAttribute("MfgEnttity", Boolean.FALSE);
    hdrRow.setAttribute("MfgAcct", Boolean.TRUE);
    hdrRow.setAttribute("MfgSubAcct", Boolean.FALSE);
    hdrRow.setAttribute("MfgCc", Boolean.FALSE);
    hdrRow.setAttribute("MfgProj", Boolean.FALSE);
    }else
    if("Subaccount".equals(status))
    hdrRow.setAttribute("MfgEnttity", Boolean.FALSE);
    hdrRow.setAttribute("MfgAcct", Boolean.FALSE);
    hdrRow.setAttribute("MfgSubAcct", Boolean.TRUE);
    hdrRow.setAttribute("MfgCc", Boolean.FALSE);
    hdrRow.setAttribute("MfgProj", Boolean.FALSE);
    }else
    if("Cost Center".equals(status))
    hdrRow.setAttribute("MfgEnttity", Boolean.FALSE);
    hdrRow.setAttribute("MfgAcct", Boolean.FALSE);
    hdrRow.setAttribute("MfgSubAcct", Boolean.FALSE);
    hdrRow.setAttribute("MfgCc", Boolean.TRUE);
    hdrRow.setAttribute("MfgProj", Boolean.FALSE);
    } else
    if("Project".equals(status))
    hdrRow.setAttribute("MfgEnttity", Boolean.FALSE);
    hdrRow.setAttribute("MfgAcct", Boolean.FALSE);
    hdrRow.setAttribute("MfgSubAcct", Boolean.FALSE);
    hdrRow.setAttribute("MfgCc", Boolean.FALSE);
    hdrRow.setAttribute("MfgProj", Boolean.TRUE);
    else
    hdrRow.setAttribute("MfgEnttity", Boolean.FALSE);
    hdrRow.setAttribute("MfgAcct", Boolean.FALSE);
    hdrRow.setAttribute("MfgSubAcct", Boolean.FALSE);
    hdrRow.setAttribute("MfgCc", Boolean.FALSE);
    hdrRow.setAttribute("MfgProj", Boolean.FALSE);
    Now when in the page I am changing the value of the attribute "Meaning" it is always getting into the else part i.e. where all the attributes are "False".
    The two System.out.Println statements are returning the follwing values.
    10/03/22 15:41:08 poRow [email protected]3
    10/03/22 15:41:08 value of the status is null
    Can you please suggest why this "Status" is returning NULL and how I can get the current row selected in the page?
    Thanks
    Subhabrata

    Hi Pratap,
    Thanks a lot for your reply.
    Can you please suggest how can I rectify the code.I have tried commenting the AM code as follows
    public void initializeXXR2RMfgproSegVO()
    OAViewObject vo = getXXR2RMfgproSegVO();
    if(!vo.isPreparedForExecution())
    vo.executeQuery();
    //Row row = vo.createRow();
    //vo.insertRow(row);
    //row.setNewRowState(Row.STATUS_INITIALIZED);
    But in the page when I am selecting any segment its throwing Null pointer Exception.
    I am new in OAF and this is an urgent client requirement.Please suggest me Where exactly I need to make change in my code.
    Thanks in advance...
    Thanks
    Subhabrata

  • SpContext.CreateUserClientContextForSPHost() returns null on Provider-hosted app

    I have been working with Apps for SharePoint for the past 1 year. But suddenly spContext.CreateUserClientContextForSPHost() returns null and not able to work on provider-hosted app.
    Note: Same code has been worked perfectly before and all of a sudden it is not working... (tried re-install of office tools for visual studio 2013)
    Please help me to resolve this issue.
    Server Error in '/' Application.
    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
    Source Error: 
    Line 35:             using (var clientContext = spContext.CreateUserClientContextForSPHost())
    Line 36:             {
    Line 37:                 clientContext.Load(clientContext.Web, web => web.Title);
    Line 38:                 clientContext.ExecuteQuery();
    Line 39:                 Response.Write(clientContext.Web.Title);
    Source File: d:\Demo\SharePointApp2\SharePointApp2Web\Pages\Default.aspx.cs    Line: 37 

    Hi Rajkumar,
    Please refer below link,
    http://www.looselytyped.net/2013/06/26/sharepoint-app-tools-in-visual-studio-2013-preview-the-new-sharepointcontext-helper/
    Please let us know if you need any help on this.
    Whenever you see a reply and if you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Alternate TextMark As Answer

  • Getting the ascii code for null

    i want to get the ascii code for null and append it for n number of times as string and return it.

    check whether it is correct
    public static String createNULL(int number){
              String     nullValue = new String(new char[number]);
              System.out.println(" String nullValue"+nullValue);
              System.out.println("length :"+nullValue.length());
              return nullValue;
    output i am getting is
    String
    nullValue.......................................
    ength: 35It's correct.

Maybe you are looking for

  • FS10N cumulative value Table and Fields

    Hi, FS10N balances, cumulative balances in which table it will store this values. I am not able to see cumulative balances in BKPF or BSEG. In which table we can see the cumulativie values by period wise for FS10N. Thanks srinu

  • Multiple IDocs to File using BPM

    Hi All, I have configured a scenario of multiple IDocs to file using BPM.  In this scenario while I am triggering IDoc from R/3 system it is sent to the external program.    I am getting in the status record of WE05 as IDoc is sent to an external sys

  • "Another application has changed your network settings" = connect trouble

    I am having a terrible time connecting to my ISP via dial-up. If I go to system preferences and click the network, and set up a new location, put in all the info, the computer will configure and connect me. But then I get the pop up message shown in

  • What is Workbench and Cut over stratrgy

    hi Gurus Can any one plese tel me 1 .  what is    ' WORKBENCH'      Why we use it and when? 2. what is CUTOVER STRATEGY    when we use it and why? Thanks and Regards           babi

  • Please give the meaning of this 9.2.0.7

    please give the meaning of this 9.2.0.7 each number represents what?