EJBs in dynpro

Hi all,
I want to use  ejbs in my dynpro. In this case, is it required to use a command bean i.e an intermediate layer?
The ejbs will have business functions. To use an ejb using a javabean model, i'll bind the context attributes of component to that of the created model.
But since our ejb contain functions not variables so I guess the ejb can't be used directly.
Could anyone please help me in this regard.
Is command bean needed in every scenario ?
Is there any other solution to this ?
Can anyone tell me the link for using simple ejbs in dynpro except the pdf in sdn 'Using ejbs in web dynpro' ?
Thanks,
Prasanna

hi,
no it is not that you have to use command beans.
Since ejbs are used to have business methods, the task is also performed using the stateless beans.
Go to J2EE perspective and create the simple ejb module project, add basic methods to this project. This basic methods you have created can be used in your front end appl. This is simply done by adding the jar file to your front end application
refer the thread for more details, it describes the two ways of ejbs.
http://help.sap.com/saphelp_nw2004s/helpdata/en/bd/b127af68234e868cfd4e9f440aa0bf/frameset.htm
Regards,
Abhijeet.

Similar Messages

  • EJB Web Dynpro  - Data Persistence

    What is the recommended way for connecting to oracle database and adding business logic to web dynpro application.?
    We were researching on the CMP entity bean but found that CMP entity bean in SAP netweaver can be
    configured only to connect to the default database. Its too difficult for my consious to digest why anyone will connect only to the default portal database. Is there any way that we could work on CMP entity beans and connect to an external datasource in EP 7.0 ?
    Your valuable feedbacks would be highly appreciated...

    unlike others, I dont think it should be an issue in connecting to an external data base as long as you can telnet / ping to that db server from Portal.
    All you need to create is a JDBC datasource from portal to that database and use that datasource in your application.
    It should be pretty straight forward.
    Did you try this?
    The reason i know it should work is, i am working on MDM and from portal i create a datasource to connect to MDM database for one of the application provided by SAP and it is the standard procedure defined by SAP to create datasource and consume it.
    I just saw, yardon has provided links to help.sap on how to create datasource, so you should be good.
    Let me know if i need to explain more. I can guide you how to create datasource in Visual admin.
    Good Luck
    Regards,
    Nitin
    Edited by: Nitin Mahajan on May 1, 2009 6:50 PM
    Edited by: Nitin Mahajan on May 1, 2009 6:50 PM

  • Exposing Web Services as Callable Objects

    Hello!
    I have SAP NetWeaver 04s SP7. How can I expose Web Services as Callable Objects?
    According to "Exposing Web Services as Callable Objects" (http://help.sap.com/saphelp_nw2004s/helpdata/en/44/4758351fcb1193e10000000a155369/frameset.htm), I should start with choosing type of CO "Service -> Web Service".
    Actually, I haven't this entry in CO type list!
    According to integrate Web Services with GP, this type appeared in SP8. What are the alternatives in SP7?
    "Background execution" and "External service" seem to be the best candidates...
    What is the best solution?
    Thanx in advance!

    Hello, Jan!
    I have SAP NWDS 7.0.07, and I cannot find there an option to create a CAF project. I can create Web service, EJB, Web DynPro, and something else - but not a CAF project. In documentation I did not find the connection points between NWDS and External Services, except some plug-ins.
    Maybe I've misunderstood you, sorry - I'm a newbie in SAP
    Actually, I've made a simple EJB, created a Web service from it, and deployed the WS to portal. Maybe, EJB instead of Web service can be somehow used in CAF?
    I've tried to create a CO of type Composite Application Service, but there was necessary to configure endpoint aliases. I've read the manual "Configuring Endpoint Aliases", but didn't succeed to make one for EJB remote call... I've defined the name, URL (http://<host_of_portal>:<portal_port>), user and pwd - but I've got an exception when tried to use the created alias:
    com.sap.caf.core.gp.servicelocator.exception.MetaModelBrowserException: Exception while trying to get InitialContext. at com.sap.caf.core.gp.servicelocator.CAFMetaModelBrowser.getAllApplications(CAFMetaModelBrowser.java:77) at com.sap.caf.core.gp.ui.backgroundco.admin.VSelect.browseCAFCore(VSelect.java:305) at com.sap.caf.core.gp.ui.backgroundco.admin.VSelect.onActionSelectEptAlias(VSelect.java:750) at com.sap.caf.core.gp.ui.backgroundco.admin.wdp.InternalVSelect.wdInvokeEventHandler(InternalVSelect.java:287) at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87) at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67) at
    Maybe, the easiest way is to upgrade the versions of SAP and NWDS?
    Are there some manuals that could provide me some help about:
    1) creating CAS from the deployed Web service (from its creation in NWDS till its use in CAF, step-by-step)
    2) binding Web Dynpro apps and Web services, using CAF and GP.
    Or maybe I should attend SAP courses?
    I have SAP NetWeaver 04s SP7 and NWDS ver. 7.0.07.
    Sorry for the messy post, I did my best
    Message was edited by:
            Kirill Shepitko

  • What is missing ?? -  JDBC and webdynpro

    Hello!!:
    I'm traying to get some data vias JDBC from a Data base to display info in a webdynpro project's view.
    The code is:
    public void wdDoInit()
        //@@begin wdDoInit()
      wdContext.nodeAddressbook().invalidate();
      IPrivateAddressbookView.IAddressbookNode
      addressNode = wdContext.nodeAddressbook();
      IPrivateAddressbookView.IAddressbookElement addressElement;
      try {
           InitialContext ctx = new InitialContext();
         Object obj = (Object)ctx.lookup("jdbc/PDIM");
         DataSource ds = (DataSource)PortableRemoteObject.narrow(obj, DataSource.class);
         Connection con = ds.getConnection();
         Statement stmt = con.createStatement();
         ResultSet rs = stmt.executeQuery("SELECT * FROM INTERNOS" );
         String nombre;
         String departamento;
          con.close();
      }catch (SQLException e) {
              // handle exception
         System.out.println(e.getCause());
          System.out.println(e.getMessage());
      }catch (NamingException e) {
              // handle exception
         System.out.println(e.getCause());
          System.out.println(e.getMessage());
      }catch (Exception e){
              // handle exception
                System.out.println(e.getCause());
                System.out.println(e.getMessage());
    at line:
    Object obj = (Object)ctx.lookup("jdbc/PDIM"); an Naming exception is throw, it says:
    com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Object not found in lookup of PDIM.
    PDIM = alias and name of de data base.
    The connector and alias are well difine in the portal as I look up for some steps to do it at the SDN an all of them were well done. I was wondering if there's some file, as data-source-aliases.xml or something like that's missing (what and where should I put it?).
    All the examples using JDBC that I saw were with EJB + Web dynpro, not just Webdynpro and JDBC. THERE IS NOT EJB ON MY PROJECT.
    Thanks a lot for your time.

    Nagarajan Kumarappan Thanks a lot for your answer.
    You said:
    "Note:This should be added only if the alias does not exist."
    by that you mean "if the alias SAP/PDIM is NOT display on the aliases'list"
    is it ok? or the alias could have been created from the portal side, this is
    htp://<host>:50000/irj/portal  --> system configurations --> portal content -->(from context menu) New --> System
    THANKS!!

  • Dependency injection and inheritance

    Given:
    class abstract AbstractFoo
    MyObject obj;
    class ConcreteFoo extends AbstractFoo
    Now, I'd like to declare @EJB on "MyObject obj" but AbstractFoo is extended by other subclasses on the client end (outside the container) and so I don't want them to have any EJB3 dependencies. Is there a way for me to declare, inside ConcreteFoo, that "MyObject obj" should have @EJB associated with it?
    Thanks,
    Gili

    Hi Janeth,
    As you can see, Web Dynpro is not a standar JEE container so itu2019s not possible to use dependency injection from a Web Dynpro layer. You have to use JNDI lookups as usually.
    Perhaps the following link may help you: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/605ff5f2-e589-2910-3ead-e558376e6f3d
    You can use EJB Web Dynpro models as an alternative.
    Edited by: Sergi Arrufat on Jun 3, 2008 12:27 PM

  • Creating DataSource in Visual Administrator for Oracle DataBase

    Hi Experts,
    I want to connect to external Orcle Database from my application(EJbs,Web Dynpro) where i need to call some stored Procedures.for that one i want to create
    DataSource in Visual Administrator.
    i got some doubts for  creating DataSource in Visual Administrator
    1.which SQL engine i need to use(open SQL or Native SQL or Vendor SQL)
    2.shall i need to deploy any additional drivers(jars) in WAS
    any help will be appriciated
    thanks in Advance
    With Regards
    Naidu

    I can see you are still looking for answeres, I have included more explicit examples of how to connect to an Oracle DB via an SAP Visual Administrator Datasource.
    First the DB has to exist and you should be able to connect to it using some other application to test with like Toad for example.
    Secondly for installing the Data Source via Visual Administrator you will need to verify that you have a an Database Driver defined in the Visual Admin first, if not define one. Defining an oracle driver is as simple as providing an alias name for the driver and supplying the Oracle classses.jar, or ojdbc14.jar. Click Create Driver in the Visual Admin enter an alias name  and click Browse to find one of the jar files mentioned above. Once done click the diskette looking icon to save.
    After the above 2 steps you can either define the Datasource manually in the Visual Administrator or Import the datasource via an xml file as defined below.
    I have included a mock datasource.xml file which you can copy and paste and more or less use as  a reference.
    <b>Note</b>
    With Oracle I have always sected <b>Vender SQL</b> as I can not get any of the other selections to work properly when connecting to our Oracle DB. I have also used this approach to connect to Oracle 8 databases as well. We have been using these Datasources in production for many years without incident.
    Variables Defined
    <b> data-source-name </b> PORTFOLIODS is the name we use to look up the Datasource via JDBC.
    <b>driver-name </b>  The name that you have defined for the Oracle jar libary you added as a Database Driver via the Visual Administrator.
    <b> url </b>           The "Type 3" Network URL pathname to the Oracle DB.
    <b> user </b>        The account you want to log in as.
    <b> password </b> The account password for the DB.
    Cheers,
    Alex
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE data-sources SYSTEM 'data-sources.dtd'>
    <data-sources>
      <application-name>chep.com/JDBCConnectior_PORTFOLIODS.xml</application-name>
      <data-source>
        <data-source-name>PORTFOLIODS</data-source-name>
        <driver-name>Oracle9i</driver-name>
        <max-connections>25</max-connections>
        <max-time-to-wait-connection>60</max-time-to-wait-connection>
        <sql-engine>vendor_sql</sql-engine>
        <jdbc-2.0>
          <cpds-class-name>oracle.jdbc.pool.OracleConnectionPoolDataSource</cpds-class-name>
          <object-factory>oracle.jdbc.pool.OracleDataSourceFactory</object-factory>
          <properties>
            <property>
              <property-name>url</property-name>
              <property-value>jdbc:oracle:thin:@usdenedu169.cnn.com:1521:ORCL</property-value>
            </property>
            <property>
              <property-name>user</property-name>
              <property-value>LogisticsApplication</property-value>
            </property>
            <property>
              <property-name>password</property-name>
              <property-value>logisticsAppPwd</property-value>
            </property>
          </properties>
        </jdbc-2.0>
      </data-source>
    </data-sources>

  • Error while importing EJB model in Web dynpro: Unable to fetch the EJBs.

    Hi,
    We are getting the below error while importing ejb model to Web dynpro.
    Error :
    Unable to fetch the EJBs. Check if the selected Enterprise Application contain the EJBs.
    I have created the public part-> It has a reference to EJB client and the enterprise application also has reference to the EJB project.The EJB is also added in dependency list.
    But still we are getting this error. Could anyone please explain what can i do to solve this issue.
    Best Regards,
    Karthika

    Hi Vishweshwara,
    Thanks for your reply.
    Please find the steps i followed while importing EJB model in webdynpro.
    1. The Entity forwarding permission has been enabled.
    2. public part reference has been created and through the reference entity option the ejbDC->Client public part is selected.
    I followed all the steps mentioned in the document. But still i am getting that error. In EJB DC we have list of JPA entities and stateless session beans are exposed as a webservice(top-down manner).The enterprise application has a reference to the EJB DC.
    I could be able to invoke the ejb service beans from ejb explorer and Webservice navigator.
    I am able to insert,delete and modify the records from there.
    Please let me know what could i do to resolve this error?
    Best Regards,
    Karthika
    Edited by: SAKarthika on Apr 29, 2011 1:43 PM

  • Couldn't complete tutorial u0091Integrating EJB 3.0 into Web Dynpro ... '

    Hi All,
    I am trying to complete the “Integrating EJB 3.0 into Web Dynpro Using the EJB Model Importer” tutorial that goes with SAP NetWeaver Composition Environment 7.1 SP3 Developer Studio.
    Does anyone ever completed this tutorial because I have problems completing it. The result is very important for me because I need to use this technology for my essay.
    In this tutorial you create a button that calls the method StudsBean.getStudent(String). In this method the object student is created and it will be returned. In several labels the information of the returned student should be displayed. But that doesn’t happen, when I push the button no error occurs but the labels are still empty. When I try to debug the Enterprise Bean and Web Dynpro application I see that the method StudsBean.getStudent(String) is called and the property’s are set and the student object is returned, but still it isn’t displayed.
    After discussing this with a colleague I tried to search for a solution on the SDN and of course Google. First I thought I would be a bug but I only found 2 people with the same problem. I found it remarkable because it’s one of the key subjects of Java EE 5 and it’s a tutorial displayed in the welcome page of the Developer Studio.
    So do you people think it’s a bug in WebDynpro? Because I am sure that I followed all the steps mentioned (a colleague checked it even).
    Regards,
    Sander

    Hi Vesselin,
    Thank you for the quick replay, this is the code I'm using:
    public void onActionGetStudent(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionGetStudent(ServerEvent)
              try {
                  // executes the corresponding method on the session facade
                  wdContext.currentRequest_StudsLocal_getStudentElement().
                  modelObject().execute();
                  // forces Web Dynpro to re-create the Request model object
                  // in order to clear the InputField
                 wdContext.nodeRequest_StudsLocal_getStudent().invalidate();
                  // updates the UI elements bound to the Response node
                  wdContext.nodeResponse().invalidate();
                  //Code for trying something out
                  //wdContext.nodeReturn().invalidate();
                  //wdContext.nodeAddress().invalidate();
               } catch (Exception e) {
                  throw new RuntimeException(e);
    Have you tried this example yourself, or is replay based on experience?
    Kind Regards,
    Sander

  • Couldn't complete tutorial 'Integrating EJB 3.0 into Web Dynpro ...'

    Hi All,
    I am trying to complete the “Integrating EJB 3.0 into Web Dynpro Using the EJB Model Importer” tutorial that goes with SAP NetWeaver Composition Environment 7.1 SP3 Developer Studio.
    Does anyone ever completed this tutorial because I have problems completing it. The result is very important for me because I need to use this technology for my essay.
    In this tutorial you create a button that calls the method StudsBean.getStudent(String). In this method the object student is created and it will be returned. In several labels the information of the returned student should be displayed. But that doesn’t happen, when I push the button no error occurs but the labels are still empty. When I try to debug the Enterprise Bean and Web Dynpro application I see that the method StudsBean.getStudent(String) is called and the property’s are set and the student object is returned, but still it isn’t displayed.
    After discussing this with a colleague I tried to search for a solution on the SDN and of course Google. First I thought I would be a bug but I only found 2 people with the same problem. I found it remarkable because it’s one of the key subjects of Java EE 5 and it’s a tutorial displayed in the welcome page of the Developer Studio.
    So do you people think it’s a bug in WebDynpro? Because I am sure that I followed all the steps mentioned (a colleague checked it even).
    Regards,
    Sander

    Hi Sander,
    I guess, it's not a bug in Web Dynpro, maybe it's a bug in the tutorial
    I tried something similar, but not following the tutorial and it works. I wasn't able to call the model from the view controller and I guess that's the problem. Take the code from the init-method of the view controller and put it to the component controller's init -method and the code inside the onActionGetStudent and put it into a method you create in the component controller, too. From onActionGetStudent just call this method in the component controller with some code like this:
    wdThis.wdGet<your component controller's name>.<your method's name>;
    Hope this helps
    Kind regards
    Stefanie

  • Using EJBs in Web Dynpro

    I have recently started to develop Web applications using the Web Dynpro framework. Coming from a pure J2EE world, I must admit that Web Dynpro has a few innovative features that I find interesting for user interface development. The use of component & view contexts, for example, is not unlike the ActionForms that one may find in a Struts application, but pushed a bit further. No complaints here.
    What I do have some problems with is the whole CommandBean paradigm that is put forth by SAP (refer to the document <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/using%20ejbs%20in%20web%20dynpro%20applications.pdf">Using EJBs in Web Dynpro</a>).
    I do understand the usefulness of defining a model that will be used to generate and eventually bind to Context data structures. That's fine. What I do object to is the use of a so-called CommandBean to play that role. Again, coming from a J2EE world, I am familiar with the BusinessDelegate pattern - which would typically be used by a client application to invoke business logic on the server side. I would propose that a better, cleaner way of integrating EJBs with the Web Dynpro framework would be to use a BusinessDelegate for invoking business logic, and importing a separate and distinct ModelBean (instead of a CommandBean) to be used for defining and binding to Context data.
    I have built one Web Dynpro application thus far. Instead of using a CommandBean, I created a ModelBean that extends my business object DTO (Data Transfer Object) (which is quite appropriate for that role, given that it implements all the get & set methods that are required for the business data that I need to model). My Web Dynpro application also makes use of an independant BusinessDelegate that is packaged with my EJB DC - this is a standard best practice on J2EE projects. I have been asked by the people working with me to modify this architecture to bring it more in line with the SAP way of doing things. I am open-minded and willing to learn and accept new ways of thinking and doing things. However, I fail to understand the usefulness of merging structure and behaviour by resorting to CommandBeans:
    - <b>It violates the MVC paradigm</b> by having one object (the CommandBean) serve as both model AND controller as far as the Web Dynpro application is concerned. The CommandBean is obviously a model - since it is literally imported as such into the Web Dynpro application. It is ALSO a controller from the Web Dynpro's application perspective, since all calls to the back-end go thru the CommandBean via one or more of its execute_xxx methods. In contrast, the use of a business delegate by the Web Dynpro application clearly separates the model (the CommandBean... or rather, a more suitably named ModelBean) from the controller (BusinessDelegate).
    - <b>Doesn't carry its own weight.</b> In other words, I haven't yet been provided with any valid justification for going thru the extra effort of coding the CommandBean's execute methods. It's been proposed to me that it somehow serves as an abstraction layer between the Web Dynpro application and the business logic. I would argue that it is the BusinessDelegate's role to abstract away the back-end logic from clients. If one does have a BusinessDelegate available, I would argue there's no need to code execute methods in a separate CommandBean. To prove my point, I would simply point out that all of the CommandBean examples that I have seen so far, either in How-To documents, or in production code, all follow the same pattern....
               CommandBean.execute_doSomething() calls BusinessDelegate.doSomething()
    Not a heck of an "abstraction" layer... I would in fact argue that it is worse than useless. If some major change occurs in the business logic that requires changing the doSomething() operation, we expect of course to modify the BusinessDelegate. The Web Dynpro client will also presumably need to be modified - that's to be expected, and unavoidable. But then, we'll also need to go about and change the CommandBean's execute_doSomething() method - again, extra work for no apparent benefit. Adding and removing business methods has the same implication. All this for an layer that simply adds the prefix execute_ in front of all business method calls... Is this "abstraction layer" worth the cost of creating and maintaining it ??
    - <b>Unnecessarily complicates error handling</b>. I have been told that for technical reasons, it is recommended that all exceptions thrown by the CommandBean be of type WDException or WDRuntimException. But what if the client application needs to react differently to different failure scenarios ? When I create a business object, I might wish to provide the user with an error messages if connection is lost to the backend, and with a different error message if an object already exists in the database with the same attributes. In order to do that, I will have to catch the WDException, extract the cause, and continue processing from there... possible, yes, but clearly less standard and more labor intensive than the classical try/catch mechanism.
    To say nothing about the fact that SAP's own API documentation clearly states that applications using Web Dynpro can reference and catch WDExceptions, but THEY MUST NOT THROW OR EXTEND IT !
    - <b>Produces unnecessary DCs</b>. Page 6 of the aforementioned document presents an architectural view of a Web Dynpro project that uses a CommandBean. Why an extra DC for the CommandBean ?? I created my ModelBean class right inside the Web Dynpro project (in the Package view). That, to me, is where this class should reside, because it is created for no other reason that to be used by this particular Web Dynpro application. What is the benefit of placing it in its own independant DC ?
    - <b>Not a typical application of the Command pattern</b>. The well-documented command pattern (Design Patterns - Gang of Four) has been devised mainly to enable encapsulation of request as objects, thereby making it possible to:
    - specify, queue and execute requests at different times
    - decouple execution of a command from its invoker
    - support undo operations
    - support logging changes so that they can be reapplied in case of system crash making it possible to assemble commands into composite commands (macros), thereby structuring a system around high-level operations built on primitive operations.
    None of this applies to the way the SAP CommandBeans are being used. Not that much of an issue to people new to J2EE and/or OO development... but quite confusing for those already familiar with the classic Command pattern.
    At this point, I fail to understand the advantage of merging structure (model) and behaviour (execute methods) through the use of a unique CommandBean object. Am I missing something ?

    Thanks for your reply and your suggestion. I have posted in the Web Dynpro Java forum... and suggest those wishing to participate in this thread to refer to the Web Dynpro Java forum.
    As for your answer, I'm afraid it doesn't satisfy me.
    Reuse is hardly an issue, since the CommandBean is specifically tailor-made for the Web Dynpro application that needs to use it. I could hardly imagine building another application that would just happen to have the exact same needs as far as data structure and processing is concerned...
    As for the right Eclipse environment... the CommandBean is not an EJB artifact - it is an EJB client. The aforementioned tutorial in fact suggests creating it in the Java perspective.
    But thanks anyway for your time and suggestion

  • Using EJBs in Web Dynpro Applications

    I have recently started to develop Web applications using the Web Dynpro framework. Coming from a pure J2EE world, I must admit that Web Dynpro has a few innovative features that I find interesting for user interface development. The use of component & view contexts, for example, is not unlike the ActionForms that one may find in a Struts application, but pushed a bit further. No complaints here.
    What I do have some problems with is the whole CommandBean paradigm that is put forth by SAP (refer to the document <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/using%20ejbs%20in%20web%20dynpro%20applications.pdf">Using EJBs in Web Dynpro Applications</a>).
    I do understand the usefulness of defining a model that will be used to generate and eventually bind to Context data structures. That's fine. What I do object to is the use of a so-called CommandBean to play that role. Again, coming from a J2EE world, I am familiar with the BusinessDelegate pattern - which would typically be used by a client application to invoke business logic on the server side. I would propose that a better, cleaner way of integrating EJBs with the Web Dynpro framework would be to use a BusinessDelegate for invoking business logic, and importing a separate and distinct ModelBean (instead of a CommandBean) to be used for defining and binding to Context data.
    I have built one Web Dynpro application thus far. Instead of using a CommandBean, I created a ModelBean that extends my business object DTO (Data Transfer Object) (which is quite appropriate for that role, given that it implements all the get & set methods that are required for the business data that I need to model). My Web Dynpro application also makes use of an independant BusinessDelegate that is packaged with my EJB DC - this is a standard best practice on J2EE projects. I have been asked by the people working with me to modify this architecture to bring it more in line with the SAP way of doing things. I am open-minded and willing to learn and accept new ways of thinking and doing things. However, I fail to understand the usefulness of merging structure and behaviour by resorting to CommandBeans:
    - <b>It violates the MVC paradigm</b> by having one object (the CommandBean) serve as both model AND controller as far as the Web Dynpro application is concerned. The CommandBean is obviously a model - since it is literally imported as such into the Web Dynpro application. It is ALSO a controller from the Web Dynpro's application perspective, since all calls to the back-end go thru the CommandBean via one or more of its execute_xxx methods. In contrast, the use of a business delegate by the Web Dynpro application clearly separates the model (the CommandBean... or rather, a more suitably named ModelBean) from the controller (BusinessDelegate).
    - <b>Doesn't carry its own weight</b>. In other words, I haven't yet been provided with any valid justification for going thru the extra effort of coding the CommandBean's execute methods. It's been proposed to me that it somehow serves as an abstraction layer between the Web Dynpro application and the business logic. I would argue that it is the BusinessDelegate's role to abstract away the back-end logic from clients. If one does have a BusinessDelegate available, I would argue there's no need to code execute methods in a separate CommandBean. To prove my point, I would simply point out that all of the CommandBean examples that I have seen so far, either in How-To documents, or in production code, all follow the same pattern....
    CommandBean.execute_doSomething() calls BusinessDelegate.doSomething()
    Not a heck of an "abstraction" layer... I would in fact argue that it is worse than useless. If some major change occurs in the business logic that requires changing the doSomething() operation, we expect of course to modify the BusinessDelegate. The Web Dynpro client will also presumably need to be modified - that's to be expected, and unavoidable. But then, we'll also need to go about and change the CommandBean's execute_doSomething() method - again, extra work for no apparent benefit. Adding and removing business methods has the same implication. All this for an layer that simply adds the prefix execute_ in front of all business method calls... Is this "abstraction layer" worth the cost of creating and maintaining it ??
    - <b>Unnecessarily complicates error handling</b>. I have been told that for technical reasons, it is recommended that all exceptions thrown by the CommandBean be of type WDException or WDRuntimException. But what if the client application needs to react differently to different failure scenarios ? When I create a business object, I might wish to provide the user with an error messages if connection is lost to the backend, and with a different error message if an object already exists in the database with the same attributes. In order to do that, I will have to catch the WDException, extract the cause, and continue processing from there... possible, yes, but clearly less standard and more labor intensive than the classical try/catch mechanism.
    To say nothing about the fact that SAP's own API documentation clearly states that applications using Web Dynpro can reference and catch WDExceptions, but THEY MUST NOT THROW OR EXTEND IT !
    - <b>Produces unnecessary DCs</b>. Page 6 of the aforementioned document presents an architectural view of a Web Dynpro project that uses a CommandBean. Why an extra DC for the CommandBean ?? I created my ModelBean class right inside the Web Dynpro project (in the Package view). That, to me, is where this class should reside, because it is created for no other reason that to be used by this particular Web Dynpro application. What is the benefit of placing it in its own independant DC ?
    - <b>Not a typical application of the Command pattern</b>. The well-documented command pattern (Design Patterns - Gang of Four) has been devised mainly to enable encapsulation of request as objects, thereby making it possible to:
    - specify, queue and execute requests at different times
    - decouple execution of a command from its invoker
    - support undo operations
    - support logging changes so that they can be reapplied in case of system crash making it possible to assemble commands into composite commands (macros), thereby structuring a system around high-level operations built on primitive operations.
    None of this applies to the way the SAP CommandBeans are being used. Not that much of an issue to people new to J2EE and/or OO development... but quite confusing for those already familiar with the classic Command pattern.
    At this point, I fail to understand the advantage of merging structure (model) and behaviour (execute methods) through the use of a unique CommandBean object. Am I missing something ?

    Hi Romeo,
    You would be disappointed, this reply ain't anywhere nearby to what you are talking about...
    I wanted to mail you, but you have not mentioned your email in your profile.
    I am really impressed by your flair for writing. It would be far better had you written a blog on this topic. Believe me, it would really be better. There is a much wider audience waiting out there to read your views rather than on the forums. This is what I believe. To top it, you would be rewarded for writing something like this from SDN. On the blogs too, people can comment and all, difference being there you would be rewarded by SDN, here people who reply to you would be rewarded by you. Doesn't make  much a difference.
    Anyways the ball is still in your court
    As far as I am concerned, it has still not been much time since I have started working on Web Dynpro. So can't really comment on the issue...
    Bye
    Ankur

  • Importing EJBs into web dynpros

    I have created EJBS and I would like to use these EJBs in
    web dynpros. How do I do it.
    I think I can create a jar file for the EJBS and reference them in my Web Dynpro project but I think that is not the right way to do it.
    Thanks,
    PKK.

    Hi Simon + Praveen,
      I will try to walk you through how to do it but I think you may need a bit of experience with EJB's, Web Dynpro and NWDS to understand it right away. <i>The following assumes you have created a session and entity bean.</i>
    First you need to make sure your table is deployed in the database that you created(dictionary perspective).
      Second deploy your EJB (.ear file) to the J2EE engine (J2EE development perspective)
      Third switch to Web Dynpro perspective and goto your project properties (right click on the project and click properties)
       Now goto Java Build Path - libraries - add external jars and add the EJB-Jar file. then choose the tab called "order and export" and move the jar file to the top.
    <b>THIS IS A LITTLE TRICKY</b>. Next you need to add the sharing reference. In the same properties wizard where you add the java build path select Web Dynpro References and then select the Sharing references tab. Click on Add and enter the vendor name and name of the ear file like this <vendor name>/<name of the ear file>, This is how your web dynpro knows where the ear file is on the j2ee engine. <b>IF YOU ARE NOT SURE WHAT IT IS</b> you need to access the J2EE visual administrator. and goto SERVER 0/Services/Deploy then select the "runtime" tab then look under <i>Server 0/EJBContainer</i> save all your meta data. your WD application now accesses your EJB logic.
    Good luck!!
    -wael
    *plz dont forget the rewards?

  • Using EJB Model in Web Dynpro

    I have to redeploy my EJB.ear (used as a Web Dynpro model) everytime the J2EE server is started (only the first time), after which My Web Dynpro program continues to work. In other words, the following code in my Command Bean is not successful without redeploying the EJB.ear for some reason. Can someone please tell me what I am doing wrong ?
    home = (MyLocalHome) context.lookup("localejbs/MySessBean");

    Walter, thanks for the reply.  When I checked the EJB Container in VA after starting up the J2EE server, my EJB shows a blue check mark already with the START button grayed out (STOP button is active).  So I would think the EJB is started already...  HOWEVER, I noticed that when I hit the DEPLOY button there, I see a warning message popping up which says :  "This Application hasn't J2EE modules, so it cannot be loaded. Proceeding with Deploy".  I go ahead and finish the Deploy and then my EJB works.  It seems I am not including a module when I deploy it ?
    Paul

  • Web Dynpro Tables from EJB

    I am new to Web Dynpro and I'm trying to write an application that displays data from and EJB in a table in web dynpro.  The EJB returns an array "items[]" to my command bean.  Is there a way to create a table based on the array "items[]" and several properties of the item.

    Hi Jonathan,
    If the properties of the items are static (i.e. not going to change in the course of time), you can create Table with fixed TableColumns (no. of Table columns = no of properties of item) which has TableCellEditor which can be TextView if the data is display only.
    You have to also create context structure which has root node and attributes corresponding to each of the property of item and bind the node to datasource property of Table and bind attributes to each TableCellEditor(TextView's text attribute).
    Just populate the data from your bean to the context creating nodeElements for each item and setting contextAttribute value as the property value.
    Refer https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/bad3e990-0201-0010-3985-fa0936d901b4 for table
    If the properties are dynamic (i.e. changing due course of time). You can create the TableColumns, TableCellEditors dynamically and also the context attributes dynamically in wdDoModifyView.
    Refer Dynamic table column creation for more details
    Hope this helps.
    Thanks and Regards,
    Rohit Jaiswal

  • Expose EJB through Java Bean model importer in Web Dynpro

    Hi,
    I am planning to expose EJB like following:
    1. Create Stateless session bean as a façade for DAO access.
    2. Create DAO to access database. In my case is Oracle DB
    3. Create Java Bean to encapsulate session bean
    4. Import java bean model to web dynpro
    Few of my business method return the object array e.g. Customer[] which contains all properties of customer, and getter, setter.
    Has anyone done this before? Is there any sample code?
    Best Regards,
    Zhang Yan

    Hi
    I think u can refer to the following link
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/java/simple java bean generator for database.pdf
    Thought this link is also Useful
    Creating and Deploying Web Services for an EJB
    Wishes
    Krishna kanth

Maybe you are looking for