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;

Similar Messages

  • How do i get rid of type error null is an object on my iphone ? It keeps popping up on my yahoo, please help ?

    How do i get rid of type error null is an object on my iphone ? It keeps popping up on my yahoo, its driving me mad, please help.

    That's probably a Javascript error in what Yahoo is producing. Contact Yahoo and inform them of the problem.

  • 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" ) );

  • 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.

  • 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

  • Callouts and anchored objects - there must be a better way to do this

    I've spent a lot of time in the last six months rebuilding PDF files in InDesign. It's part of my ordinary responsibilities, but I'm doing a lot more of it for some reason. Because I'm sending the text of these rebuild documents out for translation, I like to keep all of the text in a single story. It really helps to have the text in "logical order," I think; when I'm prepping a trifold brochure, I try pretty hard to make sure that the order in which the readers will read the text is duplicated in the flow of the story throughout the ID document.
    So, I'm rebuilding a manual that has a 3-column format on lettersize paper, and it's full of callouts. Chock full of 'em. They're not pull quotes, either; each of these things has unique text. Keeping in mind that I'd like the text in these callouts to remain in the same position in the text once I've linked all the stories and exported an RTF for translation, what's the best way to handle them? What I've been doing is inserting an emptly stroked frame as an anchored object, sized and positioned to sit above the text that is supposed to be called out. When my translations come back, they're always longer than the source document, so as I crawl through the text, I resize the anchored frames to match the size and position of the newly expanded translated text, and then nudge them into place with the keyboard.
    There Has To Be a Better Way.
    There is a better way, right? I'm not actually too sure. If I want to actually fill those anchored frames with text, I can't thread them into the story. I suppose that I could just thread the callout frames and assign two RTFs for translation instead of one, but then the "logical order" of my text is thrown out the window. So, I'm down to asking myself "what's more important? reduction of formatting time or maintenance of the flow of the story?" If there's something I'm missing that would let me dodge this decision, I'd love to hear about it. The only thing I can think of would work like this:
    1) Duplicate callout text in the story with a custom swatch "Invisible"
    2) Create "CalloutText" parastyle with "Invisible" swatch and apply it to callout text
    3) Insert anchor for anchored frame immediately before the CalloutText content
    4) Send it out for translation
    5) While I'm waiting for it to come back, write a script that would (dunno if this is possible):
       a) Step through the main story looking for any instance of CalloutText
       b) Copy one continguous instance of that style to the clipboard
       c) Look back in the story for the first anchor preceeding the instance of CalloutText
       d) Fill the anchored object with the text from the clipboard (this is where I'm really clueless)
       e) Apply a new parastyle to the text in the callout
       f) Continue stepping through the story looking for further instances of CalloutText
    If this really is the only decent solution, I'll just head over to the Scripting forum for some help with d). Can any of you make other suggestions?

    In-Tools.com wrote:
    The use of Side Heads saves weeks of manual labor.
    Yup, Harbs, that is exactly what I was describing. If I use the Side Heads plugin to set up a job, will my clients get a missing plug-in warning when they open up the INDD? Will roundtripping through INX strip the plugin but leave the text in the callout? (My clients don't care if the logical flow of the story is broken; it's just me.)
    I'm just curious; seems like a pretty obvious purchase to me. I'll probably try to script a solution anyways, after I buy the plugin; that way I get to learn about handling anchored objects in scripts AND deliver the job on time!

  • TextWrap and Anchored Objects

    Okay, I've been using InDesign since it was PageMaker 4.3 so I'm pretty familiar with the features and the intents behind them. Lately I've had a problem for which I can't seem to find a fully acceptable work-around. It involves text-wrapping anchored objects within a large, multi page flow of text.
    Boiled down to a basic description of the issue, I need a graphic to appear on a page within a text block at a certain point, that is, at the top of a justified paragraph on the extreme right side of the column. The object occupies 7 lines of text, dropping down into the paragraph from line 1. The object needs to have a word wrap applied causing the text within the block to flow around it.
    The problem is that as the document evolves, the quantity of text that precedes the paragraph holding the graphic changes. As text is added to preceding paragraphs, text advances through the text blocks to a point where the graphic now begins to be displayed beyond the bottom of the text block rather than jump to the next text block. Forcing the object to stay within the text block (by using the "Keep with top/bottom column boundaries") pushes the object up, effectively leaving the original location and invading the preceding paragraph.
    The first solution I tried was to anchor the object 7 lines deep in the paragraph, then manually move it up to the first line using the "Y-offset" in the "Anchored Objects Options" palette. When I do this, the object's text wrap fails (!), always working only at line 7 and below and not moving up with the object.
    My current solution is to not embed the object inline at all, but place it over the text block. This works but is unsatisfactory since the text is constantly changing, forcing me to stop and reposition the graphic - plus the 500 or so similar objects that follow in similar situations further along in the document.
    Any ideas?

    Unfortunately, no. If the anchor is inserted at the top of the paragraph (where I want the top of the image to be), the image won't flow to the next text block when any other part of the image (i.e., any part of the image that is not on the first line where the anchor is) is beyond the end of its text block.
    Here is how I want the page to look:
    Here, the graphic is not placed inline but sits over the text with textwrap set.
    But rather than have all my objects placed over text, I want them inline. If I place the anchor anywhere below the first line of text, (again, the line where I want the top of the image to be), text wrap won't function above the anchor point regardless of how high I move the image:
    If I place the graphic in its own paragraph above the first line of the paragraph, the result works well as long as the text preceding the anchor doesn't flow any further (i.e., no additional text is added). But as text is added and once the line holding the bottom of the photo flows to a new text block, one of two problems arises. If "Keep Within Top/Bottom Column Boundaries" is checked the graphic moves up:
    If "Keep Within Top/Bottom Column Boundaries" is unchecked, the graphic begins to bleed out of the text box:
    I can't believe there isn't a simple (or even complex) solution to this problem...

  • Foot notes and Anchored Objects...

    So from what I can tell, an anchored object set to the bottom of the page, column, margin etc will all sit nice and smugly over footnotes!
    ( I would have thought using the column for the y axis would not count the footnote portion)
    Anyhow, has anyone come up with a solution for this?

    Unfortunately, no. If the anchor is inserted at the top of the paragraph (where I want the top of the image to be), the image won't flow to the next text block when any other part of the image (i.e., any part of the image that is not on the first line where the anchor is) is beyond the end of its text block.
    Here is how I want the page to look:
    Here, the graphic is not placed inline but sits over the text with textwrap set.
    But rather than have all my objects placed over text, I want them inline. If I place the anchor anywhere below the first line of text, (again, the line where I want the top of the image to be), text wrap won't function above the anchor point regardless of how high I move the image:
    If I place the graphic in its own paragraph above the first line of the paragraph, the result works well as long as the text preceding the anchor doesn't flow any further (i.e., no additional text is added). But as text is added and once the line holding the bottom of the photo flows to a new text block, one of two problems arises. If "Keep Within Top/Bottom Column Boundaries" is checked the graphic moves up:
    If "Keep Within Top/Bottom Column Boundaries" is unchecked, the graphic begins to bleed out of the text box:
    I can't believe there isn't a simple (or even complex) solution to this problem...

  • TOC and anchored objects

    Hi!
    I'm experiencing some problems generating the TOC.
    I design the chapter titles to stay into an anchored object before the first paragraph title but generating the TOC the chapter title is putted after the first paragraph title!
    There's a way to make indd to read the title into the anchored object first?
    Thank you!

    Thanks to everyone for the help and sorry if I can answer just now.
    I'm probably doing something wrong in anchoring the object, I don't use this method often. I need to put the chapter title in a frame that everything is within a fluid text, so that if I remove or add some text the title box moves accordingly.
    The method I used to anchor the text frame with the title chapter is to hold down the shift key and drag (I'm using windows7) on the black square. And it works great, if not for this issue of the TOC!
    I accept any kind of suggestion!
    @ Uwe: using this method to anchor I can't move the frame to right or left... So nothing change...

  • 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.

  • 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 ;)

  • How to get UserPrincipalName if getUserPrincipalName() return null?

    Hi Everybody,
    Issue like topic posted. This issue is directed related to To Frank: how to have some pages not need login while ADF Security is on
    let me re-cap the use case: I have a web apps with security implemented. A welcome page with no ADF BC access is out of security as the main entry. All works fine until I need to add user registration functionality to the apps. I added a method binding to the welcome page to link to use registration page. The problem is I have custom codes in prepareSession() in application module to set the User Principle after security login as the current user. After I added the method binding to the welcome page. The AM was accessed at the first time in welcome page and the UserPriciple in user session is set to null. After login, the UserPriciple is not reset to the login user. So I get null when I call getUserPrincipalName(). So my problem is how could I get UserPrincipalName without use session from AM? Can I use JSF security and how?
    thanks everyone!

    "ObjectID"? I may be wrong but I think it's up the JVM how to deal with issues like this. The default response from toString doesn't have to be what it usually is, and isn't guaranteed to have any meaning.
    You can't do pointer arithmetic in Java, if that's what you're hoping for.
    But check out System.identityHashCode. That plus getClass.getName plus an @ plus formatting as hex will get the string you want.

  • Return statement and accessing object's variable

    I want to return object variable but I am not sure how
    that is the constructor which takes int as arg.
    public class VHS implements MyInterface
    int year;
    public VHS (int year)
    this.year = year;
    Now I create new object in main class
    VHS currentMovie;
    currentMovie = new VHS(1995);
    int movieYear;
    System.out.println("enter the year of movie: ");
    movieYear=Keyboard.readInt();
    currentMovie.movieTitle(movieYear);
    System.out.println("passed as parameter when creating obj = new VHS(" currentMovie ")" );
    currentMovie.userInput();
    // it printout the year entered by user and works fine, however the thing above it dont, it is supposed to return the same thing
    // the problem is with currentMovie. I know I could do it differently, but I am curious if I could somehow printout the argument that was passed to the object using currentMovie.
    I quess I would need toString method but if I create it I got a message incompatible types :
    public String toString()
    return year; // year is an int
    If anyone is able to understand what I am trying to do, please respond
    and thank you , this forum already helped me very much, much more than my professors :) who are extremally weird

    public String toString()
    return year; // year is an int
    }Of course it says incompatible types. You're trying to return with an int, when you declared that the method should return String.
    String, although it is an object in Java, is treated differently. You can convert any primitive value to String easily. You also can convert any kind of objects to String as well.
    In case of primitives, one of the "wrapper" classes will be used to convert the primitive to string. In case of objects, the toString method of the object will be used to convert.
    Since you want to convert an int (primitive) to string, the easiest way perhaps:
    return "" + year;
    Since one of the operands has the type of String, the operator will change to be the "concatenate strings" operator, and the other operand will be converted to string. The returning type of the expression is String, and that's what it should be.
    You also might use the static method of the Integer wrapper class:
    return Integer.toString(year).

  • 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

  • EjbFindByPrimaryKey returns null

    Hello,
    We are writing an BMP in 6.1 SP 2. The ejbLoad perfectly loads the data.
    From the Remote using the getPrimaryKey() to get the PrimaryKey. That key
    is passed to the findByPrimaryKey(PK) call. But, it returns the following.
    I have the db-is-shared to false in weblogic-ejb-jar.xml. It looks like it
    is returning null and I don't understand why it is doing like this. Whether
    it is because, it is not able to find the object through the
    findByPrimaryKey or I am making any mistakes.
    I even system.out.println inside the ejbFindByPrimaryKey and the key is not
    null, it is having the value. Any help is greatly appreciated.
    mcar.ejb.rbm.RBMCustomBean_ocyn82_Impl - ejbFindByPrimaryKey - 1
    mcar.ejb.rbm.RBMCustomPK@10a07 - PFINA
    mcar.ejb.rbm.RBMCustomBean_ocyn82_Impl - refresh - 1 : PFINA - false
    mcar.ejb.rbm.RBMCustomBean_ocyn82_Impl - ejbFindByPrimaryKey - 2
    mcar.ejb.rbm.RBMCustomPK@10a07 - PFINA
    Did not find for the CUID another : PFINA
    java.rmi.RemoteException: The findByPrimaryKey method from home:
    mcar.ejb.rbm.RBMCustomHome was passed: null, but it returned null
    mcar.ejb.rbm.RBMCustomBean_ocyn82_Impl - ejbFindByPrimaryKey - 2
    mcar.ejb.rbm.RBMCustomPK@e5a5f - PFINA
    Did not find for the CUID another : PFINA
    java.rmi.RemoteException: The findByPrimaryKey method from home:
    mcar.ejb.rbm.RBMCustomHome was passed: null, but it returned null
    Start server side stack trace:
    java.rmi.RemoteException: The findByPrimaryKey method from home:
    mcar.ejb.rbm.RBMCustomHome was passed: null, but it returned null
    at
    weblogic.ejb20.manager.BaseEntityManager.findByPrimaryKey(BaseEntityManager.
    java:443)
    at
    weblogic.ejb20.manager.BaseEntityManager.remoteFindByPrimaryKey(BaseEntityMa
    nager.java:376)
    at
    weblogic.ejb20.internal.EntityEJBHome.findByPrimaryKey(EntityEJBHome.java:33
    2)
    at
    mcar.ejb.rbm.RBMCustomBean_ocyn82_HomeImpl.findByPrimaryKey(RBMCustomBean_oc
    yn82_HomeImpl.java:99)
    at mcar.ejb.rbm.RBMCustomBean_ocyn82_HomeImpl_WLSkel.invoke(Unknown
    Source)
    at
    weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:298)
    at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
    :93)
    at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:267)
    at
    weblogic.rmi.internal.BasicServerRef.dispatch(BasicServerRef.java:166)
    at
    weblogic.rmi.internal.ServerRequest.sendOneWayRaw(ServerRequest.java:92)
    at
    weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:112)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :262)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :229)
    at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
    at $Proxy80.findByPrimaryKey(Unknown Source)
    at
    jsp_servlet.__HMqwestagentform._jspService(__HMqwestagentform.java:173)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :265)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :304)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :200)
    at
    weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
    ntext.java:2495)
    at
    weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
    :2204)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    End server side stack trace
    <<no stack trace available>>
    JSP Exception : java.lang.NullPointerException
    java.lang.NullPointerException
    at
    jsp_servlet.__HMqwestagentform._jspService(__HMqwestagentform.java:181)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :265)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :304)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :200)
    at
    weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
    ntext.java:2495)
    at
    weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
    :2204)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    Thanks,
    Ganesh

    Sentence fragments.
    Missing predicates.
    It's a bit hard trying to understand your questions.
    In BMP you write the ejbFindByPrimaryKey method. Your job in that method is
    to verify that it exists in the DB and throw an ObjectNotFoundException if
    not. You return the valid PK (the one passed in) if it does exist. So, what
    exactly is returning null?
    "Ganapathy Sankaran" <[email protected]> wrote in message
    news:[email protected]...
    Hello,
    We are writing an BMP in 6.1 SP 2. The ejbLoad perfectly loads the data.
    From the Remote using the getPrimaryKey() to get the PrimaryKey. That key
    is passed to the findByPrimaryKey(PK) call. But, it returns thefollowing.
    I have the db-is-shared to false in weblogic-ejb-jar.xml. It looks like it
    is returning null and I don't understand why it is doing like this.Whether
    it is because, it is not able to find the object through the
    findByPrimaryKey or I am making any mistakes.
    I even system.out.println inside the ejbFindByPrimaryKey and the key isnot
    null, it is having the value. Any help is greatly appreciated.
    mcar.ejb.rbm.RBMCustomBean_ocyn82_Impl - ejbFindByPrimaryKey - 1
    mcar.ejb.rbm.RBMCustomPK@10a07 - PFINA
    mcar.ejb.rbm.RBMCustomBean_ocyn82_Impl - refresh - 1 : PFINA - false
    mcar.ejb.rbm.RBMCustomBean_ocyn82_Impl - ejbFindByPrimaryKey - 2
    mcar.ejb.rbm.RBMCustomPK@10a07 - PFINA
    Did not find for the CUID another : PFINA
    java.rmi.RemoteException: The findByPrimaryKey method from home:
    mcar.ejb.rbm.RBMCustomHome was passed: null, but it returned null
    mcar.ejb.rbm.RBMCustomBean_ocyn82_Impl - ejbFindByPrimaryKey - 2
    mcar.ejb.rbm.RBMCustomPK@e5a5f - PFINA
    Did not find for the CUID another : PFINA
    java.rmi.RemoteException: The findByPrimaryKey method from home:
    mcar.ejb.rbm.RBMCustomHome was passed: null, but it returned null
    Start server side stack trace:
    java.rmi.RemoteException: The findByPrimaryKey method from home:
    mcar.ejb.rbm.RBMCustomHome was passed: null, but it returned null
    at
    weblogic.ejb20.manager.BaseEntityManager.findByPrimaryKey(BaseEntityManager.
    java:443)
    at
    weblogic.ejb20.manager.BaseEntityManager.remoteFindByPrimaryKey(BaseEntityMa
    nager.java:376)
    at
    weblogic.ejb20.internal.EntityEJBHome.findByPrimaryKey(EntityEJBHome.java:33
    2)
    at
    mcar.ejb.rbm.RBMCustomBean_ocyn82_HomeImpl.findByPrimaryKey(RBMCustomBean_oc
    yn82_HomeImpl.java:99)
    atmcar.ejb.rbm.RBMCustomBean_ocyn82_HomeImpl_WLSkel.invoke(Unknown
    Source)
    at
    weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:298)
    at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
    :93)
    at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:267)
    at
    weblogic.rmi.internal.BasicServerRef.dispatch(BasicServerRef.java:166)
    at
    weblogic.rmi.internal.ServerRequest.sendOneWayRaw(ServerRequest.java:92)
    at
    weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:112)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :262)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :229)
    at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
    at $Proxy80.findByPrimaryKey(Unknown Source)
    at
    jsp_servlet.__HMqwestagentform._jspService(__HMqwestagentform.java:173)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :265)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :304)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :200)
    at
    weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
    ntext.java:2495)
    at
    weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
    :2204)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    End server side stack trace
    <<no stack trace available>>
    JSP Exception : java.lang.NullPointerException
    java.lang.NullPointerException
    at
    jsp_servlet.__HMqwestagentform._jspService(__HMqwestagentform.java:181)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :265)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :304)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :200)
    at
    weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
    ntext.java:2495)
    at
    weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
    :2204)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    Thanks,
    Ganesh

Maybe you are looking for

  • How to see the total imports purchase.

    Hi, We want to see the Value of Imports Purchase, Please suggest the T Codes. Does the  Values includes the Customs Duty & othe chrages like Insurance, CHA. Regards,

  • Firefox for Mac: Upload/Attachment window won't disappear

    Howdy - I recently upgraded to OS X Yosemite 10.10, and Firefox 32.0.3. Frequently, but without consistency, the upload file or attachment window will not disappear after I have selected a file. For example, in Wordpress, I will go to import a file t

  • Creating EVS , OVS with RFC in WebDynpro Java (F4)

    Hello All, I am struggling with EVS creation through aRFC. I followed all the tutorials given on the SDN, but of no use till now. I have two DC's <b>rmmodel</b> and <b>rmcomponents</b> I have created <b>Model</b> in the rmmodel DC through aRFC and ad

  • Bapi for updating data

    I am using a bapi for getting data into infotype BAPI_EMPLOYEE_GETDATA. Is there any BAPI for updating data ? regards Balaji

  • How do i delete my system configuration?

    Does anyone know how I can delete my System Configuration?? I have a MacBook Pro (Mac OSX version 10.5.8).