MVC: Storing a model in Application

Hello again,
I just found fragments in here and the weblogs on how to store a model (derived from CL_BSP_MODEL) within the application.
To clear it up: I have a model class that shall be persistent to all controllers within the session scope (so, per user). My controllers have an attrribute called APPLICATION, being of type OBJECT. But many examples talk of the interface IF_BSP_APPLICATION which I cannot find within any of my controllers. The BSP app entry itself has no pinters to classes, just base porperties and navigation mappings, so where do I find this reference to  IF_BSP_APPLICATION?
I could create a custom class to store my model, but where to create it? I have multiple controllers and want to go shure that another controller (not being a sub controller) receives the model. I have set all my ctonrollers as well as the app to session lifecycle.
It would be okay for me to pass the next controller my model, but navigation->set_parameter() cannot pass object references.
I would like to have something like this:
CTRLA:
application->set_attribute( name='model' value=me->model ).
CTRLB:
mod = application->get_attribute( name='model' ).
Where "application" is really one single instance per session for all controllers within the MVC app.
From Java I know this as request.getSession().setAttribute("model", model);
Thanks you,
Timo

You already have a pointer to your application in the controller class.  It is just very generic (type object).  You need to cast it into your specific object type before you can use it.
data: model1 type ref to zcl_bsp_m_mfglbl.
  data: appl type ref to zcl_ep_bsp_appl_mfglbl_prt.
****Get a Pointer to the application Object
  appl ?= application.
****Get a pointer to the Model Object.
  model1 ?= appl->model.
The reverse is true if you want to set the model into the application class.
data: model1 type ref to zcl_bsp_m_mfglbl.
****Get a pointer to the Model Object.
  model1 ?= get_model( 'MQ' ).
  if model1 is initial.
****Create the Model to hold data for the Document Search Controller
    data: model type ref to cl_bsp_model.
    model = create_model( model_id = 'MQ'
                          class_name = 'ZCL_BSP_M_MFGLBL' ).
  endif.
  data: model2 type ref to zcl_bsp_m_mfglbl.
  data: appl type ref to zcl_ep_bsp_appl_mfglbl_prt.
****Get a pointer to the Model Object.
  model2 ?= get_model( 'MQ' ).
****Get a Pointer to the application Object
  appl ?= application.
****Tell the Application object about the Model Object
  appl->model ?= model2.

