Passing a cfc object to another cfc

Hi,
I am relatively new to using cfc, so I am not sure if what I am asking for is possible:
Can I pass a CFC object (that has been instantiated) to another CFC?  For example, I instantiate a CFC object
<cfobject component="CFC1" name="myCFC1Obj">
<cfset myCFC1Obj.init('abc')>
Now I want to instantiate a second CFC object
<cfobject component="CFC2" name="myCFC2Obj">
I would like the functions in myCFC2Obj to have access to myCFC1Obj variables
and functions, either by passing myCFC1Obj as a function argument or by
using myCFC1Obj to instantiate myCFC2Obj.
I have read http://forums.adobe.com/message/1894989#1894989, but this
deals with instantiating CFC1 object inside CFC2.  What I want is to instantiate
CFC1 object outside and pass it to CFC2.
Would I be able to do this?
Thank you.

An CFC instance (object) is just a variable like any other variable.  So there's no trick to passing it into a function as an argument, you just do it as you would with any other value.
In your <cfargument> tag, if you're wont to specify the TYPE attribute, it needs to be the CFC name or path (I use path).  That's the only real special consideration.
Adam

Similar Messages

  • How to pass a locale object into another function?

    Greetings,
    i like to pass a locale object into another function. These are my code below
    import java.util.*;
    public class Locales{
         public static void main(String[] args){
              Locale locale= new Locale("EN", "US");
              convert(locale);
    public void convert(Locale convert)
         String language = convert.getDisplayLanguage();
         System.out.println(language);          
    }I got this error:
    Locales.java:6: non-static method convert(java.util.Locale) cannot be referenced from a static content
                    convert(locale);
                    ^How do i correct it?
    Thanks

    Did you bother to do a search?
    Did you bother to read any of the material that the search would have linked you to?
    If you had then you would be able to understand where you are going wrong and how to fix it yourself. Instead of being spoonfed by us.

  • Passing an object to a cfc as an argument

    I am trying to pass an object of java.util.RegularEnumSet into a CFC as an argument. This object contains several methods, but when I try to use any of these methods inside the CFC it is telling me there is no such methods in my enum set. When I use these java methods outside of my cfc on a test page it works just fine, any ideas why I cant pass this java object into my cfc and use the object's methods? Thanks in advance.

    I'm guessing that cfc's were not designed with your intended use in mind.  Why don't you simply create an object inside your cfc?

  • How to pass arraylist of object from action class to jsp and display in jsp

    I need to do the following using struts
    I have input jsp, action class and action form associated to that. In the action class I will generate the sql based on the input from jsp page/action form, create a result set. The result set is stored as java objects in a ArrayList object.
    Now I need to pass the arraylist object to another jsp to display. Can I put the ArrayList object in the request object and pass to the success page defined for the action? If this approach is not apprpriate, please let me know correct approach.
    if this method is okay, how can I access the objects from arraylist in jsp and display their property in jsp. This java object is a java bean ( getter and setter methods on it).
    ( need jsp code)
    Can I do like this:
    <% ArrayList objList = (ArrayList)request.getattribute("lookupdata"): %> in jsp
    (***I have done request.setattribute("lookupdata", arraylistobj); in action class. ***)
    Assuming the java object has two properties, can I do the following
    <% for (iint i=0. i<objList.size;I++){ %>
    <td> what should i do here to get the first property of the object </td>
    <td> what should i do here to get the first property of the object </td>
    <% }
    %>
    if this approach is not proper, how can I pass the list of objects and parse in jsp?
    I am not sure what will be the name of the object. I can find out how many are there but i am not sure I can find out the name
    thanks a lot

    Double post:
    http://forum.java.sun.com/thread.jspa?threadID=5233144&tstart=0

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

  • How can I send a mapping based CFC object?

    I got an exception on sending a CFC object through
    EventGateway for Flex Messaging. The result of SendGatewayMessage
    says
    FALSE: Error on server: java.rmi.UnmarshalException: error
    unmarshalling arguments; nested exception is:
    java.lang.ClassNotFoundException: coldfusion.runtime.Array (no
    security manager: RMI class loader disabled)
    If the CFC is under web root, it works... I changed
    eventgateway config (e.g. use-structs, use-accessors, adding
    use-mappings) and tried them. But it does not work at all.
    Is this a bug?

    Well the OO theory says that objects comunicate via messages, now that information must be taken as knowledge only, not for programming issues really. What you need to know is that when you need to pass any data from onw object to another you can send them via parameters of defined methods.
    For example you have an Object called R of a receiver class and that object needs to pass a String (text message) to another object. you can do it via a method.

  • Need a way to pass object to another application

    Hello Everyone,
    I need to pass an object from one application to another. I wanted to do that using request.setAttribute(Object) but this works only on RequestDispatcher.forward(URL) method and can be used only within the application you are currently in. It does not work for absolute URLs therefore I cannot go to another application. I also tried response.sendRedirect(URL) but then request object is lost when redirected to another application.
    Any help will be greatly appreciated,
    Thanks in advance,
    Y.M.

    if your two application servers are on the same box,
    then you can get the RequestDispatcher object from
    another ServletContext and then use the
    request.setAttribute() call.
    ServletContext newContext =
    getServletContext().getContext(webApp);
         if( newContext == null )
    throw new IllegalArgumentException("Invalid webApp
    p '"+webApp+"' does not exist.");
    request.setAttribute("myobject", objToPass) ;
    RequestDispatcher dispatcher =
    newContext.getRequestDispatcher(urlToGoTo) ;
    dispatcher.forward(request, response);
    Unfortunately those apps are on different servers ...

  • Return query from one CFC to another CFC

    I have a CFC called "order.cfc". Also in this app is a CFC
    called "user.cfc".
    In my order.cfc, one of the functions will setup and create a
    new order for an existing user. The user ID is passed to the
    function "createOrder" in order.cfc.
    Instead of duplicating a function called "getUser" from
    user.cfc, I figured I could pass the arguments.userID from
    order.cfc over to the getUser function of user.cfc and get my query
    result back:
    <cfset thisCustomer =
    createObject("component","user").getUser(arguments.userID) />
    Obviously, I'm doing something wrong as I keep getting this
    error message:
    The value returned from function getUser() is not of type
    query.
    However, getUser does return a proper query data type when I
    access that component directly and not from this other cfc.

    quote:
    Originally posted by:
    Newsgroup User
    What is the difference you and Dan perceive in using
    <cfinvoke> over
    createObject() (<cfset> really has nothing to do with
    it).
    Adam
    Since you asked.
    This is the line of code:
    <cfset thisCustomer =
    createObject("component","user").getUser(arguments.userID) />
    My style is to be a bit more methodical. If I were going to
    use createobject, I would do it like this:
    MyObject = createObject("component","user");
    thisCustomer = MyObject.getuser(arguments.userID);
    If I wanted to do it in one line, or if I were only going to
    call one function from that component, I'd use cfinvoke.
    I'm simply not clever enough to try using cfset like that. I
    had no idea it would work.

  • Problem in reading an object inside another obj in C thru JNI

    Hi All,
    I am passing a java class object from Jave to C thru JNI.
    This object has many integer fields + one object of another class, which also has some fields.
    I am able to read integer fields from C but not able to read fields inside another object.
    Can anyone plz help me in reading the object inside another object from C.
    I m pasting class here for better understanding :
    public class ImageMergeInformation {
    public ImageInformation outputImageInfo;
    public ImageInformation[] inputImageInfo = new ImageInformation[8];
    public int topMargin;
    public int bottomMargin;
    I wanna read ImageInformation obj.
    Plz help me...
    Thanks in Advance,
    Regards,
    Sneha

    You have to get the field id (getFieldID) of the variable you want, e.g. outputImageInfo, then get the object (getObjectField) in that field. At this point, you can start over (get the class, get the field id, get the object).

  • How to pass the java object into the spring controller

    Hi Friends
    When I hit the url at the first time my call goes to the spring controller and sets the userDetails objects in the modelAndView.addObject("userDetails", userDetails.getUserDetails()) and returns the userDetails.html page. if I click any link in the same page i want to pass same (userDetails) object thru javascript or jquery and calls the another(controller) method and returns the same (userDetails.html) page.
    It means how can i pass the java object thru javascript or jquery and calls the controller. if i get the same object in my controller i can avoid calling the db again. please help me out to resolve this issue. i am tired of fixing this issue.
    Regards
    Sherin Pooja

    If you want to avoid calling the database again then cache the data.
    However before you do that make sure that calling the database, in the context of YOUR system, is going to be an actual problem.
    For example there is absolutely no point in caching a  User object when only one user an hour is actually using the system.

  • How can i send a MESSAGE from an object to another object?

    i've following code:
    class Receiver {
         private String str = "Your message is recieved to me.";
         String sendBack() {
              return str;
    class Sender {
         public static void main(String[] args) {
              Receiver r = new Receiver();
              System.out.println(r.sendBack());
    }I'm confused with the concept of MESSAGE in java. All i gather about it is that when two objects want to communicate with each other they send messages to each other. One object is sender of message and other is its receiver.
    Here reciever object 'r' itself performs its method and does not communicate with any other object. How do i change this code into where two objects communicate with each other?

    Well the OO theory says that objects comunicate via messages, now that information must be taken as knowledge only, not for programming issues really. What you need to know is that when you need to pass any data from onw object to another you can send them via parameters of defined methods.
    For example you have an Object called R of a receiver class and that object needs to pass a String (text message) to another object. you can do it via a method.

  • Is it possible in java to pass reference of object in Java?

    Hello,
    I'm relativily new to Java but I have "solid" knowledge in C+ and C# .NET+.
    Is it possible in java to pass reference of object in Java? I read some articles about weakreferences, softreferences, etc. but it seems that it's not what I'm looking for.
    Here is a little piece of code I wrote:
    package Software;
    import java.util.Random;
    * @author Rodrigue
    public class RandomText
        private Random rand = new Random();
        private Thread t;
        private String rText = "Rodrigue";
        public RandomText()
            t = new Thread()
                @Override
                public void run()
                    try
                        while(true)
                            UpdateText();
                            sleep(100);
                    catch(InterruptedException ex)
            t.start();
        private void UpdateText()
            int i = rand.nextInt();
            synchronized (rText)
                rText = String.valueOf(i);
        public String GetText()
            return rText;
    }It's just a class which start a thread. This class updates a text with a random integer 10 times per second.
    I would like to get a reference on the String rText (like in C++ ;) yes I know, I must think in Java :D). So, like that, I could get one time the reference, thanks to the GetText function, and update the text when my application will repaint. Otherwise, I always have to call the GetText method ... which is slow, no?
    Are objects passed by reference in java? Or, my string is duplicated each time?
    Thank you very much in advance!
    Rodrigue

    disturbedRod wrote:
    Ok, "Everything in Java is passed by value. Objects, however, are never passed at all.". Reference of object is passed by value too.
    But, how to solve my problem in Java_? I have an object which is continually modified in a thread. From an another side, this object is continually repainted in a form.I'm not sure I totally understand your problem. If you pass a reference to an object, then both the caller and the method point to the same object. Changing the internal state of the object (e.g. by calling a setter method) through one reference will be observed through both references, since they both point to the same object.
    No, calling a method is not particularly slow. Especially if it's just a simple getter method that returns the value of a member variable.
    If this is happening in a multithreaded context, you'll have to use proper synchronization to ensure that each thread sees the others' changes.

  • Pass a COM object across processes

    Hi,
    I need to pass a COM object from process A to B.  I didn't find a good code example for IMoniker.  So I am trying to test a simpler solution.  Please refer to the following snippet of code.  There is a problem.  When the execution
    reaches GetActiveObject in B, the system hangs.  "HRESULT h" in several places returns S_OK.   Does anybody have a clue?  Please help me out.  Thanks for your help in advance.
    // the definition of the COM object
    EXTERN_C const IID IID_IUniverse;
    #if defined(__cplusplus) && !defined(CINTERFACE)
        MIDL_INTERFACE("91CAF3F6-BD4D-4DDC-9C35-59F5DB20D570")
        IUniverse : public IDispatch
        public:
    // PROCESS A:
    HRESULT h = RegisterActiveObject (cwApp, IID_IUniverse, ACTIVEOBJECT_STRONG , &dwRegister);
    // PROCESS B:
    HRESULT h = CoInitialize(NULL);
    IUniverse *p = NULL;
    HRESULT h = GetActiveObject(IID_IUniverse, NULL, (IUnknown**)&p);
    if (p)
      CComPtr<IUniverse> cwApp(p);
    JD

    On 1/27/2015 7:43 PM, jdyng77 wrote:
    I did some research on this issue to help me better understand your comments here.  I still don't fully understand the problem.  Please help me out.  Or, if I can get around the problem by using IMoniker and IRunningObjectTable instead,
    I would be more than happy doing that.
    Unlikely. If, as I suspect, the problem is that the server thread blocks, then the client won't be able to obtain the interface pointer from it by any means. Any IPC mechanism you might want to use kind of assumes that both parties remain responsive.
    WaitForSingleObject() is the opposite of "responsive".
    The third party (3rd pty) provides a COM interface.  I write a COM server A
    In-process (a DLL) or out-of-process (an EXE)? From your description, I would assume in-proc.
    that has an implementation for this interface.  I believe the 3rd pty must have called CoInitialize(NULL) before it instantiates object A.
    It must have, yes. This is only significant if A is an in-proc server.
    The 3rd pty passes a COM object of IUniverse to A.  I can call IUniverse's methods in A without any problem.  The need here is to transfer the IUniverse object to another process B so that B can call IUniverse's methods.  The problem
    is that B hangs.
    My guess is, B hangs because A hangs. In one of your responses, you suggest that you are calling WaitForSingleObject (waiting on process B's handle, I presume). In so doing, you have created a deadlock. B is trying to communicate with A to retrieve the
    interface pointer, but A is waiting for B to exit.
    After A registers IUniverse pointer (whether in ROT or as active object), it should return to the caller. Said caller likely spins a message pump - but by blocking and not returning, you don't allow it to run.
    The thread where A sits is created in the 3rd pty.  If I understand you correctly, the 3rd pty must "retrieve and dispatch window messages in a timely manner".  I think it does because it calls A when a window button is clicked.
    3rd pty would, if only A would let it. By sitting in the message handler, A prevents the caller from retrieving messages in a timely manner.
    But I don't know whether I should use Class, File or Item IMoniker.
    Item moniker is the easiest to use by far. It just wraps a piece of text. You create one with CreateItemMoniker: pass L"!" (by convention) in the first parameter, and arbitrary string in the second. Both parties (one that registers in ROT, and
    one that picks up) should agree on and use the same string, of course.
    Igor Tandetnik

  • I am fed up with Spring and Apple passing me off to one another and neither will fix the problem. I am unable to receive a connection on my phone.

    I am fed up with Spring and Apple passing me off to one another and neither will fix the problem. I am unable to receive a connection on my phone.
    The internet goes out and I have to reset network setting each and every time. This is only a temporary solution which by the time I release the line with Spring or leave the apple store the issue is back. Sprint indicates that it is a know issue with the Iphone 5 and apple says it is a network issue as Sprint's network is not up to par with the Iphone and can not meet the expectations on the Iphone 5.
    I have attached a few picture, as you can see it clearly says I have 5 bars and 3g available but I have no connections what so ever.
    This issue affects all data and so I can not send or receive picture messages, use apps, or access the internet. The data goes in and out intermittently and it seems the phone chooses what I can and can't do.
    For example I can watch Youtube or Vevo videos but I can not access Facebook or Instagram.
    Is anyone else having this issue?
    I will soon loose my patience....
    I have reset my phone three time and have reset network and other setting mutltiple times.

  • Can i copy values from one object to another ?

    One more help..
    How do i compare the input values with the ones in an object of another class ?
    Can i copy values of one object of a class to different object of another class ?
    Thanks,
    Sanlearns

    How do i compare the input values with the ones in an
    object of another class ?By getting and comparing them?
    Can i copy values of one object of a class to
    different object of another class ?Yes, you can. But you shouldn't, as you're breaking encapsulation all over the place. You could use setter methods (if available) to set the values.

Maybe you are looking for