facebook

optional parameters

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #275458 Reply

    Renen
    Member

    Hello,

    I just rewrote some code to take advantage of JDK 1.5’s optional parameters. But, the JSP pages don’t seem to handle the optional parameters (the optional parameters appear as simple arrays. And the parameters can’t be omitted).

    Any input would be appreciated.

    Thanks in advance.

    renen.

    #275459 Reply

    Renen
    Member

    Maybe I should also add, other 1.5 constructs do work (autoboxing etc).

    #275487 Reply

    Riyad Kalla
    Member

    Moving to OT > Soft Dev

    Renen some example code would probably make any help others had easier to give (off hand I don’t know, I’ve never tried using the optional args)

    #275501 Reply

    Renen
    Member

    Thanks for your time. I would like to figure it out, so here goes:

    I have a stateless EJB called DB2 (nothing to do with IBM). Within this class I can execute:

    
    execute("exec", 234, "xx", "yy", 43, "blah");
    

    However, when I try to call it from a different EJB, things don’t work:

    
    db().execute("string", 4, "param", "param", 1652, "message" );
    

    (However, other calls do work).

    I think the problem may be that I have too many definitions of the same execute function, all with notionally different signatures – and some of which take variable numbers of parameters at the end (which, I think, sows the confusion). In fact, I’m sure of it because when you push F3, it takes one to the wrong function!

    It gives the rather weird impression that it works in one context but not the other.

    I will apply my mind a bit more and post a follow up if / when I reach a conclusion.

    Renen.

    #275506 Reply

    Renen
    Member

    Some headway.

    The first point is that java matches the shortest signature it can for a method. So, I was definitely muddling things up. I have tidied the methods and made sure that there can be no ambiguity around which method is being called. I am, though, not out of the woods yet.

    From other classes, or JSP pages, the method signature is reflected as, for example:

    
    execute(int processID, Object[] parameters)
    

    instead of:

    
    execute(int, Object...)
    

    My suspicion is that the other modules are not looking at the code from a java 1.5 perspective. Specifically, there is a setting under Project | Properties | MyEclipse which reads J2EE Specification: 1.3. What is this and how do I change it?

    Again, I appreciate your input.

    Thanks.

    Renen.

    #275557 Reply

    Riyad Kalla
    Member

    Renen,
    The project specification level can only be changed during the project-creation step (you can choose between Java EE 5, J2EE 1.4 and 1.3)

    #275564 Reply

    Renen
    Member

    Thanks. I have made some headway: when I run xdoclet, the interface class is incorrectly generated:

    
    /**
    * @ejb.interface-method view-type="remote" 
    * @ejb.transaction type="Never"
    **/
    public RowSet execute(String sql, Object...parameters) throws SQLException {
    

    becomes:

    
    public javax.sql.RowSet execute( java.lang.String sql,java.lang.Object[] parameters )
       throws java.sql.SQLException, java.rmi.RemoteException;
    

    which is, to my mind, wrong.

    Again, thanks for your time and input. Any ideas on how to remedy this would be hugely appreciated!

    #275581 Reply

    Renen
    Member

    Just upgraded to MyEclipse 6.0. And reran xdoclet. The interfaces are still generating incorrectly.

    Anyone got any ideas?

    #275673 Reply

    Riyad Kalla
    Member

    This message has not been recovered.

    #275739 Reply

    Renen
    Member

    This message has not been recovered.

    #275749 Reply

    Riyad Kalla
    Member

    This message has not been recovered.

Viewing 11 posts - 1 through 11 (of 11 total)
Reply To: optional parameters

You must be logged in to post in the forum log in