Similar Messages

  • Why files in Lightroom mobile and files in the creative cloud not the same? idea-  one place(stored date) for all application ??????

    Why files in Lightroom mobile and files in the creative cloud not the same? idea- one place(stored date) for all application ??????

    Lightroom Mobile is not a cloud storage service. You shouldn't treat it as a way of backing up your files. You are merely storing Smart Previews of your files in the cloud space, high-quality JPEGs of your files regardless of their original format on your desktop. The point is that they are there so you can continue editing them in a Lightroom-like environment even while away from your desktop/laptop computer. The files in Lightroom Mobile can only be used in Lightroom Mobile.
    This is very different from what is offered by the Creative Cloud storage, which can be used to synchronize your files between any device (that can support the individual files).
    The vast difference in how each service works and its intended use is why they are separate.

  • Facing error while trying to execute stored procedure from JSF Application

    Hi, I am facing the below error when I try to execute a stored Procedure from JSF application which is deployed on WAS 7.0
    =2013-03-04 19:06:58,550 INFO [com.lloydstsb.iw.util.DBUtils] - DBUtils : executeFileNetStoredProc method started..
    =2013-03-04 19:11:58,271 ERROR [com.lloydstsb.iw.dao.FileNetCustomDBSynchDAOImpl] - Data Access Exception
    com.lloydstsb.iw.common.exceptions.DataAccessException: Data Access Exception Occured : Integration Stored Proc- java.sql.SQLException: java.lang.ClassCastException: oracle.jdbc.driver.LogicalConnection incompatible with oracle.jdbc.OracleConnection
         at com.lloydstsb.iw.util.DBUtils.executeFileNetStoredProc(DBUtils.java:959)
         at com.lloydstsb.iw.util.DAOUtil.executeFileNetStoredProc(DAOUtil.java:117)
         at com.lloydstsb.iw.dao.FileNetCustomDBSynchDAOImpl.updateFileNetDetailsCustomDB(FileNetCustomDBSynchDAOImpl.java:36)
         at com.lloydstsb.iw.servlet.IndexServlet.service(IndexServlet.java:127)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1443)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:790)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:443)
         at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
         at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
         at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:859)
         at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1557)
         at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:173)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
         at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
         at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
         at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
         at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
         at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
         at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:202)
         at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766)
         at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:896)
         at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
    The oracle version we are using is 11g.
    Previously it worked fine when the application was used in 10g.
    Can someone please help me in resolving this issue?
    Kiran
    Edited by: 991640 on Mar 4, 2013 8:25 PM

    java.lang.ClassCastException: oracle.jdbc.driver.LogicalConnection incompatible with oracle.jdbc.OracleConnection
    Are the the JDBC JARs packaged with the application? If so, remove the applicaiton packaged JDBC JARs as the JARs are also in WebSphere application server.

  • Error: demo.model.AppModule: Application module demo.model.AppModule has a view instance EmpByEmail1 that references an invalid view object.

    Error: demo.model.AppModule: Application module demo.model.AppModule has a view instance EmpByEmail1 that references an invalid view object.
      intially i created view object named EmpByEmail.........for that EmpByEmail1 is created in datacontrols....i deleted EmpByEmail in demo.model by mistake and i created again with same name EmpBYEmail another view object...again another EmpByEmail2 is created in datacontrols.....
    while i am running i am getting following error:::::::
    Error: demo.model.AppModule: Application module demo.model.AppModule has a view instance EmpByEmail1 that references an invalid view object.

    Hi,
        Please seasrch for the EmpByEmail1 file in ur project and remove all the details in the Page Def and UI and then try again.
    Due to the EmpByEmail1 existance in page Def this may occur . It may help , still if it was not working then I am sorry for that.

  • Different ways to return results using a stored proc to calling application

    Hi, Can someone please suggest me different ways of returning results( set of rows and columns) from a stored procedure to calling application.
    Currently I am using sys_refcursor to return results to front end. Stored proc is executed fast, but cursor access and retrieval of results has some overhead.
    So can you suggest the ways which will be faster than this approach.
    Thanks.

    Currently the procedure executes quickly but the results from the ref cursor are returned slowly, this is because the query is slow, for whatever reason.
    Collecting in all the rows in the stored procedure first before returning them will
    a) Make the stored procedure slower taking the same amount of time to execute as current query takes to complete.
    b) Use more memory.
    c) Put more stress on the network as all rows will be transferred at once instead of using the arraysize/fetchsize to to fetch the rows in smaller packets.

  • What is the best MVC approach for designing Swing application

    Hi...
    I am designing an client/server application. In this I am using java swing for the front-end development. We decided on using MVC approach for the front-end design. I found that there are more than one approachs for designing in MVC.
    Which is the best way to model. To create your model taking View into consideration or Creating the Model taking the tables into consideration.
    Can anybody give help me out in this this is urgent. Thanks
    sai

    I'm not sure what you are asking, so I'll just ramble a bit and hope it helps.
    Create your model taking the view and the data into consideration. :-)
    Design a class to hold instances of the rows in your database that correspond (more or less) to the structure of the data. Add any needed methods to that data object to support the data that you might need for the view.
    For example, suppose your database stores a name in two columns (firstname and lastname). You pull that data from the database into a collection of Person objects into your model. Your Person class has two fields (and set/get methods) to hold that data. Now, in your view, you want to display the name as one string, so add a method to the Person object to get the full name (just by concatenating the two data elements).
    You have to take everything into consideration. How you are going to view the data as well as how it might be structured.

  • Use XML files stored in directory of Application server as a input for XI ?

    I have a scenario that there is a xml file stored in sap application server for example /inf/ERQ/XML/XXX.xml which i want to use it as an input for XI. I know that there is an adapter in XI for getting xml file stored in normal path but in my situation it's in application server of SAP so i don't know how to do this.
    Any solution or example for this? Thank you in advance.
    Best regards

    Hi,
    We can read this file through FILE adapter with FTP protocol, before that i think need permission from basis for access.  Configure source(according to xml format) and target structure according to your requirement.  But one thing should remember in XI/PI sour/target XML formats should contain Message type name & namespace name else it can't work.
    Find below link for more information.
    Introduction to simple (File-XI-File)scenario and complete walk through for starters(Part2)

  • Calling Stored Procedures from JAVA Application

    Hi all,
    i am using JDeveloper 3.2.2 for creating a DB Application that
    uses Oracle8i as DB Server.
    One approach of the application is to only use PL/SQL Stored
    Procedures to write Data back to the DB.
    Some of the stored procedures expect more than 20 parameters.
    I want to know if there is a better way to call such a stored
    procedure from Java than using a CallableStatement and setting
    its 20 parameters.
    Another reason why the way above isnt possible for me is that
    i need a dynamic way to set the parameters of the stored
    procedure.
    A solution for that dynamic way i could think of is to get
    the information of the stored procedure by using some functions
    of DatabaseMetaData and than use this information to map the
    parameters with their respective variables in the java
    application.
    The best argument against this way is that it would be time and
    performance consuming.
    So could anybody tell me a solution to call PL/SQL stored
    procedures from java which is better than doing something like:
    String calString = "{Call myStoredProc(";
    while(counter < 22) {
    params += "?";
    if(counter<21) params += ",";
    counter++;
    calString += params + ")}";
    try {
    CallableStatement cs = session.prepareCall(calString);
    } catch(SQLException ex) { ... }
    cs.setString(1, var1);
    cs.setString(1, var2);
    And that for every Stored Procedure i want to call ?!?
    Any help or direction-leading would be really appreciated.
    Tank you much.
    MfG,
    Oliver Bankel

    Hi Oliver,
    If you your Stored Procedures were in Java and seamlessly
    integrated with your Java application would that make your life
    easier?
    I don't know if this is a practical or acceptable solution in
    your environment but it would certainly solve all of your issues
    and provide your with a couple of nice advantages. Scalability
    and platform independence are just a couple I could think of.
    There is a tool called in2j (see http://www.in2j.com) which will
    automatically migrate your PL/SQL Stored Procedures into Java.
    You can download a copy of the tool and migrate your PL/SQL to
    Java with no upfront costs. If you're happy with the generated
    Java and want to deploy it, the migration fee falls due - simple.
    Hope this helps.
    Elton

  • SQL Developer 2.1 removes the stored password in SVN Application Data

    Hello everybody
    SQL Developer is a great Tool and I use it together with the SVN Versioning System. I also use TortoiseSVN on my Windows XP Operating System, that's why I found out that either the SQL Developer or its SVN Extension has a bug.
    I have installed the latest SQL Developer 2.1.0.63.73 and the extension "*Versioning Support for Subversion* 11.1.1.2.36.55.30".
    Both Tools the SVN Extension for SQL Developer and the TortoiseSVN save Authentification Data automatically in the same Folder "C:\Documents and Settings\UserXYZ\Application Data\Subversion\auth\svn.simple\" into some Files.
    When I use TortoiseSVN, the password can be stored in those mentioned Files. That's very useful, so I don't have to enter my password every time I perform a SVN command. But when I later use SQL Developer and update/commit some file, the password will be removed from the above mentioned Files, even though my Password is stored in the SQL Developer's Subversion Navigator inside the Connection Setup of my Repository.
    I would be happy to get some feedback from your point of view. Are there other people who have the same problem?
    I turned already to google, but I haven't found a hint that it could be something you can configure in some properties.
    Thanks in advance,
    Ben

    In the meantime I found the solution:
    just add those two lines to the *%appdata%\Subversion\config* File
    store-auth-creds = no
    store-passwords = yes
    It looks like the SVN Extension in SQL Developer has different Default Values for the properties than TortoiseSVN has.

  • Best practice: storing user input as application wide config

    example: a webmail application is deployed as a war-file to a server. the fresh deployed app now needs to read info from the user (mail-host, username, password, etc.).
    what is the best way to store this information permanently on the serverside for as long as the app is not undeployed (i.e. persistent even after server reboot)?
    thx

    and what if i wanted an installer (setup script) that stores database connect info from a submitted html form?
    basically i need a standard way of storing data without unpacking the war and editing a .xml file. kind of chicken and egg issue.

  • Calling Web Dynpro-Model of Application-Service doesnu00B4t work.

    Hello!
    I have created a Composite Application with Entity- and Application-Services. I have also created the WebDynpro-Model and use it in another WebDynpro application to call the services.
    I have a Entity-Service 'PollCatalogue' and an Application Service 'PollCatalogueApp'.
    When I call an Entity-Service to create an entity, it works:
    APollCatalogue pollcat =
                        PollCatalogueServiceProxy.createPollCatalogue();
                   pollcat.setName(name);
                   pollcat.getAspect().sendChanges();
                   IServiceFacade serviceFacade;
                   serviceFacade =
                        CAFServiceFactory.getServiceFacade(diplDefinition.class);
                   serviceFacade.save();
    But when I call the create-Method of the Application service nothing is created:
    the call is similar to above except that
    PollCatalogueServiceProxy.createPollCatalogue();
    is replaced by
    PollCatalogueAppProxy.createPollCatalogue();
    Anyway I don´t understand what is done behind the scenes. My create-Methode has one parameter name, because it is a business key. But the ServiceProxy-create-Methods do not provide a name parameter. What service-methods are called when service-facade.save() is called? In case of Entity-Service-Proxy seems to be the create method. But what if I change more than the key-parameter, what else is called? update? And in case of AppServiceProxy? ???
    Does anyone understand what is going on here?
    Thank you for your help.
    Best regards,
    Jörg

    Hi Jorg,
    About getting an exception:
    IQuery query =... ;
    query.execute() ;
    IMessageList mList = query.getResultAspect().getMessages()
    if (mList.size() > 0) {
         for (int i = 0; i < mList.size(); i++) {
             IMessage mes = (IMessage) mList.getMessage(i);
          Throwable ex = (Throwable) mes.getExtension();
         ByteArrayOutputStream bAOStream = new ByteArrayOutputStream();
         PrintStream pStream = new PrintStream( bAOStream);
         ex.printStackTrace(pStream);
            //use bAOStream in order to show stacktrace
    Regarding conceptual background about Models and Proxys:
    You can find some infomation about wd model:
    <a href="/people/valery.silaev/blog/2005/09/09/common-model-interface Model Interface</a>
    <a href="https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/cef4f43e-0d01-0010-db84-ede25c874115">WQhy to use webdynpro common model interface ?</a>
    I don't know about some proxies documentation. Possible it does not exist. So, there is brief information about it:
    CAF data access services - comcafruntime~uicoupling DC. There is an implementation of com.sap.tc.col.client.generic.api api. These interfaces extends generic CMI interfaces. On top of CAF data access services implementation CAF designer generates typed CMI models which you finally use. For supporting of typed CMI models CAF provides additional build-in functionality GCP(generic client proxy) which directly operates over com.sap.tc.col.client.generic.api generic implementation.
    I recommend you to learn CAF data access implementation and read information about CMI model. That's not huge area and it gives you necessary understanding.
    Best regards,
    Aliaksei
    P.S. I don't recommend to learn and investigate the GCP implementation. That's just loss of time. The only thing that you need to know there is a black box layer which converts generic CMI model to typed model. Actually you can use generic model directly without typed. To do this use the following method for service facade getting:
    com.sap.caf.ui.utils.cool.CAFServiceFactory.getServiceFacade() ;
    but not this one:
    com.sap.caf.ui.utils.cool.CAFServiceFactory.getServiceFacade(final Class modelDefinition) ;
    and also do not use generated proxies at all, just use CMI api for model info setup for model nodes and other generic CMI api.

  • Where is the data stored for the Contacts application in OS X 10.10?

    My client uses Backblaze online backup, and recently needed to retrieve his contacts. Is the data stored in the app itself, or somewhere else? Backblaze doesn't back up applications by default. Is there a way to instruct Backblaze to back up the Contacts application?

    Thanks, lllaass.

  • MVC: Controller called twice in application

    I have a situation that I am hoping is not that strange to some of you. The app that I am working on is fairly simple. A table is created using user-input from an input field and a function module in the controller class. This table is then sent to the view and used to populate a tableview. Once a user has chosen a row and clicked submit, the controller is called again. What is supposed to happen, of course, is that I use the row that was selected against the previously created internal table. My problem is that the data in the internal table is lost by the time the user clicks the submit button.
    After a little debugging, I've learned that even on the original painting of the view, the controller is called a second time. When the controller is called a second time (without any user interaction yet) all data is 'refreshed.' The view reverts to intitial and my internal tables are cleared.
    There is only one controller and one view in this application. Main.do and Main.htm.
    Does anyone have an idea as to why the dispatch_input in Main.do would be called a second time, even after the view has been painted on screen and the user has yet to submit anything?
    I appreciate any guidance you can give!

    Hello Theresa Dancy,
    Welcome to SDN Forums...
    I suggest you to use the <b>Application Class</b> for storing values.
    The main function of Application Class is a BSP Application is to store values in it.
    There can be only one application class for one bsp application.
    You can find the application class field in the properties of the BSP Application.
    Refer this link for more information on Application Class...
    http://help.sap.com/saphelp_nw04/helpdata/en/21/8cec3ada87e076e10000000a11405a/content.htm
    Reward points for useful answer by clicking the star on the left side of the screen.
    Regards,
    Maheswaran.B
    Message was edited by: Maheswaran B

  • How to grant privilege to Change Stored Password in External Application ?

    Hi,
    I have added an external application in portal but if I did not grant manage privilege for the page that I have added "External Applications Portlet" then the users are unable to change stored password. How can I grant users to do this action only?

    You cannot log in by supplying a password's hashed value. You should supply the real password. The SQL Authenticator (or the ReadOnlySQLAuthenticator) in the Weblogic Server then will calculate the hash value of the password you supplied and will compare it with the hash value stored in your database table. Of course, in order to do that you should configure the SQL Authenticator to retrieve the hashed password values from the DB table with the appropriate prefix (e.g. {SHA}, {SSHA} or {MD5} depending on the hashing algorithm you used for the passwords in the DB table) in order for the WLS to know which hashing algorithm to apply.
    Dimitar

  • Storing 3D Models

    I've written a small 3DS loader, but now I've run into the problem of storing the information. When I load one model, there are the XYZ coordinates and ABC for the faces. Coordinates are extracted from the file as floats then converted to integers with a small loss of precision and the faces are integers as well.
    This is really a problem of storing multiple(~20) large arrays(~200) of 6 integer arrays. I was thinking about doing a bit wise operation to convert the 6 arrays into one long. 2 bytes for each x y and z then store each face as one byte. But, this gives me multiple large arrays of longs. Also limiting the amount of polygons I have to 256.
    I'm sure I'm over complicating this so I figured I would ask if there is a simpler method.

    Hello,
    This is really a problem of storing multiple(~20) large arrays(~200) of 6 integer arrays. I was thinking about doing a bit wise operation to convert the 6 arrays into one long. 2 bytes for each x y and z then store each face as one byte. But, this gives me multiple large arrays of longs. Also limiting the amount of polygons I have to 256.
    I'm sure I'm over complicating this so I figured I would ask if there is a simpler method.Can you re-state what your "problem" is? I don't see any in your description, but maybe I missed something.
    Based on your numbers, you're talking about storing 20*200*6=24000 integers, i.e. 96kB. Not a big amount in the RAM of a regular desktop computer - but maybe you're running on a more limited device? Please clarify if this is the case.
    This is likely not a big number either in terms of file storage.
    Is your problem the fact that you don't know how to code this "storage"? Then search about "Java serialization" (of course a lot of other approaches exist).
    Best regards,
    J.

Maybe you are looking for