Skip to Content
avatar image
Former Member

How to create global object for a number of views?

Hello,

Let's say I have 5 different views in a certain component.

I would like to open a connection to a DB and share this connection between all views.

Can somone please show/explain me where do I do it on the component and how do I access this connection from the views?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Jun 08, 2005 at 06:52 AM

    Hi

    create a method in component controler open the connection there and release the connection once it is finished and call this contoller method from any view u want.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 08, 2005 at 06:48 AM

    Connect thru the Controller, and make use of this in ur views.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 08, 2005 at 06:48 AM

    Hi Roy,

    How about creating a context attribute of (java native type)java.sql.Connection type and use it in the component controller .

    Open the connection in the component controller and set it to the connection attribute you have created...

    Finally map it to all the views.

    Regards

    Bharathwaj

    Message was edited by: Bharathwaj R

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Just add the component Controller in the required Controler of your view

      and u can call from view

      wdThis.wd<<Component ControllerName>>.<<MethodName>>

  • avatar image
    Former Member
    Jun 08, 2005 at 07:01 AM

    Hi Roy,

    Create the connection in the component controller itself. There will be only one instance of that connection in the whole component.. If u just map it and and use this variable to create a statement and execute it ,the connection should work.

    we dont have to activate anything here....

    Regards

    Bharathwaj

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 08, 2005 at 09:48 AM

    Hi Roy,

    If u r creating the connection in a method in component controller it is only as good as creating it in each view. Evry time u call the function in a view a new connection wil be created.. You will not be sharing a single connection in this case !

    Is ur requirement satisfied.. how did u do the whole process.. bcoz connections are transient ! and u might have to re-create them whenever it is not available..

    Regards

    Bharathwaj

    Message was edited by: Bharathwaj R

    Add comment
    10|10000 characters needed characters exceeded