Instantiating objects in cfc (CF9)

Hi all,
in certain cases it is necessary to me to instantiate objects like this:
I think to remember that I've read recently that this kind of instantiating isn't recommended. So I just wanted to ask the veterans about it.
Mostly I use this way in cases where recursion are used so I do not need to reinstantiate the objects with each recursive call of a function.
Thanks in advance
Hurga

Oh, sorry...there is no edit button.
Here it is:
<cfcomponent...>
<cfset this.myObj = new myCFC() />
<cffunction...>
some code
</cffunction>
</cfcomponent>

Similar Messages

  • Instantiating Object with NDS

    I'm having no success in instantiating object with NDS. Does anyone know whether is possible?
    I can hard code a statement as follows:
    pkg1.gs_nt(gs_nt.LAST) := NEW SomeObject_ot('x');
    where pkg1 is a package with the gs_nt variable declared in the spec. (global scope). The var. gs_nt is a nested table of SomeObject_ot type.
    When I try to use the same approach using NDS I get error messages at compile time:
    PLS-000103: Encountered the symbol "" - When I try to use the SomeObject_ot in a USING clause to set the value of a placeholder. In other words, it doesn't do the substitution.
    PLS-00382: expression is of wrong type - when I try to concatenate the object with a string.
    Based on the above, I've concluded that NDS can't be used to instantiate object types.
    Is thsi conclusion correct? Does anyone have a solution?

    Does this do what you need?
    SQL> create or replace type SomeObject is Object (
      2         val varchar2(10)
      3  ) ;
      4  /
    Type created.
    SQL>
    SQL> create or replace type SomeObject_nt is table of SomeObject ;
      2  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE pkg1 IS
      2      gs_nt someobject_nt;
      3      PROCEDURE initialize(p_var IN VARCHAR2,
      4                           p_obj IN VARCHAR2);
      5  END;
      6  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY pkg1 IS
      2      PROCEDURE initialize(p_var IN VARCHAR2,
      3                           p_obj IN VARCHAR2) IS
      4          str VARCHAR2(4000);
      5      BEGIN
      6          str := 'begin ' ||
      7                 '  ' || p_var ||'.EXTEND ; '||
      8                 '  ' || p_var || '(' || p_var ||'.LAST) := NEW ' || p_obj || '(:val) ; ' ||
      9                 'end ;';
    10          dbms_output.put_line('Count=' || pkg1.gs_nt.COUNT);
    11          EXECUTE IMMEDIATE str
    12              USING 'String';
    13          dbms_output.put_line('Count=' || pkg1.gs_nt.COUNT || ' pkg1.gs_nt(1).val='||pkg1.gs_nt(1).val);
    14      END;
    15  BEGIN
    16    gs_nt := SomeObject_nt() ;
    17  END;
    18  /
    Package body created.
    SQL> set serveroutput on size 100000
    SQL> exec pkg1.initialize(p_var => 'pkg1.gs_nt',p_obj => 'SomeObject') ;
    Count=0
    Count=1 pkg1.gs_nt(1).val=String
    PL/SQL procedure successfully completed.
    SQL>

  • How do i add the same mouselistener to many different instantiated objects?

    This is for a card game.
    The deck class instantiates 52 cards from the card class.
    The game has a deck of cards. I am dealing each player their cards, the player is to be dealt 8 cards each of which should have a mouselistener.
    How do I add the same mouselistener to each of the cards dealt.
    This is how I have it so far but it only adds a mouselistener to the last card dealt.
         public void dealPlayerACard()
              taken = availableCards.dealCard();
              taken.showCard();
              taken.addMouseListener(this);
         public void mouseClicked(MouseEvent MEvent)
              playerHand.remove(taken);
              paintHand(playerHand);
              playerHand.repaint();
    Any help would be appreciated

    Yeh I have 52 card object in the deck. Theyre not individually named, they were instantiated in the deck class.
    standardDeck.add(new Card(a, b, new ImageIcon(str), cardBack)); //creating and then adding the cards
    So i draw one card at a time, and I had a mouselistener to that particular card. But the thing is, When the cards are clicked, some checking happens and if the move is legal, the card is added back into the deck and its mouselistener should be removed. This is because that card could then be added to the computers hand, and I dont want no player using the computer players cards.
    The game deals the cards to players, players use the cards and then send them to the bottom of the deck, the deck is shuffled and then the game continues until a condition is met by either of the players.
    So i dont understand how a loop solution would work here. My mind is blank at the moment, maybe im not understanding properly. I am new to java. So if you do know the answer, please tell it to me. Please dont wait for a lightbulb to appear above my head. ;)

  • Problem Accessing Instantiated Objects

    I'm sorry for the long code that follows. Am hoping that someone can point out some ideas for how to structure this properly. Following my instructor's cookie requirements, the first panel two user inputed balances and an interest rate. Two objects are instantiated, one for each balance, in a seperate class. The results of 12 months of savings are then displayed in the 2nd panel. There is then the required option to change the interest rate. When modified, it should show the new interests and balances for the original balances instead.
    I successfully got the first set of interests and new balances, and thought, "sweet! I'm home free now!"
    Because God himself hates me, this is of course not the case. It's not recognizing the objects in the second event, which is modifying the interest rate.
    I'm not sure how I can restructure this so that the objects which are instantiated using user input can be accessible by both events. If anybody can suffer through looking at all this junk and has some ideas (or even just some general advice on how to manipulate objects), I'd appreciate it.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.DecimalFormat;
    public class SavingsTest extends JFrame
        private JLabel balanceLabel, dollaSign, balanceLabel2, dollaSign2, percentSign, rateLabel;
        private JTextField balanceField, balanceField2, rateField;
        private JTextArea displayArea;
        private JButton submitButton, modifyButton;
        private String cBalance1S, cBalance2S, intRateS;
        private double cBalance1, cBalance2, intRate, oldBalance1, oldBalance2;
        // Constructor creates frame
        public SavingsTest ()
            super( "Savings Calculator" );
            Container container = getContentPane();
            JPanel mainPanel = new JPanel();
            mainPanel.setLayout(new FlowLayout());
            mainPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));   
    *          INPUT PANEL        *
            JPanel inputPanel = new JPanel();
            inputPanel.setLayout(null);        
            inputPanel.setPreferredSize(new Dimension(500,250));         
      //      inputPanel.setBackground(Color.white);       
            inputPanel.setBorder(BorderFactory.createCompoundBorder(
                          BorderFactory.createTitledBorder("Enter Data"),
                          BorderFactory.createEmptyBorder(5,5,5,5)));
            // Consumer 1 Balance Components
            balanceLabel = new JLabel ("Enter Customer 1 balance:"); 
            balanceLabel.setBounds(85,25,168,24);
            inputPanel.add(balanceLabel);
            dollaSign = new JLabel ("$ "); 
            dollaSign.setBounds(125,55,168,24);
            inputPanel.add(dollaSign);       
            balanceField = new JTextField(10);
            balanceField.setBounds(145,55,50,24);
            inputPanel.add(balanceField);
            // Consumer 2 Balance Components
            balanceLabel2 = new JLabel ("Enter Customer 2 balance:"); 
            balanceLabel2.setBounds(265,25,168,24);
            inputPanel.add(balanceLabel2);
            dollaSign2 = new JLabel ("$ "); 
            dollaSign2.setBounds(305,55,168,24);
            inputPanel.add(dollaSign2);       
            balanceField2 = new JTextField(10);
            balanceField2.setBounds(325,55,50,24);
            inputPanel.add(balanceField2);        
        // Interest Rate Components      
            rateLabel = new JLabel ("Enter annual rate :"); 
            rateLabel.setBounds(215,105,168,24);
            inputPanel.add(rateLabel);
            percentSign = new JLabel ("% "); 
            percentSign.setBounds(215,145,168,24);
            inputPanel.add(percentSign);       
            rateField = new JTextField(10);
            rateField.setBounds(235,145,50,24);
            inputPanel.add(rateField); 
         // Submit Button Component
            submitButton = new JButton("SUBMIT");
            submitButton.setBounds(215, 185, 80, 30);
            inputPanel.add(submitButton);
            mainPanel.add(inputPanel);             
    *          DISPLAY PANEL      *
            JPanel displayPanel = new JPanel();
            displayPanel.setLayout(null);        
            displayPanel.setPreferredSize(new Dimension(500,375));        
            displayPanel.setBorder(BorderFactory.createCompoundBorder(
                          BorderFactory.createTitledBorder("Monthly Interest & Balances"),
                          BorderFactory.createEmptyBorder(5,5,5,5)));
            // Modify Interest Rate Button Component
            modifyButton = new JButton("Modify Rate");
            modifyButton.setEnabled( false );       
            modifyButton.setBounds(215, 25, 80, 30);
            displayPanel.add(modifyButton);    
            // Display Area Component
            displayArea = new JTextArea(); 
            displayArea.setEditable(false);
            displayArea.setBounds(25,85,445,275);
            displayPanel.add(displayArea);          
            mainPanel.add(displayPanel);    
    *         MAIN PANEL           *
            container.add( mainPanel);      
            setSize(630, 700);
            setVisible( true );  
    *     SUBMIT BUTTON EVENT               *
    submitButton.addActionListener(
              new ActionListener()
         { // Open ActionListener
              public void actionPerformed (ActionEvent e)
                        getInput();
         } // Close ActionListener
    *          MODIFY BUTTON EVENT          *
    modifyButton.addActionListener(
              new ActionListener()
         { // Open ActionListener
              public void actionPerformed (ActionEvent e)
                        modifyInput();
         } // Close ActionListener
        }  // End Constructor
    public static void main ( String args[] )
          SavingsTest initiate = new SavingsTest();
          initiate.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
       private void getInput()
                // Get values from fields and assign to Strings
                cBalance1S = balanceField.getText();
                balanceField.setText("");
                cBalance2S = balanceField2.getText();
                balanceField2.setText("");
                intRateS = rateField.getText();
                rateField.setText("");
                // Parse Strings to doubles, etc
                cBalance1 = Double.parseDouble(cBalance1S);           
                cBalance2 = Double.parseDouble(cBalance2S);
                intRate = Double.parseDouble(intRateS);           
                intRate = intRate * .01;
                oldBalance1 = cBalance1;
                oldBalance2 = cBalance2;
                submitButton.setEnabled( false );
                modifyButton.setEnabled( true );
                SavingsAccount account1 = new SavingsAccount(cBalance1, intRate);
                SavingsAccount account2 = new SavingsAccount(cBalance2, intRate);              
                displayArea.append("\t         Account 1\t\t         Account 2\n");
                displayArea.append("\tInterest\tBalance\tInterest\tBalance\n");
                DecimalFormat twoDigits = new DecimalFormat( "0.00");
                // Calculate Interests & Balances, then display
                for (int i = 1; i <13; i++)
                    double interest1 = account1.calculateMonthlyInterest ();
                    double interest2 = account2.calculateMonthlyInterest ();
                    double newBalance1 = account1.calculateNewBalance(interest1);
                    double newBalance2 = account2.calculateNewBalance(interest2);
                    displayArea.append("Month " + i + ":\t" + twoDigits.format(interest1)
                    + "\t" + twoDigits.format(newBalance1) + "\t" +
                    twoDigits.format(interest2) + "\t" + twoDigits.format(newBalance2)
                    + "\n");
       private void modifyInput()
         intRateS = JOptionPane.showInputDialog(" Enter new annual rate: ");       
            intRate = Double.parseDouble(intRateS);
            SavingsAccount.modifyInterestRate(intRate);
            displayArea.setText("");
                displayArea.append("\t         Account 1\t\t         Account 2\n");
                displayArea.append("\tInterest\tBalance\tInterest\tBalance\n");
                DecimalFormat twoDigits = new DecimalFormat( "0.00");
                // Calculate Interests & Balances, then display
                for (int i = 1; i <13; i++)
                    // ERROR IS HERE WHERE IT DOES NOT RECOGNIZE THE OBJECTS
                    double interest1 = account1.calculateMonthlyInterest ();
                    double interest2 = account2.calculateMonthlyInterest ();
                    double newBalance1 = account1.calculateNewBalance(interest1);
                    double newBalance2 = account2.calculateNewBalance(interest2);
                    displayArea.append("Month " + i + ":\t" + twoDigits.format(interest1)
                    + "\t" + twoDigits.format(newBalance1) + "\t" +
                    twoDigits.format(interest2) + "\t" + twoDigits.format(newBalance2)
                    + "\n");
     

    I believe I did indeed state was not being recognized.I didn't see it. But then, I didn't read all your code either. That's not me (or paul) being an asshole--it's just too much code.
    Besides in the content of my post, if I were a
    gambling woman, I'd wager it's probably within that
    code which you went through so much trouble to make
    sure everybody knows you aren't reading. He wasn't doing that for anybody's benefit but your own. That is a lot of code to read. Pasting in the exact error message the compiler gave you would have made it a lot easier for someone to help you. Yawmark waas very kind, but in general, if you want help here, you should post details about what the problem is. "Not recognizing objects" means next to nothing, but the actual error message tells us a lot. In fact, you should take a stab at reading it yourself. Error messages are your friends. They tell you pretty precisely what was wrong and where.
    It says
    exactly where the objects are unrecognizable. It's
    even in big, red, pretty letters.The compiler gave you a lot more detail than that. You didn't indicate which objects.
    But why make posts which make coherent sense when you
    could just make an ass of yourself without all that
    silly reading.Paul's comments were intended to goad you into posting something that would make it easier for people to help you.
    >
    For example, complaining that there's too much code
    (having seen only half the code at that), It doesn't matter if that was only 0.001% of your code. It's too much to post here for that problem. It's understandable that you wouldn't know that, as you're new here, but copping an attitude instead of accepting the constructive criticism doesn't really accomplish anything.
    The only thing lending itself to the idea that God
    hates me is the fact that he let some idiot such as
    yourself wonder into this thread. There are some
    brilliant, wonderful, kind, and very helpful people on
    these forums to which I am eternally grateful. Then I
    guess there's also you.Actually, paulcw helps a lot of people here. Like most of us, he gets annoyed sometimes at poorly constructed questions.
    I hope that you won't take the above as a personal attack. It's not intended that way. It's intended to be constructive criticism.

  • Passing a Flex object to CFC

    I have no problem passing a query object to my Flex app and
    use it to populate a datagrid (arraycollection).... however, I want
    to use this same data to update the database when the user clicks
    on save, and instead of looping through each row (calling my
    remoteobject each time) is there a way I can format this
    information into an array, array collection or some other form of
    flex object and pass ti back to another cfc function to do the
    update?????
    I've read elsewhere that its possible to do with a
    remoteobject, however, my attempts were futile and I cannot find an
    example anywhere.
    I cant find a solution anywhere so and help would be
    appreciated.

    Here is a simple example I just wrote real quick. This is how
    I normally go about passing something an array of items to
    Coldfusion. Hope this helps.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.managers.CursorManager;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.events.FaultEvent;
    [Bindable] private var apples:Array = new Array(
    {name:"Normal Apple", color:"Red"},
    {name:"Sweet Apple", color:"Ged"},
    {name:"Rotten Apple", color:"Brown"});
    private function createApples():void {
    AppleManager.Create_Apples(apples);
    private function createApplesResult(event:ResultEvent):void
    Alert.show("You have successfully added some apples into our
    system.", "System Notice");
    ]]>
    </mx:Script>
    <mx:RemoteObject
    id="AppleManager"
    destination="ColdFusion"
    source="cfc.AppleManager"
    endpoint="Your endpoint here"
    showBusyCursor="true"
    fault="CursorManager.removeBusyCursor();Alert.show(event.fault.message,
    'System Notice')">
    <mx:method name="Create_Apples"
    result="createApplesResult(event)"/>
    </mx:RemoteObject>
    <mx:Button x="10" y="10" label="Create Apples"
    click="createApples()"/>
    <mx:DataGrid left="10" right="10" top="40" bottom="10"
    dataProvider="{apples}">
    <mx:columns>
    <mx:DataGridColumn headerText="Apple Name"
    dataField="name"/>
    <mx:DataGridColumn headerText="Apple Color"
    dataField="color"/>
    </mx:columns>
    </mx:DataGrid>
    </mx:Application>

  • Design Question::Instantiating Object from Stored Procedure Output

    Hi All,
    I am confused with approaching this design issue. I called a Stored Procedure, and the output from the Stored Procedure is a REF CURSOR. The size of the REF CURSOR can be large.
    My Question is, is it a good idea to pass the values from the REF CURSOR to a class constructor, there by instantiating an object of that type. lets say
    //rset is of type ((OracleCallableStatement)callableStatement).getCursor(5);
    //rset is not ResultType
    while (rset.next()){
    new ClassXYZ(var1, var2, var3);
    /*var1, var2, var3 would be rset.getObject(1),rset.getObject(2),rset.getObject(3)
    Class XYZ does some business logic
    }Other things:
    1) Will the JVM hold up assuming good enough JVM mem size, while creating objects for the range 100 thousands?
    2) I do not know the cursor size. It can change randomly from business perspective. And, it would be in the range of 100 thousands
    I was thinking, If I can "police" the call to the Class XYZ in case of large data. May be I am totally off the best solution. Any light on the best way to approach will be great.
    Anyhow, this would be a standalone java application. Just in case if people are trying to suggest/recommend DAO etc.,
    Thank you,
    VJ

    You can use ConvertTo-Html:
    http://ss64.com/ps/convertto-html.html
    Here's an example:
    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/5cb016d3-e2fb-43e7-9c01-10b6878056e4/formattable-lost-in-email
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Instantiating object using Class.forName()

    What is the difference between instantiating using Class.forName() method and instantiating using the new operator?

    The difference is that you can use the new operator to instantiate an object, but you can't do it using Class.forName().
    But seriously folks...
    Presumably you're talking about Class.newInstance()--which often appears right on the heels of Class.forName().
    New gives you compile-time checks you don't get with Class.forName(). If it compiles with new, then you know the constructor in question exists on the class in question.
    With Class.newInstance() (and it's cousin (also called newInstance, I think) in the Constructor class), you can't be sure until you actually execute it whether that constructor even exists.
    New requires you to know the class at compile time. NewInstance lets you defer the specific class until runtime.
    New is simpler and more direct.
    (Did I just do your homwork for you? Hope not.)

  • Instantiating Objects from the library from within the movie clip

    Ive been Instantiating Library object from linked external
    action script files and it works fine.
    var PPEbtn1 = new btnPPE;
    but when i try to do it from within the main swfs timeline it
    fails to work and i recieve an error if anyone could please help it
    would be most apreciated. thanks

    You need to get the application domain of the external swf
    and use its getDefinition method. Cast the result to a Class and
    then you can instantiate the symbol.
    Here's some example code where "library" is an externally
    loaded swf:

  • Dynamically instantiating objects using string name

    Hello to all.
    This is probably an easy question, but I am wondering how I can dynamically create instances of an object in a loop using a string variable as the name.
    The idea here is this:
                   while (someBooleanVariable) {
                        int count = 1;
    String objectName = "myObject" + count;
                        myObject objectName = new myObject; // How do I pass the objectName String variable as a name?
                        count++;
                   } // End while
    Of course this doesn't work - incompatible types, but the idea is that the code would create "myObject1," "myObject2," "myObject3," "myObject4," etc as long as someBooleanVariable = true using the objectName String variable.
    I am new to this and appreciate any help and ideas.
    Thanks!

    BigDaddyLoveHandles wrote:
    There's been this outbreak of people wanting to dynamically name their variables -- is this some sort of scripting disease?It's always been around. Shoot, I remember suffering from it when I first started out, because it seems so, hm I dunno, necessary at the time. Eventually the newbie (me) realizes that the variable "name" means nothing, that reference is everything.
    ... and then I discovered maps, and names were useful again. :o)

  • Extending an Existing Instantiated Object and ClassCastException

    I am trying to wrap a class around an object that is returned from a third party.
    "Requirement" is a class that extends "Dispatch". "Dispatch" is a class that is returned from the third party.
    I am getting a class ClassCastException error.
    requirement = (Requirement) Dispatch.call(terms, "Item", i+1, 3).toDispatch();
    I thought that I could do this.. What is the problem?
    Example below.
    Requirement requirement;
    for (int i=0;i<cnt;i++) {
    requirement = (Requirement) Dispatch.call(terms, "Item", i+1, 3).toDispatch();
    System.out.println(i + " " + requirement.getText());
    }The Requirement class extends Dispatch.
    public class Requirement extends Dispatch {
         boolean initialized = false;
         String name;
         String text;
    ...The error that I am getting is:
    Exception in thread "main" java.lang.ClassCastException: com.jacob.com.Dispatch cannot be cast to com.sita.reqpro.Requirement
         at com.sita.reqpro.EasyRqmt.main(EasyRqmt.java:49)
    I'm using: jdk1.5.0_12

    So what is the best way to do this?
    Something like this:
    Dispatch item = null;
    Requirement requirement;
         for (int i=0;i<cnt;i++) {
         item = Dispatch.call(terms, "Item", i+1, 3).toDispatch();
         requirement = new Requirement(item);
         System.out.println(i + " " + requirement.getText());
    public class Requirement {
         Dispatch dispatch;
         boolean initialized = false;
         String name;
         String text;
         public Requirement(Dispatch pDispatch) {
              name = Dispatch.get(pDispatch, "Name").toString();
              text = Dispatch.get(pDispatch, "Text").toString();
              initialized = true;
         }

  • Getting error PLS-00307: too many declarations while instantiating object.

    Hi,
    I'm using oracle 10.2.0.4.0
    I've created an object obj_bsk as follows:
    create or replace type obj_bsk as object
    (batch_set_key varchar2(64),
    constructor function obj_bsk
    return self as result,
    constructor function obj_bsk(p_batch_set_key in varchar2)
    return self as result,
    member procedure display_batch_set_key
    and object body as
    create or replace type body obj_bsk as
    constructor function obj_bsk
    return self as result is
    begin
    self.batch_set_key := sys_guid();
    return;
    end;
    constructor function obj_bsk (p_batch_set_key varchar2)
    return self as result is
    begin
    self.batch_set_key := p_batch_set_key;
    return;
    end;
    member procedure display_batch_set_key is
    begin
    dbms_output.put_line('batch_set_key is:' || self.batch_set_key);
    end;
    end;
    Then I've created a package test_obj as follows:
    specification:
    create or replace package test_obj is
    -- Author : TSHARMA
    -- Created : 31/01/2012 10:32:37
    -- Purpose : to test objects
    my_bsk obj_bsk;
    g_batch_set_key varchar2(64);
    procedure show_obj_val;
    end test_obj;
    body:
    create or replace package body test_obj is
    procedure show_obj_val is
    begin
    my_bsk.display_batch_set_key();
    end;
    begin
    -- Initialization
    if (g_batch_set_key is not null) then
    my_bsk := obj_bsk(g_batch_set_key);
    else
    my_bsk := obj_bsk();
    end if;
    end test_obj;
    When I'm compiling the package I'm getting following error:
    Compilation errors for PACKAGE BODY TSHARMA.TEST_OBJ
    Error: PLS-00307: too many declarations of 'OBJ_BSK' match this call
    Line: 12
    Text: my_bsk := obj_bsk(g_batch_set_key);
    Error: PL/SQL: Statement ignored
    Line: 12
    Text: my_bsk := obj_bsk(g_batch_set_key);
    Can anyone please explain why oracle is viewing it as too many call for constructor when both constructors are different.
    and how to resolve the issue.
    Thanks
    Tarun

    I've solved the problem. Though it is strange.
    The error occurred because I'm using p_batch_set_key as parameter constructor.
    i.e. constructor function obj_bsk(p_batch_set_key in varchar2)
    return self as result,
    once I changed it to the same name as variable name in object it compiled fine.
    i.e constructor function obj_bsk(batch_set_key in varchar2)
    return self as result,
    It is very strange. Can anyone plesae explain why the parameter name should be same as variable name in object.
    Thanks
    Tarun

  • Form Upload: Shortdump while instantiating object

    Hello,
    while uploading an interactive form I get a shortdump: CX_FP_RUNTIME_USAGE
    Create PDF Object using destination 'ADS' (<-- this is how it is
    defined in SM59)
      DATA: lo_pdfobj TYPE REF TO if_fp_pdf_object VALUE IS INITIAL.
      lo_pdfobj = lo_fp->create_pdf_object( connection = 'ADS' ).
      DATA: pdf_data TYPE xstring.
    Set document
      lo_pdfobj->set_document( pdfdata = pdf_data ).
    method if_fp_pdf_object~set_document.
    data: l_errstr type string.
      if pdffile is initial and pdfdata is initial.
    =====>    raise exception type cx_fp_runtime_usage   <=====
           exporting
            textid = cx_fp_runtime_usage=>nothing_to_do.
       endif.
    Does anybody know why this parameter pdf_data is empty,
    although I have uploaded the file before  with cl_gui_frontend_services=>gui_upload?
    Thanks
    G

    Total Posts:  440 
    Total Questions:  204 (39 unresolved) 
    Forum Points:  18 
    By the way: How comes you ask so much and answer very little? Why should people help you when you don´t bother to contribute and use others to do your job?
    Otto

  • Static functions instantiating objects

    I am a beginner in Java. I would like to know
    if a static function can instantiate other Java objects?
    X and Y are public classes.
    class Y has a static method fnStatic()
    Can Something like this allowed?
    static void fnstatic()
    X obj = new X(..);
    X. regFn();
    Meena

    Actually, I have a class Session, which has a method ProcessEvent()
    public class Session{
    public synchronized void processEvent(Event e)
    // Processing of the event
    // Generate a response for the Event
    This Session class is the mainstream code..
    Now I want to write a TestClass that will test the main code.
    So I have a Test class as below:
    public class Test {
    public static void sendReq()
    // Construct an event and call processEvent Function from the main code
    Event ev = new Event();
    // Fill the event with parameters
    Session sess = new Session();
    sess.processEvent(ev);
    What I am thinking of doing is: Call the static method in another class called Manager of the mainstream code for test purpose as follows:
    public class Manager {
    public void somefunction()
    //*** Just for test purpose: do the following line **//
    Test.sendReq();
    I am not sure what I am trying to do will work. I would appreciate if you can comment on that or suggest something that would work for me.
    Another thing which I want to do is:
    Inside ProcessEvent(), I want to call another static method ParseandValidateResponse() of the TestClass This looks odd, but as long as it works, it would be fine for me because this is only for test purpose.
    In this case, I would write,
    public class Session{
    public synchronized void processEvent(Event e)
    // Processing of the event
    // Generate a response for the Event
    Test.parseandValidateResponse(Response res);
    public class Test {
    public static void sendReq()
    // AS SHOWN PREVIOUSLY
    public static void parseandValidateResponse(Response resp)
    // validate the response
    }

  • Help with instantiating objects and validating them please

    Hello,
    im working on an assigment where i have to make a milk tank object that simulates a Milk tanker (one of those things that carrys milk :P)
    It has a specific constructor that you can pass the volume and capacity to it. I was wondering how i could validate this and make it so the object doesnt instantiate and maybe return an error message if the volume of milk exceeds the capacity of the milk tanker?
    basically i just want to make sure an object is valid while it instantiates, otherwise bomb out and return an error..
    Thank you,
    Phill
    PS: im still learning java so some stuff might be over my head, but ive got a book next to me to help me understand :) (yes, ive checked and i cant find anything on this subject)

    public MilkTanker(int volume, int capacity) throws
    InvalidArgumentException
    if (volume > capacity)
    throw new InvalidArgumentException("Volume can't be greater than >capacity");
    this.volume = volume;
    this.capacity = capacity
    }This means that while trying to create a new object of this class you need to handle a possible exception:
    public static void main (String [] args){
       try {
          MilkTanker tank = new MilkTanker(100, 1000);
       catch (InvalidArgumentException _){
          System.err.println(_.getMessage());
    }In the case that an exception is thrown the object of this class will not be created and every line of code you might have after the constructor call (inside the try clause) will not be executed.
    Hope that helped
    afotoglidis

  • Declaring String type and instantiating object

    I am using this JavaBean but I think I shouldnt be declaring String type with emply values and also instantiating the bean in the no arg constructor with null values:
    public class SimpleBean  {
         private String firstname = "";
                    private String lastname = "";
         public SimpleBean()
                          firstname = null;
                          lastname = null;
    ..Please advise.

    Evergrean wrote:
    Thanks,
    Instead of setting them to null in the Constructor I assume I should have nothing in it?Right. In fact, if that's the only constructor, and you don't do anything else in it, you can dispense with it entirely. If you don't write any constructors, the compiler will generate one for you: a default constructor that takes no arguments and does nothing but call super().

Maybe you are looking for