[DUPLICATE]strange Session Facade method calling behaviour (EJB3/ADF Faces)

Hi,
I have a custom query in a Session Facade bean. On my search form I have a popup dialog and when I return from the dialog, the query in the session facade is called for no explicable reason. In fact it seems to get called several times at different events, but I only want it to be called when I click the button it's bound to. Why is this happening?
The only partial solution I have at the moment is to make one of the method parameters of the query a boolean value that indicates whether I want the query to actually run or not, if it's false I just return from the query. I set this parameter to true in the backing bean when the search button is pressed.
Can someone please point me to a better solution?
many thanks
R

Hi,
as mentioned in teh other posting of your, make sure the refresh condition is set so that it doesn't execute the query on postBack
Frank

Similar Messages

  • Calling session facade methods from my code

    My application consists of two projects: Interface and Model. Model, of course, is used for access to a database using TopLink with POJOs and session facade bean...Pretty much like thing done int tutorial. While, naturally, Interface project are the web pages etc. Standard web application.
    Now, there is no problem with using data controls from session facade bean (drag and drop to the form for making tables, lists, forms etc.), that works fine.
    What I need is to use methods from my session facade bean in my code. For example, I have made a TopLink query findAllLabels. It is exposed in session facade bean UtilBean so in the bean the code is
    List<Labels> findAllLabels(){
    So In some part of my code (for instance, in some backing bean) I would like to call this query. I have done this:
    UtilBean util=new UtilBean();
    List<Labels> labels=util.findAllLabels();
    And this works fine, for now. But, I'm wondering, is this the correct solution, and is there some more ellegant and correct way to do this? Is it correct to instantiate a session facade bean in this way?

    The more appropriate and correct solution is as follows:
    Drag the toplink named query(without expanding it) from the data control pallete into your h:form.
    You will get an option to create a ADF Command Button or ADF Command Link.
    Select ADF Command Button.
    Double click the generated button.
    It enables you to create a default action listener for the button. Ensure that the Check box labelled
    "Generate ADF Binding Code" is checked.
    Click OK.
    This should create a method in your backing bean
    as
    public String commandButton1_action(....)
    /*Generated Code.
    Insert your code here
    This should solve your problem
    Bye.

  • [EJB3 - ADF Faces] entity bean design

    Hello,
    I have an existant application that use database view (very complex) to retrieve and display values from some tables.
    I have to reproduce the same thing with EJB3 ans ADF Faces in a web application.
    What is for you the best way to design entities beans ?
    1. Create some buisness objects (entity beans) and feed them with a query thru the database view ?
    2. Create a unique entity bean with only attributes who are used by the db view ?
    In this case, the entity bean will be used only for this query.
    3. ?
    I think the best solution is the first one.
    But in this case, how to display the result of the query in an ADF Faces table?
    With the 2nd solution the query returns a list of object which will be used by the adf table. That would be much easier.
    Thanks for your help.

    The popup dialog is used for looking up a value of fields on the form. I have fields "location id" and "sub location id", the popup has cascading drop down lists where I choose which ones I want, then return those values from the popup and display the selection in readonly text inputs. Other inputs also exist on the form. Together they all make the input parameters to the session facade's query.

  • Bindings problem (EJB3 - ADF  Faces)

    Hi Forum,
    I have a static fieald in a entityBean (EJB3) with its accessors:
    private static Double totalQty;
    I have this method in a session bean:
    public Double TotalsSaticValues(){
    return VOrderLinesFulladj.getTotalCHF();
    And I want to show the value in a outputText component like this:
    <af:outputText value="#{bindings.TotalsSaticValues1.inputValue}">
    <f:convertNumber groupingUsed="false"
    pattern="{bindings.TotalsSaticValues1.format}"/>
    </af:outputText>
    The problem is that when the page loads, the TotalsSaticValues() method is not called and of corse the value is not shown.
    I have to create a button to call the method:
    <af:commandButton actionListener="#{bindings.TotalsSaticValues.execute}"
    text="TotalsSaticValues"
    disabled="#{!bindings.TotalsSaticValues.enabled}"/>
    And when I click, the value appears !
    What I have to do to call the method without button ?
    Thanks for your help.

    Hi,
    create an invokeAction in the executable section of the pagedef file and point it to the method you otherwise execute from the button.
    The invoke action is invoked when the page loads
    Frank

  • Non numeric @Id being treated as numeric (EJB3/ADF Faces) [Please Frank]

    Hi,
    I have a non-numeric field (varchar2) defined as such:
    public class DepartmentV implements Serializable {
        @Id
        @Column(name="DEPT_ID", nullable = false)
        private String deptId;
    ...When I run the program, I get the following error:
    Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2006.8 (Build 060829)): oracle.toplink.essentials.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-01722: invalid numberThis is because the column in the table has some non-numerics in it. However the column is defined as varchar, and in the EJB it is defined as String, so why is it being treated as a numeric and how do I fix it?
    many thanks
    R

    Hi,
    tried to reproduce in JDeveloper 10.1.3.2 with no success
    @Entity
    @NamedQuery(name = "Testtable.findAll", query = "select o from Testtable o")
    public class Testtable implements Serializable {
    private Long age;
    @Id
    @Column(nullable = false)
    private String idf;
    private String name;
    public Testtable() {
    public Long getAge() {
    return age;
    public void setAge(Long age) {
    this.age = age;
    public String getIdf() {
    return idf;
    public void setIdf(String idf) {
    this.idf = idf;
    public String getName() {
    return name;
    public void setName(String name) {
    this.name = name;
    Works as designed
    Frabj

  • Transaction Problem in Session Facade Design Pattern

    Hi
    Well Sorry for giving wrang title to the topic, coz of which I have not received and reply.
    I am using session facade design pattern.
    I have Action class calling session facade method "getData" . This method calls "findByPrimaryKey" method in BMP.
    Method "getData" has transaction attribute as "RequiresNew" and "findByPrimaryKey" has "Required".
    This combination does not assign identity to BMP hence I can not use setter getter method for retriving data(throws nullpointer exception when getter method accessed) I have made sure that I am accessing table and getting data in to BMP but as BMP is not ablle to hoild any identity its not allowing me to use BMP's getter method in session facade.
    I have Used Same transaction attribute for create method called by "addNew" method of session facade bean.
    Transaction method for "addNew" is "RequiresNew" and for "create" is "Required".
    It works fine and gives identity toBMP hense I can use Setter getter method defined in BMP bean.
    How can I avoid this and get BMP an identity?
    Thanking in Advance,
    Chintan.

    Sorry, how is this related to JSF?
    There's an OO/patterns forum out. Consider reposting the question over there with formatted code.

  • Traction Problem In Session Facade Disign

    Hi
    I am using session facade design pattern.
    I have Action class calling session facade method "getData" . This method calls "findByPrimaryKey" method in BMP.
    Method "getData" has transaction attribute as "RequiresNew" and "findByPrimaryKey" has "Required".
    This combination does not assign identity to BMP hence I can not use setter getter method for retriving data(throws nullpointer exception when getter method accessed) I have made sure that I am accessing table and getting data in to BMP but as BMP is not ablle to hoild any identity its not allowing me to use BMP's getter method in session facade.
    I have Used Same transaction attribute for create method called by "addNew" method of session facade bean.
    Transaction method for "addNew" is "RequiresNew" and for "create" is "Required".
    It works fine and gives identity toBMP hense I can use Setter getter method defined in BMP bean.
    How can I avoid this and get BMP an identity?
    Thanking in Advance,
    Chintan.

    Hi
    I am using session facade design pattern.
    I have Action class calling session facade method "getData" . This method calls "findByPrimaryKey" method in BMP.
    Method "getData" has transaction attribute as "RequiresNew" and "findByPrimaryKey" has "Required".
    This combination does not assign identity to BMP hence I can not use setter getter method for retriving data(throws nullpointer exception when getter method accessed) I have made sure that I am accessing table and getting data in to BMP but as BMP is not ablle to hoild any identity its not allowing me to use BMP's getter method in session facade.
    I have Used Same transaction attribute for create method called by "addNew" method of session facade bean.
    Transaction method for "addNew" is "RequiresNew" and for "create" is "Required".
    It works fine and gives identity toBMP hense I can use Setter getter method defined in BMP bean.
    How can I avoid this and get BMP an identity?
    Thanking in Advance,
    Chintan.

  • Non-synchronized client method calls

    hi there,
    i am having following scenario:
    methods provided in the remote interface of a stateful session bean are called by a remote client.. client is using multithreading. now these methods in stateful session forward method calls to a stateless session and then an entity using local interfaces. the point here is that the client only has one object of the stateful session ( obviously an object per user session)
    the problem is that when i call the methods on this object one by one it goes fine. but when in multithreaded client application one method is called by first thread and another by second at the same time, application crashes. and the server tells that client has tried to enter stateful session with different transaction context. does anybody have some idea to solve this problem without having the client to make synchronized calls.
    thanx in advance,
    ra4a

    Hi,
    The Container serializes calls to stateful session beans.And hence your application calling in a multithreaded environment will surely fail.This is because the state of the bean might be corrupt when calls are concurrent.And different applications servers might provide some way of overriding this behaviour..Surely weblogic has got one way..
    Sathya

  • DAO and session Facade

    Hi
    I came across an design pattern where they call the DAO from Session facade. The purpose of session facade is to minimise the number of network calls. Even though there are no network calls involved why do they go for session facade to call the DAO. Wont a DAOFActory will help them doin this.
    Even if the requirement is to block the presentation layer of all the backend operations, we could have had any other , why session facade was used i could nt understand

    You might even discover that entity beans can get created even before you use them.
    Your application server creates "pools" of bean instances that it can use when it needs to. It is part of this role, and is done in order to optimize performances.
    You cannot force them to be garbage collected. Even if you stop referencing them, the app server will.
    When your create references to a bean, it (usually) won't create an instance. It will take an existing one, and load data into it, using ejbCreate or ejbActivate.
    Hope this helps.
    /Stephane

  • NoSuchMethodException calling a session bean method from a web service

    I am running on NetWeaver 6.40 SP10 on Windows.
    I have a Java class (not a SessionBean) exposed as a web service where I invoke a session bean method with an argument that is another Java class (basically, just a JavaBean with some getters and setters).  I am getting a strange reflection-related error when I invoke a session bean method.  The exception I see is a 'java.lang.reflect.UndeclaredThrowableException', and if I unwrap it with 'ex.getCause()', I see 'java.lang.NoSuchMethodException: com.xx.ejb.PersistentObjectSBObjectImpl0.createR3Config(com.xx.common.R3Config)'
    I have spent several days trying to come up with a testcase for this, but to no avail.  The calling class is:
    --- snip R3UpdateTest.java ---
    package com.xx.server.webse;
    import com.xx.ejb.*;
    import com.xx.common.*;
    import java.util.*;
    import javax.ejb.*;
    import java.rmi.*;
    import javax.naming.*;
    * @author william_woodward
    * To change the template for this generated type comment go to
    * Window>Preferences>Java>Code Generation>Code and Comments
    public class R3UpdateTest {
         public String createR3Config(String a, String b, String c,
                   String d, String e, String f) {
              String retval = "success!";
              try {
                   PersistentObjectSB poSB = getPersistentObjectSB();
                   R3Config r3cfg = new R3Config();
                   r3cfg.setR3HostName(a);
                   r3cfg.setR3SystemNumber(b);
                   r3cfg.setRfcUserName(c);
                   r3cfg.setRfcPassword(d);
                   r3cfg.setRfcClient(e);
                   r3cfg.setRfcLanguage(f);
                   poSB.createR3Config(r3cfg);
              } catch (Exception ex) {
                   retval = "Exception: " + ex + ", Causing Exception : " + ex.getCause();
              return retval;
          * Private methods
         private PersistentObjectSB getPersistentObjectSB() throws RemoteException, CreateException, NamingException {
              Properties props = new Properties();
              props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
              props.put(Context.PROVIDER_URL, "localhost:50004");
              InitialContext ctx;
              ctx = new InitialContext(props);
              PersistentObjectSBHome poSBHome =
                   (PersistentObjectSBHome) javax.rmi.PortableRemoteObject.narrow(
                        ctx.lookup("xx.com/CMPOBEAR/PersistentObjectSBBean"),
                        PersistentObjectSBHome.class);
              return poSBHome.create();
    --- end R3UpdateTest.java ---
    If I change the createR3Config() method to take an argument of class 'Object' instead of an argument of class 'R3Config', and then cast the object back into an R3Config in the method body, it all works fine.
    Any clues, anyone?
    Thanks,
    - Bill
    Message was edited by: Bill Woodward - Fixed some funky formatting

    Sure, I can show them to you.  They are very similar to a couple of non-DC classes/projects I put together to try and duplicate the problem.
    First, the interface, PersistentObjectSB.java:
    package com.xx.ejb;
    import javax.ejb.EJBObject;
    import com.xx.common.R3Config;
    import java.rmi.RemoteException;
    public interface PersistentObjectSB extends EJBObject {
          * Business Method.
         public void updateR3Config(R3Config r3Config) throws RemoteException;
          * Business Method.
         public void createR3Config(R3Config r3Config) throws RemoteException;
    And the implementation, PersistentObjectSBBean.java:
    package com.xx.ejb;
    import java.util.*;
    import javax.ejb.*;
    import javax.naming.*;
    import com.xx.common.*;
    import com.xx.interfaces.*;
    * @ejbHome <{com.xx.ejb.PersistentObjectSBHome}>
    * @ejbLocal <{com.xx.ejb.PersistentObjectSBLocal}>
    * @ejbLocalHome <{com.xx.ejb.PersistentObjectSBLocalHome}>
    * @ejbRemote <{com.xx.ejb.PersistentObjectSB}>
    * @stateless
    public class PersistentObjectSBBean implements SessionBean {
         private R3ConfigEJBLocalHome _r3ConfigEJBLocalHomeIf = null;
         public void ejbRemove() {
         public void ejbActivate() {
              try {
                   setEJBLocalHome();
              } catch (NamingException e) {
                   throw new EJBException(e);
         public void ejbPassivate() {
         public void setSessionContext(SessionContext context) {
              myContext = context;
         private SessionContext myContext;
          * Create Method.
         public void ejbCreate() throws CreateException {
              try {
                   setEJBLocalHome();
              } catch (NamingException e) {
                   throw new CreateException();
          * Business Method.
         public void updateR3Config(R3Config r3Config) {
              try {
                   R3ConfigPrimaryKey primKey = new R3ConfigPrimaryKey();
                   primKey.r3HostName = r3Config.getR3HostName();
                   primKey.r3SystemNumber = r3Config.getR3SystemNumber();
                   R3ConfigEJBLocal r3ConfigEJBLocal =
                        _r3ConfigEJBLocalHomeIf.findByPrimaryKey(primKey);
                   if (r3ConfigEJBLocal != null) {
                        r3ConfigEJBLocal.updateR3Config(r3Config);
              } catch (Exception e) {
                   // What to do here?
          * Business Method.
         public void createR3Config(R3Config r3Config) {
              try {
                   R3ConfigEJBLocal r3ConfigEJBLocal =
                        _r3ConfigEJBLocalHomeIf.create(r3Config);
              } catch (Exception e) {
                   // What to do here?
         private void setEJBLocalHome() throws NamingException {
              Properties props = new Properties();
              props.put(
                   Context.INITIAL_CONTEXT_FACTORY,
                   "com.sap.engine.services.jndi.InitialContextFactoryImpl");
              InitialContext ctx = new InitialContext(props);
              Object obj = ctx.lookup("localejbs/R3ConfigEJB");
              _r3ConfigEJBLocalHomeIf = (R3ConfigEJBLocalHome) (obj);
    Thanks,
    - Bill

  • Creating Session Bean Facade Methods Off EJB QL

    Hello,
    I'm trying to follow the documentation for creating a Session Bean that has facade methods for various Entity Beans. When I add a named query:
    @NamedQuery(name = "Debtor.findDebtorById", query = "select o from Debtor o where o.debtorId = ?1")
    I end up with the following facade method:
    /** <code>select object(o) from Debtor o where o.DEBTOR_ID = ?1</code> */
    public List<Debtor> queryDebtorFindDebtorById(Object p1) {
    return em.createNamedQuery("Debtor.findDebtorById").setParameter(0, p1).getResultList();
    I see two issues here:
    1) The type of the input parameter is supposed to be a long, as the Entity Bean field looks like:
    @Id
    @Column(name="DEBTOR_ID", nullable = false)
    private Long debtorId;
    2) The parameter being set is '0' instead of '1'.
    Is there a known issue with generating this code in JDev? Or am I doing something wrong?

    another strange problem.
    i have an APplication server added ( JBOSS ).
    when i create deployment profile (EAR ) application server is showed in the ComboBox .
    But when i create Java Test Client for some EJB and when i check " Connect Remote Application server" there is 2 comboboxes
    J2EE Application
    App Server Connection.
    first combo is ok there is EJB applicaiton
    Secound is empty .. but i Have App Server.
    Another think is that when i create EJB 3.0 its BAD to see J2EE app it must be J EE 5 app or just Java EE app

  • How to call a EJB method from Session bean method

    Hi all,
    I'm new to J2EE programming. I have a simple doubt .
    I have already created a lookup method for EJB bean in Session bean .
    My question is how to call a method of an ENTITY bean (say insertRow) from SESSION bean method(Say invoke_insertRow) .
    Please provide me an example code .
    Thanks in advance.

    InitialContext ctx = new InitialContext();
         GeneralEditor editor = (GeneralEditor) ctx
                        .lookup("GeneralEditorBean/remote");
              GeneralService service = (GeneralService) ctx
                        .lookup("GeneralServiceBean/remote");
              LanMu lm = new LanMu();
              lm.setName("shdfkhsad");
              editor.add(lm);

  • Problem Calling Remote Session Bean Method

    Need help. I am trying to call a method in a remote stateless session bean in an EJB in my web application from a stateless session bean in a different EJB in the web application. I am getting a run-time error that says,
    "java.lang.NoClassDefFoundError: dtpitb.common.sb.reports.CommonReportsHome"
    ref = ctx.lookup( jndiName );
    // Cast to Local Home Interface using RMI-IIOP
    commonReportsHome = (CommonReportsHome)
    PortableRemoteObject.narrow(ref, CommonReportsHome.class);
    If while in a session bean of an EJB, I want to call a public method in the session bean of a totally different EJB, is there something in particular I am missing. I can make the call from the web application code. I can make a remote call from this session bean to itself in the exact same fashion. I just can't call a session bean in another EJB. All thoughts are welcome.
    Thanks,
    Pete

    Thanks for replying. That could very well be the case I suppose. I'm using JBuilder and WebLogic, and JBuilder pretty much does all of the deployment descriptor code for me. However, maybe this is something I need to incorporate manually.
    One EJB is in the same project as the web application code. The other EJB (common_ejb) is in another project. The calling session bean is in the project with the web app, and the remote session bean method that I'm targeting is in the common EJB session bean. Both EJBs are included in the web app's WEB-INF\lib dir and in the war file.
    So theoretically, this isn't an unconventional practice I assume?
    Thanks,
    Pete

  • Error while calling local session bean from session facade

    Hi Everybody,
    I was to execute example of session facade pattern. All the files compile properly, but when ejbc command is run, i get the following error:
    ERROR: Error from ejbc:
         In EJB *MANAGER, method create() exposes local interface types or local home interface types through the remote home interface of the bean. This is not allowed.
    ERROR: Error from ejbc:
         In EJB *MANAGER, method remove(java.lang.Object) on the home interface does not throw java.rmi.RemoteException. This is a required exception.
         In EJB *MANAGER, method create() on the home interface does not throw java.rmi.RemoteException. This is a required exception.
    ERROR: Error from ejbc: In EJB MANAGER, the home interface be.telenet.sso.servicelayer.ebiz.ManagerHome must extend the javax.ejb.EJBHome interface.
    ERROR: ejbc found errors
    Thanks
    Amit

    If you are looking a local interface up through JNDI, try using the "java:comp/env" namespace. Also, if you post these questions here about EJB, say what vendor you are using because this stuff is pretty new and there will be differences/bugs/etc.

  • Calling stored procedure from session bean method

    I have a situation like this :
    I have one method on a stateless session bean (and I mark this method as container managed transaction). For database related stuff, I am not using entity beans, I am using my own layer of OR mapping. This method does a lot of stuff and it involves many trips to the database, as a result of which the performance is very poor. I have identified certain pieces of functionality from this method which I think can be moved to stored procedures, while some of the functionality can still remain in the session bean method. So my scenario is like this :
    session bean method start
    store some data in tables(using my OR layer)
    call the stored procedure
    session bean method end
    My question is :
    Will the data that I am storing in tables from within the session bean method, be available to the code executing inside stored proc.
    secondly, how do I sync the transcation which is being initiated by the container with the transaction under which the stored proc is executing or is it that the stored procedure code will also be executing under the container managed transcation.
    Thanks
    Vimal

    Hi Vimal,
    Will the data that I am storing in tables from within
    the session bean method, be available to the code
    executing inside stored proc.There's only one way to find out (isn't there?)
    secondly, how do I sync the transcation which is
    being initiated by the container with the transaction
    under which the stored proc is executing or is it
    that the stored procedure code will also be executing
    under the container managed transcation.Again, why not just "suck it and see!"
    [Or is there some reason why you can't?]
    As I interpret the EJB specification, if the transaction attribute for your session bean method is such that it starts a transaction, then that transaction will be terminated when the method completes -- and every operation that occurs within the framework of that method will be in the one transaction.
    In other words, your database stored procedure should execute within the same transaction as your O/R mapping layer.
    However, how OC4J behaves may not exactly follow what is written in the (EJB) specification. Hence I repeat, "try it and see for yourself".
    Put it this way: as far as I know, the only way that your stored procedure would NOT see the changes made by your O/R mapping layer is if they both executed in separate transactions and the O/R mapping layer did not commit its changes before the stored procedure began its execution.
    Hope this has helped.
    Good Luck,
    Avi.

Maybe you are looking for

  • HT204490 How do I get Photos - iPhotos to work with my iPhone

    I went to my computer to download some photos on my iPhone and noticed an update available 10.10.3 - I always download all that are offered.  10.10.3 loaded, and I proceeded to open iTines and iPhoto and plug in my iPhone, All went well until I notic

  • Problem in conditions pricing updation using BAPI_PO_CREATE1

    hi,     I am creating PO using BAPI_PO_CREATE1 however when i am passing the data to the bapi for conditions at item level the price value is not changing and throwing error as ( NET PRICE FOR ITEM 00010 adopted from last document ) so for all the it

  • Oracle 10g client with 11g ODBC.

    We have the Oracle 10g client on users PCs to use the 10g ODBC to connect to a 10g (10.2.0.4.0) database. Now we are upgrading to an Oracle 11g database, 11.2.0.3.0. Is it possible to install the 11g ODBC drivers onto the users PCs without installing

  • [AS] get overset content in a cell

    Hi Everyone, I have a script that tags stories with HTML tags based on the style sheets in use. It also creates HTML tables from InDesign tables. The problem I'm having is that when a table has a "special style", such as bold or italic, the tags may

  • Printing .GIF images with PHP

    Hello, As part of a PHP IF statement, I would like to print an image instead of text. How do I do this? Thanks in advance, John