When Beans??

when do i put a class as a bean.
when i searched for the difference betwween java calss and bean it had
-->beans are classes with default constructor ,reusable..
Can someone explain me when do i put a bean as class with a simple scenario ..
for eg:a simple jsp or jsf page which submits info
well i don't need the code..but just a simple explanation about the scenario
Thanks in advance

A bean is just a java design pattern/specification. A bean is a class which has at least a default constructor and private properties exposed by public getters/setters.

Similar Messages

  • What happens when bean exits?

    I have a CMP bean and a JSP page as a client. From what I understand, the client will performs a JNDI lookup with the lookup() method and then uses the home object to create an entity bean data with create(). At the end, weblogic will destroy the beans by calling the remove() method of each entity.
    Can someone please explain to me, in details, when the beans get destroyed, what are the expected changes in the database? I've google this for a while, but couldn't get an answer, can you please help? Thanks.

    You must make the difference between Entity and Session beans. Creating an entity bean will imply its creation in the db. Removing an entity bean (by explicitely call of remove()) will imply the deletion from the db.
    In case of a Session the creation does not imply anything to the db layer. Same for remove.

  • Problem with cascade delete and remove bean

    I am working with two entity beans that map to two tables that have a foreign key relationship. Table B has a foreign key to A and in the database that foreign key is set for cascaded updates and cascaded deletes.
    The problem occurs when the the sytem first tries to remove bean 1 (mapped to table A) and then remove bean 2 (mapped to B) where bean 2 is associated with bean 1 with a foreign key relationship. The first remove works but then when it tries to remove bean 2 it throws a very ugly "CORBA TRANSACTION_ROLLEDBACK 9998" Maybe exception. My guess is that the reason is because bean 2's reocrd in the database was deleted when bean 1 was removed but the 'bean object' was not removed from the container.
    When I go into our Application Server and look at how it see's the tables, it show the wrong relationship. It shows a restrict delete and a restrict update realationship.
    My question is, am I wrong to think that this is a application server problem or a configuration problem? It seems to me that attempting to remove a non-existant record should not cause an error. It won't cause any SQL exceptions. Is this a flawed viewpoint? As a work around I made sure that the dependent records are deleted first but it kind of defeats the point of cascaded deletes.
    We have a limited number of support calls, should I use one or am I at fault here?

    If the database removes the record from the second
    table, why is the system trying to remove it once
    again? You should try to remove an entity from a
    single place, should it be the database or the
    application. Don't try to remove it twice.
    Regards,
    DimitarI could do this but it is a huge pain in my ass. The problem is that you might want to remove the dependent bean without removing it's parent. The object structure is a little questionable, I'll admit that. It is, as they say, the eleventh hour and I can't really change that now.
    The way this work is that the server gets a list of objects marked either as new, modified, or deleted. It then relates those changes back to the database.
    In this case we have two lists(which makes me realize where the class structure sucks.) In order to do what you suggest I would have to get all the deleted parent objects and then search all the deleted child objects for ones that have the parent's key in them.
    It would be prefferable to fix the class structure but again this is not an option.
    Anyone want to answer the question I asked?

  • Problem with Read-Only Entity Bean

    Hi All,
    I have an Read-Only BMP that just read data from 20 tables and stores them in a Collection. In a 'Read-Only' Entity bean, the ejbLoad() is supposed to called periodically as defined by 'read-timeout-seconds' parameter in 'weblogic-ejb-jar.xml'. But this doesn't happen. Every time I invoke the EJB, ejbCreate() and ejbLoad() get called. Any suggestions will be highly appreciated.
    Here is the content of my 'weblogic-ejb-jar.xml' file.
    <?xml version="1.0"?>
    <!DOCTYPE weblogic-ejb-jar PUBLIC
    '-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN'
    'http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd'>
    <weblogic-ejb-jar>
    <weblogic-enterprise-bean>
    <ejb-name>beanManaged</ejb-name>
         <entity-descriptor>
              <entity-cache>
                   <max-beans-in-cache>1</max-beans-in-cache>
                   <read-timeout-seconds>5</read-timeout-seconds>
                   <concurrency-strategy>ReadOnly</concurrency-strategy>
              </entity-cache>
         </entity-descriptor>
    <jndi-name>beanManaged</jndi-name>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
    Thanks,
    Prem

    Yes, it calls ejbLoad() at intervals defined by read-timeout-seconds, but only when bean
    is requested by the client, and the cached copy is old. If bean just sits in the cache
    unused no ejbLoad()'s will be called.
    Prem Raghupathy <[email protected]> wrote:
    The weblogic document on 'Setting Entity EJBs to Read-Only' says "WebLogic Server
    never calls ejbStore() for a read-only entity EJB. ejbLoad() is called initially
    when the EJB is created; afterwards, WebLogic Server calls ejbLoad() only at intervals
    defined by the read-timeout-seconds deployment parameter.". Here is the link to
    the document
    http://edocs.bea.com/wls/docs61/ejb/EJB_environment.html#1074846
    Dimitri Rakitine <[email protected]> wrote:
    WebLogic doesn't reload Read-Only entity beans periodically. It loads
    bean instance only when client requests it, and instance is not in the
    cache, or cached instance is older than read-timeout-seconds.
    Prem Raghupathy <[email protected]> wrote:
    This is a multi-part message in MIME format.
    ---=_newsgroups3c21148f
    Content-Type: text/plain
    Content-Transfer-Encoding: 7bit
    Rajesh,
    Thanks for your reply. I&#8217;m using WL6.1 sp1. When I log the methodcalls,
    this is what I see on the server console.
    SetEntityContext()
    ejbCreate()
    ejbPostCreate()
    ejbLoad()
    As you see, the ejbLoad() doesn&#8217;t get called every 5 sec, eventhough I
    set the &#8216;read-timeout-seconds=5&#8217; in the weblogic-ejb-jar.xml,
    Do you have a working example for Read-Only BMP on WL6.1? The examplesdirectory
    in weblogic 6.1 doesn&#8217;t have one.
    Also find attached all the files. Any suggestions will be highly appreciated.
    Thanks,
    Prem.
    Rajesh Mirchandani <[email protected]> wrote:
    What version of the Server and Service pack are you using? Turn on
    JDBC
    logging and see if every ejbLoad() hits the DB.
    prem wrote:
    Hi All,
    I have an Read-Only BMP that just read data from 20 tables and storesthem in a Collection. In a 'Read-Only' Entity bean, the ejbLoad() is
    supposed to called periodically as defined by 'read-timeout-seconds'
    parameter in 'weblogic-ejb-jar.xml'. But this doesn't happen. Every
    time I invoke the EJB, ejbCreate() and ejbLoad() get called. Any suggestions
    will be highly appreciated.
    Here is the content of my 'weblogic-ejb-jar.xml' file.
    <?xml version="1.0"?>
    <!DOCTYPE weblogic-ejb-jar PUBLIC
    '-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN'
    'http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd'>
    <weblogic-ejb-jar>
    <weblogic-enterprise-bean>
    <ejb-name>beanManaged</ejb-name>
    <entity-descriptor>
    <entity-cache>
    <max-beans-in-cache>1</max-beans-in-cache>
    <read-timeout-seconds>5</read-timeout-seconds>
    <concurrency-strategy>ReadOnly</concurrency-strategy>
    </entity-cache>
    </entity-descriptor>
    <jndi-name>beanManaged</jndi-name>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
    Thanks,
    Prem--
    Rajesh Mirchandani
    Developer Relations Engineer
    BEA Support
    ---=_newsgroups3c21148f
    Content-Type: application/x-zip-compressed; name="C:\WebGain\bea\wlserver6.1\samples\examples\ejb20\basic\beanManaged\beanManaged.zip"
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment; filename="beanManaged.zip"
    UEsDBBQAAAAIAJFMkisOCqPkpgMAALEKAAAJAAAAYnVpbGQueG1spVbbbts4
    EH0v0H+YFYpFt7Ctxb42DuAYKprAToN1gPTNoKixw4SWBJJyYxT59w5JXRhH
    chZbIA5kaq5nzhz6rFTFA3IDOdvhNMKH9J+/xynTgo9TZPmS5WyLWQQZblgl
    zTRiUkZABpgJNY0m0fn7d+/fAZz9MR6DRgNbWaRMAoUtURmBGjaFAnMvNKSV
    kBmMx+fOobY4AOZ7oYp8hzmFpy9RfGSwEZJKm0zi9g+f2K6UqCddmldeviFd
    VIpjBHsmKxtkwMyV1lp9+OndnmN/3u+TCW16XNxx3MBimNpig67DLsMS80xP
    Iy4J4BGIXJgR8GJXUptrGsAIHpjyD/SPj2wcaA1+YMrKsnPgUhBwAwlt7Ojc
    B3ATmitkBmkc9BE7BG0IyGYk1tsdxAMufoA0eCJMoQ7krSpuKoVQER8gPTRV
    eXeWZ3RQHpwvtS2Lgx0yPWquREkhNHVvChCmq2D3SPHBkevDT5fwOYpPvIyX
    ye1sfHn9ZcDKjiOI4OspBkLUVmRnOWfpXBvWw+0MyETkXFYZ1lB/mjztZJvH
    GeBTaOByHRmdxXWeprzY1ufZFvtJhvs19+haWgCXTGusAewbzkdiEa0hlkwx
    I4r8r3bzXlAkIF7LlAe2Zxy04kfd28mZl6Np263RIF7PSRwmNsQI7OPXYtd8
    vVEFR61Fvk2UKlTyxLG0pfnXHXLOL7m6cOfN9vXgsWSPCMySOM+Yy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P8dXX4g0JuzyJahGke2cVkbFt402ShwH7YG9ra
    fSJnFBRi2wkbAeAkODWJO1SzQVuL/5n0w9YFAZhDgMPNayuIGDuJt4beT6aK
    Jm60VoWGO43q1W74MU3zcOnzoYjjuIXTOJoauHRzJKKv+pRu47ko9cIje+pg
    8bDL5XpfzamBZi4j/W4QjlGf+dRKvC4TIo8aD1LBlipvBlUwjzpwr62tdlHR
    2s4n2olndsCiCnG1IVUS65cldb5qjLec5DXyUgYbI2/n6K41/pWZF758UEHv
    Imu9NkReof4Op39A4zYWXg022kGriUfOd502KZUiMbSpoxrQMqj1A7VEt9+V
    Smxsbd7tW5cflzXZT/cuweitcO2eYLHy7DsvssItXWSLTQzTDIsQvRXMKpfq
    Id8x3uuAbYVr/bYM9TqzftSUVhHbGvDS4snlZDoZXXw5u7qcjv+Zfnk/Opte
    3fw7WFddr3n/u89THn++aOvzntlZumrmv3e3Bd9QvGiiTX//AVBLAwQUAAAA
    CAC9dl0ruSRzDGQBAADYAgAAHQAAAFByb2Nlc3NpbmdFcnJvckV4Y2VwdGlv
    bi5qYXZhlZJPT+MwEMXvlfod3rFUbFo4gbjwRz2stCshOHCeONPGS2JbM5Nt
    K8R3x0mDioRYtFGUOPGb37x5ciL3TBsG76hNDWvBf8rzZVGSeleUTOE3hbxf
    XU0n08liPp9OMMe9RMeqPmxWIlFWO8fJfAzwCqslbvNqnVcMR03DAjLjNpkO
    1Rax9VZXQlu0UTgLKYDgWIx8QBJWNjS+9Ya1xHYgkXOxC1b0iAFzTZ3VUXAX
    0178pjbM3AnOLi8vUO7xxOWvuPHuFD+DK3DTNHjoRYqHTJe/XBXfUH6cL5dn
    Pep2dYPHveYJ9BvaYjpJXdl4B9eQ6tc58c44VIrjn5c+X+CQMLKxOzJXs2bp
    KNEhtdhZjkoTO7/2XEFNMv5Qc3gu+tdo4ysDsxO8vH7qmHuYdM70EHhKEpN4
    Mj6aGDwM2/+ygOtEQi3a3Ls/XMfrcdB+mHuU/If1ETEW5kG0Syyz9++rPFe+
    3wBQSwMEFAAAAAgAUE2SK2gMv9fQAQAArgQAAA0AAABDYXNlSG9tZS5qYXZh
    lVTBbtswDL0b8D8QPbVBoQy79rK1aFFsGFBs+wHFphN1lmRQdJNg2L+PkuXM
    Te0N08FJZL5HvseHdLr6obcIeNC2azEofN68f6c2OphKbVC7L9rJ+/qmLMrC
    2M4Tw7N+0YdYqO4INeP9ocKOjXc3MyX3n24fvcW5Vw/G1UgLaEXWqK9o/SK/
    6tm0apUmW69WZQEr+L4zAYxjpEZXCPKDdwg7GWBy23hK1zKaCIQ7HVC+XieC
    FiXRddvWlNNMLEo6hCjGF0dIOuCn7E9wDAAjCNY5J2vofJEGDofAexTUxE
    uDbWGJfuo9eZ4SJPpKLKC3XiReg0aYEhQUAO4JsE5b3PZAE0idIaHZtKtwpg
    AA/PdfzIymILqNIgl1fCQn4f4Gyd1/DW/9daPzKj7TiJa2SbU1v3hnegYWte
    0METGavpCJ/xCA15m/GxvEMKJoipDIE9SdjUdGj4kERDNzBEgny+MRm3nVKP
    CELuycGbE0WPNTiKOqtZjGcGLh6TlkEpdCIfiSRm0ZQ45NmG/9p9Lvn/1Vxi
    Z23vJAERKjGRuBzFYRug0abt6WRCQJyl+9e/gcoJXchVVH17fDpt7DKv6s8O
    r4ZgjsE7s3o+eL/K4jdQSwMEFAAAAAgAu16TK34dDI8hCAAAVSIAAAwAAABD
    YXNlRUpCLmphdmHtWVtz2zYWfo5n/B+weimVOPS2j3bS2frWOpt1Xavb7j51
    IPLYgkUCDADKVnf83/ccALxLCj1tpulMOZOIJg7O/fKBLHiy5HfA4JHnRQYm
    hvv5V3+P59yIJJ4Dl//iEtfT4/29/T2RF0pbds9XPBYqnoEWPBO/8nkGx91V
    8yGLX/aelVZk8anKMkisUHLT6k+4pHRf1iMpFZ9q4BbOHxMohts9yVlZZCJB
    qn/Ceifh+buT3evSCrs+QfO3r54qaeHRbiK4EDIFvVPClZqVycJz2kn4/fwe
    nXKl7IUqZbqVVPJ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amIt
    amFyLnhtbFBLAQIUABQAAAAIANt4kiv6rmDSJgEAACoCAAAUAAAAAAAAAAEA
    IAC2gYYFAAB3ZWJsb2dpYy1lamItamFyLnhtbFBLAQIUABQAAAAIADhNkiuT
    J+0NxQUAAJMQAAAMAAAAAAAAAAEAIAC2gd4GAABTZXJ2bGV0LmphdmFQSwEC
    FAAUAAAACAC9dl0ruSRzDGQBAADYAgAAHQAAAAAAAAABACAAtoHNDAAAUHJv
    Y2Vzc2luZ0Vycm9yRXhjZXB0aW9uLmphdmFQSwECFAAUAAAACABQTZIraAy/
    19ABAACuBAAADQAAAAAAAAABACAAtoFsDgAAQ2FzZUhvbWUuamF2YVBLAQIU
    ABQAAAAIALtekyt+HQyPIQgAAFUiAAAMAAAAAAAAAAEAIAC2gWcQAABDYXNl
    RUpCLmphdmFQSwECFAAUAAAACACPSpIrm/ShfEkBAACoAgAACQAAAAAAAAAB
    ACAAtoGyGAAAQ2FzZS5qYXZhUEsFBgAAAAAIAAgA4wEAACIaAAAAAA==
    ---=_newsgroups3c21148f----
    Dimitri
    Dimitri

  • Can't update in mysql

    I am using JSP and MYSQL with a bean that does my database work.
    my search.jsp looks up records, when I click edit it sends the values to my inventory_admin.jsp
    When I make the changes to the data, the data is not saved in the database.
    Please, look see!
    <!--search.jsp-->
    <jsp:useBean id="inventoryBean" scope="session" class="mybeans.inventoryBean" />
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <%// Do search with bean.
         String s = request.getParameter("searchField");
         int searchId = -1;
         if(s != null)
              try
                   searchId = Integer.parseInt(s);
              catch(NumberFormatException e) {}
         //Do actual search with bean
         boolean rc = false;
         if(searchId != -1)
              rc = inventoryBean.findByPrimaryKey(searchId);
              %>
    <form action="search.jsp" method="post" enctype="application/x-www-form-urlencoded">
    <h2 align="center">Software Inventory </h2>
    <p align="center"> </p>
    <p>Lookup:
    <input name="searchField" type="text" id="searchField">
    <input type="submit" name="Submit" value="Submit">
    </p>
    </form>
    <%
         //Output 'not found' message if needed
         if(rc == false)
              out.println("<P><B>Product not found</B></P>");
    %>
    <table width="25%" border="0">
    <tr>
    <td>Item ID:</td>
    <td><jsp:getProperty name="inventoryBean" property="itemid" /></td>
    </tr>
    <tr>
    <td>Product Name:</td>
    <td><jsp:getProperty name="inventoryBean" property="item" /></td>
    </tr>
    <tr>
    <td>Platform:</td>
    <td><jsp:getProperty name="inventoryBean" property="platform" /></td>
    </tr>
    <tr>
    <td>Serial:</td>
    <td><jsp:getProperty name="inventoryBean" property="serial" /></td>
    </tr>
    <tr>
    <td>Description:</td>
    <td><jsp:getProperty name="inventoryBean" property="description" /></td>
    </tr>
    </table>
    <p>&nosave=yes">EDIT</a></p>
    <p align="center"> </p>
    </body>
    </html>
    <!--inventory_admin.jsp-->
    <jsp:useBean id="inventoryBean" scope="session" class="mybeans.inventoryBean" />
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <%-- Copy all form variables at once into the bean--%>
    <jsp:setProperty name="inventoryBean" property="*" />
    <%
         boolean saveResult = false;
         boolean notSaved = false;
         //Save our changes
         String s = request.getParameter("nosave");
         if(s == null || s.equals("yes") == false)
    saveResult = inventoryBean.update();
         else
              notSaved = true;
         //Do search with bean
         s = request.getParameter("itemid");
         int searchId = -1;
         if(s != null)
              try
                   searchId = Integer.parseInt(s);
              catch(NumberFormatException e) {}
         //Do actual search with Bean
         boolean rc;
         if(searchId != -1)
              rc = inventoryBean.findByPrimaryKey(searchId);
    %>
    <h2 align="center">Software Inventory - Edit Mode</h2>
    <FORM action="inventory_admin.jsp" method="post" enctype="application/x-www-form-urlencoded">
    <table width="25%" border="0">
    <tr>
    <td>ITEMID</td>
    <td><jsp:getProperty name="inventoryBean" property="itemid" /></td>
    </tr
    <tr>
    <td>Product Name:</td>
    <td><input name="description" type="text" value="<jsp:getProperty name="inventoryBean" property="item" />"></td>
    </tr>
    <tr>
    <td>Platform:</td>
    <td><input name="description" type="text" value="<jsp:getProperty name="inventoryBean" property="platform" />"></td>
    </tr>
    <tr>
    <td>Serial:</td>
    <td><input name="description" type="text" value="<jsp:getProperty name="inventoryBean" property="serial" />"></td>
    </tr>
    <tr>
    <td>Description:</td>
    <td><input name="description" type="text" value="<jsp:getProperty name="inventoryBean" property="description" />"></td>
    </tr>
    </table>
    <%
         if(notSaved == false)
              if(saveResult == true)
                   out.println("Changes saved");
              else
                   out.println("Changes NOT saved");
    %>
    <p><input type="submit" name="Submit" value="Submit"></p>
    <p align="center"> </p>
    </FORM>
    </body>
    </html>
    //inventory.java
    Here is the Bean Im using:
    // inventoryBean.java - Simple database bean for table products
    package mybeans; // Our custom 'package'.
    import mybeans.DBConfigInfo; // Import helper classes
    import mybeans.DBWorker; // for simpler database programming.
    // Import other packages here.
    import java.sql.*; // For database access.
    import java.util.Hashtable; // For findRecords().
    public class inventoryBean
    private boolean isBeanDataValid = false; // Set when bean contains valid data.
    private boolean isDBError = false; // Stores whether there was a processing error.
    private String dbErrorMsg = "(No error)";
    private DBWorker dbWorker; // Helper object for JDBC programming.
    // Attributes
    private String item = "";
    private String platform = "";
    private String serial = "";
    private String description = "";
    private int itemid = 0; // Primary key field
    public void clear()
    // Clears data in all your properties to 'empty' state.
    item = "";
    platform = "";
    serial = "";
    description = "";
    itemid = 0; // Primary key field
    // Accessor Methods
    public void setItem(String newItem) { item = newItem; }
    public String getItem() { return item; }
    public void setPlatform(String newPlatform) { platform = newPlatform; }
    public String getPlatform() { return platform; }
    public void setSerial(String newSerial) { serial = newSerial; }
    public String getSerial() { return serial; }
    public void setDescription(String newDescription) { description = newDescription; }
    public String getDescription() { return description; }
    public void setItemid(int newItemid) { itemid = newItemid; }
    public int getItemid() { return itemid; }
    // Operations
    // Default constructor.
    public inventoryBean()
    // Create a helper object to work with database.
    // DO NOT DELETE THIS CODE.
    dbWorker = new DBWorker();
    // Database Operations
    // Built-in methods:
    public boolean findByPrimaryKey(int searchId)
    // Use this method to find 1 record by primary key for your table.
    // (After this call, all fields will be loaded into your properties.)
    // Clear existing data, if any.
    clear();
    isBeanDataValid = false;
    // Query by primary key.
    boolean rc = dbWorker.open();
    if(rc == false)
    isDBError = true;
    dbErrorMsg = dbWorker.errorMsg;
    return false;
    try
    // 1) Get a connection.
    Connection conn = dbWorker.getConnection();
    // 2) Create a statement.
    Statement st = conn.createStatement();
    // 3) Build your SQL.
    String sql = "SELECT item, platform, serial, description, " +
    "itemid " +
    "FROM products " +
    "WHERE itemid=" + searchId;
    //System.out.println("DEBUG SQL =" + sql);
    // 4) Get a result set.
    ResultSet rs = st.executeQuery(sql);
    // 5) Move to first record
    if(rs.next())
    // 6) Retrieve fields into your properties using JDBC get??? methods.
    item = rs.getString("item");
    platform = rs.getString("platform");
    serial = rs.getString("serial");
    description = rs.getString("description");
    itemid = rs.getInt("itemid");
    // 7) Ensure non-null String fields with dbWorker.safeStr()
    item = dbWorker.safeStr(item);
    platform = dbWorker.safeStr(platform);
    serial = dbWorker.safeStr(serial);
    description = dbWorker.safeStr(description);
    // Set result code.
    isBeanDataValid = true;
    // 8) Close all DB objects.
    rs.close();
    st.close();
    dbWorker.close(); // Connection too.
    catch(SQLException e)
    System.out.println("Error in findByPrimaryKey (" + e.getMessage() + ")");
    return isBeanDataValid;
    // Update a record
    public boolean update()
    // Use this to update a record by a primary key.
    boolean resultCode = false;
    // Query by primary key.
    boolean rc = dbWorker.open();
    if(rc == false)
    isDBError = true;
    dbErrorMsg = dbWorker.errorMsg;
    return false;
    try // Remember to put all DB code inside a try block!
    // 1) Get a connection.
    Connection conn = dbWorker.getConnection();
    // 2) Create a statement.
    Statement st = conn.createStatement();
    // 3) Build your SQL.
    String sql = "UPDATE products SET item=" + dbWorker.sqlStr(item) + "," +
    "platform=" + dbWorker.sqlStr(platform) + "," +
    "serial=" + dbWorker.sqlStr(serial) + "," +
    "description=" + dbWorker.sqlStr(description)+
    " WHERE itemid=" + itemid;
    //System.out.println("DEBUG SQL =" + sql);
    // 4) Run action query.
    int rowsAffected = st.executeUpdate(sql);
    // 5) See if we succeeded (1 recorded affected).
    if(rowsAffected == 1)
    resultCode = true;
    else
    System.out.println("Warning: Can't update in update()!");
    // 6) Close all DB objects.
    st.close();
    dbWorker.close(); // Connection too.
    catch(SQLException e)
    System.out.println("Error in update (" + e.getMessage() + ")");
    return resultCode;
    // Delete a record
    public boolean delete(int deleteId)
    // Use this to delete a record by a primary key.
    boolean resultCode = false;
    // Query by primary key.
    boolean rc = dbWorker.open();
    if(rc == false)
    isDBError = true;
    dbErrorMsg = dbWorker.errorMsg;
    return false;
    try
    // 1) Get a connection.
    Connection conn = dbWorker.getConnection();
    // 2) Create a statement.
    Statement st = conn.createStatement();
    // 3) Build your SQL.
    String sql = "DELETE FROM products WHERE itemid=" + deleteId;
    //System.out.println("DEBUG SQL =" + sql);
    // 4) Run action query.
    int rowsAffected = st.executeUpdate(sql);
    // 5) See if we succeeded (1 recorded affected).
    if(rowsAffected == 1)
    resultCode = true;
    else
    System.out.println("Warning: Can't delete ID #" + deleteId + " in delete()!");
    // 6) Close all DB objects.
    st.close();
    dbWorker.close(); // Connection too.
    catch(SQLException e)
    System.out.println("Error in delete (" + e.getMessage() + ")");
    return resultCode;
    // Insert a new record.
    public boolean insert(String newItem, String newPlatform, String newSerial, String newDescription,
    int newItemid)
         // Use this to update a record by a primary key.
    boolean resultCode = false;
    // Query by primary key.
    boolean rc = dbWorker.open();
    if(rc == false)
    isDBError = true;
    dbErrorMsg = dbWorker.errorMsg;
    return false;
    try // Remember to put all DB code inside a try block!
    // 1) Get a connection.
    Connection conn = dbWorker.getConnection();
    // 2) Create a statement.
    Statement st = conn.createStatement();
    // 3) Build your SQL.
    String sql="INSERT INTO products(item, platform, serial, description, " +
    "itemid) " +
    "VALUES(" + dbWorker.sqlStr(newItem) + "," + dbWorker.sqlStr(newPlatform) + "," + dbWorker.sqlStr(newSerial) + "," + dbWorker.sqlStr(newDescription) + "," +
    newItemid + ")";
    //System.out.println("DEBUG SQL =" + sql);
    // 4) Run action query.
    int rowsAffected = st.executeUpdate(sql);
    // 5) See if we succeeded (1 recorded affected).
    if(rowsAffected == 1)
    resultCode = true;
    else
    System.out.println("Warning: Can't update in insert()!");
    // 6) Close all DB objects.
    st.close();
    dbWorker.close(); // Connection too.
    catch(SQLException e)
    System.out.println("Error in insert (" + e.getMessage() + ")");
    return resultCode;
    public int findMaxPrimaryKey()
    // Use this method to find the current max. value for a primary key
    // in the database for a given table.
    int retVal = -1;
    // Query by primary key.
    boolean rc = dbWorker.open();
    if(rc == false)
    isDBError = true;
    dbErrorMsg = dbWorker.errorMsg;
    return -1;
    try // Remember to put all DB code inside a try block!
    // 1) Get a connection.
    Connection conn = dbWorker.getConnection();
    // 2) Create a statement.
    Statement st = conn.createStatement();
    // 3) Build your SQL.
    String sql = "SELECT MAX(itemid) FROM products";
    //System.out.println("DEBUG SQL =" + sql);
    // 4) Get a result set.
    ResultSet rs = st.executeQuery(sql);
    // 5) Move to first record
    if(rs.next())
    // 6) Retrieve fields into your properties using JDBC get??? methods.
    retVal = rs.getInt(1); // Get first and only column.
    // 7) Close all DB objects.
    rs.close();
    st.close();
    dbWorker.close(); // Connection too.
    catch(SQLException e)
    System.out.println("Error in findMaxPrimaryKey (" + e.getMessage() + ")");
    return retVal;
    public Hashtable findRecords(String filter, String orderBy)
    // Use this method to return a Hashtable filled with
    // one or more records. You can specified a 'filter'
    // for finding records and 'orderBy' will determine the sort order.
    Hashtable retVal = new Hashtable();
    retVal.put("ROWCOUNT", "0");
    retVal.put("COLUMNCOUNT", "0");
    retVal.put("STATUS", "EMPTY");
    // Query by primary key.
    boolean rc = dbWorker.open();
    if(rc == false)
    isDBError = true;
    dbErrorMsg = dbWorker.errorMsg;
    return retVal;
    try // Remember to put all DB code inside a try block!
    // 1) Get a connection.
    Connection conn = dbWorker.getConnection();
    // 2) Create a statement.
    Statement st = conn.createStatement();
    // 3) Build your SQL.
    String sql = "SELECT item, platform, serial, description, " +
    "itemid " +
    "FROM products " +
    "WHERE " + filter + " " +
    "ORDER BY " + orderBy;
    //System.out.println("DEBUG SQL =" + sql);
    // 4) Get a result set.
    ResultSet rs = st.executeQuery(sql);
    int rowCount = 0;
    // 5) Move to first record (and then next) record.
    while(rs.next())
    // 6) Retrieve fields into your properties using JDBC get??? methods.
    String thisItem = rs.getString("item");
    String thisPlatform = rs.getString("platform");
    String thisSerial = rs.getString("serial");
    String thisDescription = rs.getString("description");
    int thisItemid = rs.getInt("itemid");
    // 7) Ensure non-null String fields with dbWorker.safeStr()
    thisItem = dbWorker.safeStr(thisItem);
    thisPlatform = dbWorker.safeStr(thisPlatform);
    thisSerial = dbWorker.safeStr(thisSerial);
    thisDescription = dbWorker.safeStr(thisDescription);
    // 8) Load this row into our Hashtable.
    // The convention here is to pack each row's column name with an ID
    // indicating the row. "ProjectId" + "0" = "ProjectId0" ===mapped to===> Value
    // Put this record into Hashtable.
    retVal.put("item" + rowCount, thisItem);
    retVal.put("platform" + rowCount, thisPlatform);
    retVal.put("serial" + rowCount, thisSerial);
    retVal.put("description" + rowCount, thisDescription);
    retVal.put("itemid" + rowCount, "" + thisItemid);
    rowCount++;
    // 9) Close all DB objects.
    rs.close();
    st.close();
    dbWorker.close(); // Connection too.
    // Write info to our hashtable--Since this container hold virtually anything,
    // you can put in whatever 'metadata' you want about your result set.
    retVal.put("ROWCOUNT", "" + rowCount);
    retVal.put("COLUMNCOUNT", "5");
    retVal.put("STATUS", "OK");
    catch(SQLException e)
    System.out.println("Error in findRecords (" + e.getMessage() + ")");
    retVal.put("STATUS", "ERROR");
    return retVal;
    //============================================================
    // DO NOT CHANGE THE CODE BELOW.
    //============================================================
    public boolean isValid()
    // Does bean contain real data?
    return isBeanDataValid;
    public boolean isError()
    // Returns true if there was a DB error.
    return isDBError;
    public String getErrorMsg()
    // Returns error message, if any.
    return dbErrorMsg;
    //=====================================================================
    // TODO: Remember to comment out main() with /* */ for production code!
    //=====================================================================
    // TEST DRIVER CODE
    public static void main(String[] args)
    // Test driver code goes here.
    String beanName = "inventoryBean";
    String tableName = "products";
    boolean isDataValidationError = false;
    // Exercise CRUD functionality of this bean.
    System.out.println("==============================================================");
    System.out.println("Starting Test Driver for bean " + beanName + "....");
    System.out.println("==============================================================");
    // Create bean.
    inventoryBean myBean = new inventoryBean();
    // Create a new record.
    int newId = myBean.findMaxPrimaryKey();
    newId++;
    boolean rc = myBean.insert("e", "t", "g", "R",
    newId);
    if(rc)
    System.out.println("SUCCESS: Inserted new record #= " + newId + ".");
    else
    System.out.println("ERROR! Can't insert record #= " + newId + ".");
    System.out.println("====================================================");
    System.out.println("VALIDATION FAILED: Test driver generated an error.");
    System.out.println("====================================================");
    return;
    // Retrieve a record
    rc = myBean.findByPrimaryKey(newId);
    if(rc)
    System.out.println("SUCCESS: Record #" + newId + " found.");
    else
    System.out.println("====================================================");
    System.out.println("VALIDATION FAILED: Test driver generated an error.");
    System.out.println("====================================================");
    System.out.println("ERROR! Record #" + newId + " NOT found.");
    // Simulate using set??? accessor methods with test data.
    // (Note: We don't change the primary key.)
    int testItemid = newId;
    System.out.println("Testing set???() accessor methods....");
    System.out.println("Setting Record #" + newId + " to:");
    System.out.println(" inventoryBean.setItem(testItem); // = R");
    myBean.setItem(testItem);
    System.out.println(" inventoryBean.setPlatform(testPlatform); // = Y");
    myBean.setPlatform(testPlatform);
    System.out.println(" inventoryBean.setSerial(testSerial); // = E");
    myBean.setSerial(testSerial);
    System.out.println(" inventoryBean.setDescription(testDescription); // = k");
    myBean.setDescription(testDescription);
    System.out.println(" inventoryBean.setItemid(testItemid); // = " + newId);
    myBean.setItemid(testItemid);
    // Call update.
    rc = myBean.update();
    if(rc)
    System.out.println("SUCCESS: Record #" + newId + " updated.");
    else
    System.out.println("ERROR! Record #" + newId + " NOT updated.");
    System.out.println("====================================================");
    System.out.println("VALIDATION FAILED: Test driver generated an error.");
    System.out.println("====================================================");
    return;
    // Requery and validate each field.
    rc = myBean.findByPrimaryKey(newId);
    if(rc)
    System.out.println("SUCCESS: Updated Record #" + newId + " found.");
    else
    System.out.println("====================================================");
    System.out.println("VALIDATION FAILED: Test driver generated an error.");
    System.out.println("====================================================");
    System.out.println("ERROR! Record #" + newId + " NOT found");
    // Simulate using get??? accessor methods.
    // Validate updated values against test values.
    System.out.println("Validating Record #" + newId + ":");
    String testData;
    String actualItem = myBean.getItem();
    testData = "R";
    if(testData.equals(actualItem))
    System.out.println(" OK: inventoryBean.getItem() = actualItem");
    else
    System.out.println(" ERROR! inventoryBean.getItem() returned [" + actualItem + "] instead of [R]");
    isDataValidationError = true;
    String actualPlatform = myBean.getPlatform();
    testData = "Y";
    if(testData.equals(actualPlatform))
    System.out.println(" OK: inventoryBean.getPlatform() = actualPlatform");
    else
    System.out.println(" ERROR! inventoryBean.getPlatform() returned [" + actualPlatform + "] instead of [Y]");
    isDataValidationError = true;
    String actualSerial = myBean.getSerial();
    testData = "E";
    if(testData.equals(actualSerial))
    System.out.println(" OK: inventoryBean.getSerial() = actualSerial");
    else
    System.out.println(" ERROR! inventoryBean.getSerial() returned [" + actualSerial + "] instead of [E]");
    isDataValidationError = true;
    String actualDescription = myBean.getDescription();
    testData = "k";
    if(testData.equals(actualDescription))
    System.out.println(" OK: inventoryBean.getDescription() = actualDescription");
    else
    System.out.println(" ERROR! inventoryBean.getDescription() returned [" + actualDescription + "] instead of [k]");
    isDataValidationError = true;
    int actualItemid = myBean.getItemid();
    if(actualItemid == newId)
    System.out.println(" OK: inventoryBean.getItemid() = actualItemid");
    else
    System.out.println(" ERROR! inventoryBean.getItemid() returned [" + actualItemid + "] instead of [" + newId + "]");
    isDataValidationError = true;
    // Cleanup with delete.
    rc = myBean.delete(newId);
    if(rc)
    System.out.println("SUCCESS: Record #" + newId + " deleted.");
    else
    System.out.println("ERROR! Record #" + newId + " NOT deleted.");
    // Now test out findRecords() for up to 100 records.
    Hashtable data = myBean.findRecords("itemid > 0", "itemid");
    String s = (String)data.get("STATUS");
    if(s != null && s.equals("OK"))
    s = (String)data.get("ROWCOUNT");
    int rowCount = Integer.parseInt(s);
    if(rowCount > 100) // Just output first 100 records.
    rowCount = 100;
    System.out.println("SUCCESS: Returning " + rowCount + " records (100 max.) using findRecords():");
    for(int i = 0; i < rowCount; i++)
    System.out.println(" Row #" + i + "=" +
    data.get("item" + i) + ", " +
    data.get("platform" + i) + ", " +
    data.get("serial" + i) + ", " +
    data.get("description" + i) + ", " +
    data.get("itemid" + i));
    else
    System.out.println("ERROR! No rows returned using findRecords()!");
    System.out.println("====================================================");
    System.out.println("VALIDATION FAILED: Test driver generated an error.");
    System.out.println("====================================================");
    return;
    if(isDataValidationError == false)
    // Print final success message.
    System.out.println("================================================================================");
    System.out.println("VALIDATION SUCCESS! Bean " + beanName + " passed all automated tests.");
    System.out.println("================================================================================");
    else
    System.out.println("====================================================================================");
    System.out.println("ERROR! Tests completed but bean " + beanName + " had a data validation error.");
    System.out.println("====================================================================================");

    Couple of pointers.
    1 - use [ code ] tags to post code
    2 - that is WAY too much code for more than a cursory glance. You're lucky the problem was easy to spot.
    Your problem lies in your edit JSP form:
    <td>Product Name:</td>
    <td><input name="description" type="text" value="<jsp:getProperty name="inventoryBean" property="item" />"></td>Note that the name of the input field is different from the jsp property you are populating it with.
    In fact, all of your input fields have a name of "description"
    I would recommend on your inventory_admin.jsp page that you put the following debugging code to make sure that the parameter values come through and are set correctly.
      out.println("name = param: " + request.getParameter("name") + "bean = " + inventoryBean.getName() + "<BR>");
      out.println("description = param:" + request.getParameter("description") + "bean = " + inventoryBean.getDescription() + "<BR>");
      ...

  • Delivery schedule in kanban

    Hi all.
    Can anybody tell me how the delivery schedule is created for scheduling agreement when bean scan empty?
    Thanks

    Hi PKB,
    You need to select the replenishment strategy of External procurement as Working with Scheduling agreements in the control cycle. Prior to this, you need to create a  scheduling agreement through tcode ME31L. And the number generated for the scheduling agreement is to be assigned in the control cycle. This is prerequisite. Whenever you empty the kanban bin or if the status change to empty, than a schedule line is created.
    Reward if cleared and close the thread.
    Keerthi

  • Trying to undestand container interoperability

    Hello !
    After a while of reading the different j2ee specs (EJB, JTA, JTS...), I
    thought I understood that it is possible for a bean in a container A to
    invoke a bean in a container B. The dialog between containers is supposed to
    be in RMI-IIOP.
    First question : how does it look like from the point of view of the calling
    bean ? does it perform a classic lookup like a normal EJB client ? In this
    case, the lookup must be performed on the JNDI server of container B no ?
    thus it is necessary to specify parameters when instanciating an
    InitialContext, no ?
    Second question : If the way the calling bean calls the bean in container B
    looks like what I wondered in my first question, how can transaction and
    security context be propagated to the container B ? Actually, if the bean A
    retrieves a stub from the JNDI of B and performs invocation of B, how can
    the B stub know that A is currently in a transaction in order to tell it to
    B ?
    Actually, while writing my questions, it looks like the B stub does not
    necessarily talks to container B by using RMI-IIOP. So, what bean A should
    do to make container A use RMI-IIOP to talk to B ?
    Forgive me if my questions are a bit confused, but I desperately want to
    know if and how it is possible to make two beans interoperate between
    different containers. And as per the EJB 2 spec, RMI-IIOP seems to be the
    solution, I'd like to understand how a bean can make use of this.
    Thanks for your patience
    Sylvain

    Thanks for your reply. I still have a couple of questions...
    "Andy Piper" <[email protected]> wrote in message
    news:[email protected]..
    "Sylvain Laurent" <[email protected]> writes:
    Correct, but the lookup actually happens via CosNaming. So the scenariois:
    >
    Client -> JNDI -> CosNaming -----------> IIOP ----------> CosNaming ->JNDI -> Server
    Your figure makes me think that the client instanciates an InitialContext
    with the default parameters, no ?
    And it has ejb-ref specially declared in its ejb-jar.xml ? Could you provide
    me with an example ?
    Transactional characteristics are specified in the exported IOR's and
    transactions are propagated via OTS.You mean that container B exports an IOR to container A, which in turns will
    know how to handle transactions when bean A invoke bean B, correct ?
    Because in the case where A makes a direct look-up of bean B with the JNDI
    of B, container A has no opportunity to know what's going on, correct ?
    >
    Actually, while writing my questions, it looks like the B stub does not
    necessarily talks to container B by using RMI-IIOP. So, what bean Ashould
    >
    Why not?Because, for instance WLS uses its own t3 protocol. Thus I can say that if B
    is WLS, B stub talks with container B using T3, unless I made a special
    thing to force it to use RMI-IIOP.
    Forgive me if my questions are a bit confused, but I desperately want to
    know if and how it is possible to make two beans interoperate between
    different containers. And as per the EJB 2 spec, RMI-IIOP seems to bethe
    >
    Of course. This has been demonstrated at the last JavaOne.Unfortunately I was not at the last JavaOne. What was the config for the
    demo ? What containers ?
    Actually I find it quite frustrating not to be able to find any page showing
    a kind of step by step procedure to make two containers work together. Do
    you know of any such a page ?
    Thanks for your support.
    Sylvain

  • Rendering not correct on first visit to page

    I am attempting to dynamically render components on a page during first visit (using request-scope beans), specifically datatable components (rendering via value-binding), as well optionally addMessage for a h:message component. The datatable rendering appears to pick up the default rendering when bean first created. As well, any message added during processing is not displayed.
    Background:
    When page first accessed, I'm trying to build a datatable based on current dates. When there is no data, I'm attempting to display a message and not render the datatable. Tracing indicates that isRendered is false. However, the page is displayed with the Table rendered and no message displayed. I use x:Savestate (myFaces) for subsequent requests, so all is fine then.
    Can anyone help?
    Blue in the faces....

    Hi Suni,
    I have encountered that before.
    It depends on where the page item is that holds the initial value for the root node. This needs to be above the tree. I put a new HTML region above the tree and put the hidden page item in there.
    Andy

  • How to setup session scope in servlet?

    bean tag can be used in jsp to setup its scop, like
    <jsp:usebean id="abc" class="def" scope="session"/>
    but is it possible to setup session scope to divide two users in order not to use the same bean? becuase i encounter a problem that, when using bean in servlet, seemly A user would access the data that B user just store in; at first, i try to compare if session == null or session.isNew(), but finally find out that their session.getId() is difference, thus i suppose that if i am able to decide via users' session id to limit their access to the bean just as jsp:usebean does!
    is that right? or in what way is better?(i am now to rewrite my original code, it's a little bit complicate for some reasons, so i think, if possible, that via compare session id, that i do not know how, would be a better way!)
    thanks in advice,

    If each user has a separate session, then each one
    should get their own instance of the bean. Is it
    possible that that you store and retrieve a reference
    to the bean in a servlet instance variable? That
    would cause the problem you describe.do you mean by putting variable in situation like A) ; yes i did, but if i put bean in the body of doPost method, each time when bean are "new"ed, there may be error occurred, accounting for i hope to instantize with default value, but default constructor do nothing; thus if by only construct with default constructor, error would occurred and so a new constructor with parameters i put in the position you refferred to! would you like to tell me what's the right way for i am not so familiar with servlet.
    thanks in advice,
    A)
    public class MyClassName extends HttpServlet {
    BeanClass myBean = new BeanClass();
    ... doGet(...){}
    ... doPost(...){...}

  • Best Practice EJB 3.0 Question

    I have a web application consisting of 3 projects:
    - Model (EJB 3.0 Session Beans connected to two different databases)
    - TagLibrary (custom tag library)
    - ViewController (Web App / GUI)
    Currently I am connecting to the EJB Beans using code that Jdeveloper generates for a test client:
    env.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
    env.put(Context.PROVIDER_URL, "t3://localhost:7101");
    However would like to move these to a properties file (I believe jndi.properties) such that they can be modified based on app server.
    My question is following:
    What is best practice for Session beans in the Model project to access other session beans in the same project? Do I also need to specify JNDI prop file and settings? (This occurs when Bean from one database needs to access bean from another database).
    Or should I really put these in two separate projects / EJB libraries?
    Thanks,
    Kris

    You have two options, first is to use JNDI lookup (you should be able to use just new InitialContext(), without the environment map).
    Second one is more elegant and, as far as I'm concerned, should be referred to as best practice, that is using dependency injection:
    @EJB
    YourSesionBeanInterface yourEJB;
    If you get stuck, there is plenty of documentation about this on the internet.
    Pedja

  • Javax.ejb.DuplicateKeyException: Exception [EJB - 10007]

    Hi,
    I am deploying an EJB application in OAS10.1.3.1. (it comes with toplink)
    The application executes bean.remove() and removes the bean and then it creates
    the same bean again using bean.create() in the same transaction.
    When bean.create() executes the following exception is encountered.
    Is there any setting in toplink that will help me avoid this situation.
    javax.ejb.DuplicateKeyException: Exception [EJB - 10007]: Exception creating bean of type [XXXX]. Bean already exists.
    at oracle.toplink.internal.ejb.cmp.EJBExceptionFactory.duplicateKeyException(EJBExceptionFactory.java:195)
         at oracle.toplink.internal.ejb.cmp.oc4j.Oc4jPersistenceManager.createBean(Oc4jPersistenceManager.java:163)
         at com.evermind.server.ejb.interceptor.system.TopLinkCreateInterceptor.invoke(TopLinkCreateInterceptor.java:51)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:50)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.SecurityRoleInterceptor.invoke(SecurityRoleInterceptor.java:47)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:55)
         at com.evermind.server.ejb.AbstractEJBHome.OC4J_invokeMethod(AbstractEJBHome.java:723)

    Thanks for the response and the direction.
    Its Bug No.6713854
    Could you please shed some light on toplink flavors and support/fixes.
    That is:
    1. Is toplink that comes with OAS different than the open source toplink?
    2. If so, how are bugs tracked. where should I go and look for the bugs for the open source version?
    3. Could we use the open source version for OC4J?
    Thanks :)

  • RuntimeException - Transaction Rollback

              Hi,
              I am using weblogic 6.1 on WINDOWS platform..
              hv few questions on Container Managed Transactions:
              1. What is the Bean-default transaction attribute
              (If I don't specify any transaction attribute for
              one of the method in SLSB).
              2. Does Weblogic container rollbacks transaction for any
              RuntimeException that has been thrown from Business
              method OR only for EJBException.
              3. What are the pros and cons of Specifying a Transaction
              attribute for a Business method that only executes
              SELECT statements.
              4. if I want to manage my trasaction explicitly using
              USerTransaction (Client Demarcated) do I hv control
              over Distributed transactions.
              thx,
              Ramesh
              

    Ramesh <[email protected]> wrote:
              > Hi,
              > I am using weblogic 6.1 on WINDOWS platform..
              > hv few questions on Container Managed Transactions:
              > 1. What is the Bean-default transaction attribute
              > (If I don't specify any transaction attribute for
              > one of the method in SLSB).
              I think the default is 'Supports'
              > 2. Does Weblogic container rollbacks transaction for any
              > RuntimeException that has been thrown from Business
              > method OR only for EJBException.
              Yes. There is a table in the 'Exception Handing' section of the EJB
              spec which describes what happens when bean methods throw various
              exceptions.
              > 3. What are the pros and cons of Specifying a Transaction
              > attribute for a Business method that only executes
              > SELECT statements.
              At the very least it wil decrease number of ejbLoad()'s if you
              use Entity Beans.
              > 4. if I want to manage my trasaction explicitly using
              > USerTransaction (Client Demarcated) do I hv control
              > over Distributed transactions.
              > thx,
              > Ramesh
              Dimitri
              

  • Scrolling component into view programmatically without using javascript

    Hi,
    Is it possible to scroll an adf component into view programmatically without using javascript?
    I know of <af:scrollComponentIntoViewBehaviour> that can be added to a command component , but is there a way to do that programmatically in a bean?
    Problem with using javascript is its not guaranteed to work in different browsers.
    Regards,
    Rakesh.

    Hi John,
    Thanks for the reply.
    If i use the af:scrollComponentIntoViewBehavior, then i wont be able to achieve my desired functionality.
    In my use case, i want the id, of the component that needs to be scrolled into view, to be determined in the server listener of the button which is not happening.
    Code snippet in jspx page is as follows:
    <af:commandButton id="cb1" immediate="true">
    <af:clientListener method="clickButton" type="click"/>
    <af:serverListener type="customEvent"
    method="#{pageFlowScope.bean.doScroll }"/>
    <af:scrollComponentIntoViewBehavior id="#{pageFlowScope.bean.compId}/>
    </af:commandButton>
    And the java code for method doScroll is something like :
    public void doScroll (ClientEvent clientEvent)
    //logic to determine compId goes here
    compId = "id";
    So, the problem here is "compId" is set to some value when bean is loaded and the id in the af:scrollComponentIntoViewBehavior will be set to that value forever.
    I cant find any way of telling it to re-read the "compId" value, say after clicking the button. I can refresh the button in the server listener to update the compId .
    But the updated compId will come into picture from *next click*. This is because, after the button is clicked, "scroll" action happens first and then serverListener executes.
    Is there a way to change order of this execution like "execute server listener first and then do the scrolling thing" ?
    Regards,
    Rakesh.
    Edited by: 927925 on Jul 27, 2012 2:02 AM

  • F:facet with ui:fragement & outputtext tags

    Hi,
    I am trying to display header text dynamically for rich:panel. I tried both ways as shown below. But logic doesnt work correctly. It displays test1 when #{!bean.isValid} becomes true. But it never display test when #{bean.isValid} becomes true. Am not sure if I am doing something wrong here. Please advice.
    1,
    <f:facet name="header">
    <h:outputText value="test" rendered="#{bean.isValid}"/>
    <h:outputText value="test1" rendered="#{!bean.isValid}"/>
    </f:facet>
    2,
    <f:facet name="header">
    <ui:fragment rendered="#{bean.isValid}">
    <h:outputText value="test" />
    </ui:fragment>
    <ui:fragment rendered="#{!bean.isValid}">
    <h:outputText value="test1" rendered="#{!bean.isValid}"/>
    </ui:fragment>
    </f:facet>
    Thanks in advance for your time.

    Did I put the problem in a wrong group or my way of coding is incorrect?
    Any help is appreciated...
    Thanks.

  • Weblogic 10.3-  NPE from RemoteBusinessIntfProxy.getTargetMethod

    I am migrating an application from oc4j to WLS 10.3. The application defines EJB3. From a j2se client, I do the following:
    Hashtable env = new Hashtable();
    env.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
    env.put( Context.SECURITY_PRINCIPAL, "weblogic" );
    env.put( Context.SECURITY_CREDENTIALS, "weblogic" );
    env.put(Context.PROVIDER_URL, "t3://localhost:7001");
    Context initial = new InitialContext(env);
    MyEJBRemote remote = (MyEJBRemote) initial.lookup("simple/myejbRemote");
    remote.open();
    However, I got the following NPE exception in runtime:
    java.lang.NullPointerException
    at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.getTargetMethod(RemoteBusinessIntfProxy.java:162)
    at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:53)
    at $Proxy0.open(Unknown Source)
    at demo.client.j2se.JobRequestSubmitorClient.queryRequestSummary(JobRequestSubmitorClient.java:245)
    What might be the cause? How can I turn on trace in client/server side to get more information. Any help are appreciated. Thanks.

    Here are some notes from a related CR, CR305208, that given insight to a work-around. Also consider looking at the known/resolved issues in 10.0, which discuss this as well:
    [http://edocs.bea.com/wls/docs100/issues/known_resolved.html#wp1169024]
    DIAGNOSIS:
    EJB using type variables on class level is not supported.
    RESOLUTION:
    Problem was solved with a code fix to support generic types, especially type
    variables on class level.
    CHANGED BEHAVIOR:
    As a result of this change, generic types can be used for bean class and
    business/component interface of EJB. For example, the following EJB can be
    deployed and invoked successfully:
    public interface RootI<T> {
    public T getObject();
    public void updateObject(T object);
    Business interface:
    @Remote
    public interface StatelessI extends RootI<String> {
    Bean class:
    @Stateless
    public class StatelessSample implements StatelessI {
    public String getObject() {
    return null;
    public void updateObject(String object) {
    RECOMMENDED STYLE
    Please note, under current mechanism of EJB code generation, the recommended
    style to use generic types, is to define super class/interface with type
    variables and make bean class or business/component interface parameterize it
    like the example above. The type variables declared directly on class level
    of bean class or business interface/componnent interface will be erased,
    which can be deployed successfully only when bean class parameterizes
    business interface with the upper bounds of the type parameter and no other
    generic information involved. As a good design, we suggest not to declare
    type variable on class level of bean class or business/component interface
    directly. For example, the following EJB is not legal for Weblogic generic
    support:
    Business interface:
    @Remote
    public interface StatelessI<T> {
    Bean class:
    @Stateless
    public class StatelessSample implements StatelessI<String> {
    public String getObject() {
    return null;
    public void updateObject(String object) {
    Because the type variable "T" on StatelessI has no upper bound explicitly
    declared, the upper bound is Object. So the bean class StatelessSample must
    parameterize StatelessI with Object like following:
    public class StatelessSample implements StatelessI<Object> {
    public Object getObject() {
    return null;
    public void updateObject(Object object) {
    KNOWN ISSUE:
    And, there will be problem when meeting all following conditions:
    1. The business interface doesn't extend java.rmi.Remote.
    2. The invocation of method is via remote proxy through RMI remote
    call, and no generated stub on client side. The local invocation within one
    JVM will succeed.
    3. The remote call is via t3 protocol, not iiop protocol.
    4. The method in business interface has generic information. I.e.
    method has type parameters or generic type like List<String> as parameter
    type, etc.
    WORKAROUND FOR KNOWN ISSUE
    It will be ok when meeting any of the following conditions:
    1. The business interface extends java.rmi.Remote.
    2. Put the generated stub on client side when the invocation of method is via
    remote proxy through RMI remote call. The local invocation within one
    JVM will succeed as well.
    3. The remote call is via iiop protocol, not t3 protocol.
    4. The method in business interface has no generic information. It will be ok
    if the method only has generic info declared on class level of business
    interface, and the type variable is parameterized with raw
    type. For example:
    Interface RootI < T > {
    public void hello (T t ) ;
    public &lt; S extends Comparable &gt; S testComp ( T t , S s ) ;
    //Business interface
    Interface StatelessI extends RootI < String > {
    Though business interface doesn't extend Remote, whatever through remote call
    or local call, the invocation on StatelessI.hello(String) will be ok. But
    remote invocation on StatelessI.testComp() will fail when no generated stub
    on client side.
    Release note text:
    The general issue is covered in Dante EJB docs at
    http://edocs.bea.com/wls/docs100/ejb30/implementing.html#wp1205541
    Known and resolved issues: EJBs
    http://edocs.bea.com/wls/docs100/issues/known_resolved.html#wp1131925
    EJBs with generic information fail when all of the following conditions are
    met:
    The business interface doesn't extend java.rmi.Remote.
    The invocation of method is via remote proxy through RMI remote call, and
    there is no generated stub on client side. The local invocation within one
    JVM will succeed.
    The remote call is via t3 protocol, not iiop protocol.
    The method in the business interface has generic information; that is, type
    parameters or a generic type like List<String> as a parameter type.
    Workaround or Solution:
    Make sure you fulfill any of the following conditions:
    Write your business interface to extend java.rmi.Remote.
    Put the generated stub on the client side when the invocation of method is
    via remote proxy through a RMI remote call. The local invocation within one
    JVM will succeed as well.
    Make the remote call via the iiop protocol, not the t3 protocol.
    Either do not use generic information in the business interface method, or
    use only generic information declared on the class level of the business
    interface with the type variable parameterized with raw type. For example:
    Interface RootI&lt;T&gt; {
    public void hello(T t);
    public &lt;S extends Comparable&gt; S testComp(T t, S s);
    //Business interface
    Interface StatelessI extends RootI&lt;String&gt;{
    Though the business interface doesn't extend Remote, whether through remote
    call or local call, the invocation on StatelessI.hello(String) will work. But
    remote invocation on StatelessI.testComp() will fail when there is no
    generated stub on the client side.

Maybe you are looking for