Javascript onClick EJB method call problem

Hi,
I am using JDeveloper to develop a supermarket comparison tool. I have
a JSP page called index.jsp which consists of a shopping list (shopping
cart type thing) and an iframe which displays my search.jsp page. The
search.jsp page is a list of all the items that can be added to the
shopping list. When a user clicks the add button for the corresponding
item, the cartBean addItem method is called and the itemID is passed
through. I have 3 items currently in my product list with individual
ID's, but when I click the add button on a particular item all 3 of the
items are added to my shopping list. Can anyone tell me why? and if so how can I resolve this problem?
Search.jsp:
<%
    //Get the list of items
    ArrayList itemList = null;
    try {
      itemList = items.getItems("Select * from items");          
    catch (Exception ex) {
      System.out.println(ex.getMessage());
    %>
    <table class='resultsTable' cellpadding='10' cellspacing='10'><%
      for (Iterator iter = itemList.iterator(); iter.hasNext();){        
        ItemsEJBBean product = (ItemsEJBBean) iter.next();%>
            <tr>     
          <td><%="<img src='images/items/"+product.getItemImg()+".jpg' width='77' height='45'>"%></td>
          <td><h3><%= product.getItemName()%></h3><%= product.getItemDesc()%></td>
          <td><a href="#"><img src="images/add.gif" width="47" height="19" border="0" name="addButton<%=product.getItemId()%>" id="<%=product.getItemId()%>" onMouseOver="MM_swapImage('addButton<%=product.getItemId()%>','','images/add_hover.gif',1)" onMouseOut="MM_swapImgRestore()" onclick="<%/*addNewItem(product.getItemId());*/ list.addItem(new Integer (product.getItemId()));%>window.parent.location.reload(false);"></a></td> 
            </tr><%
      %>
      </table>
      <%CartBean code snippet:
public void addItem(Integer itemID)
    if(getItemCount() < max)
      contents.add(itemID);
  public void removeItem(Integer itemID) throws ItemException
   boolean result = contents.remove(itemID);
    if(result == false)
      throw new ItemException(itemID + " not in list.");
    else
      contents.remove(itemID);
  public Vector getContents()
    return contents;
  public int getItemCount()
    if (contents == null)
      return 0;
    else
      return contents.size();
   public int getItemCountRemain()
    if (contents == null)
      return max;
    else
      return max - contents.size();
}Any help would be most helpful. Thank you for your time :)

but when I click the add button on a particular item all 3 of the
items are added to my shopping list. Can anyone tell me why? and if so how > > can I resolve this problem?I don't think that clicking the button is what is causing your problem. The following line of code is the problem:
<td><a href="#"><img src="images/add.gif" width="47" height="19"
border="0" name="addButton<%=product.getItemId()%>" id="<%=product.getItemId()%>"
onMouseOver="MM_swapImage('addButton<%=product.getItemId()%>','','images/add_hover.gif',1)"
onMouseOut="MM_swapImgRestore()"
onclick="<%/*addNewItem(product.getItemId());*/ list.addItem(new Integer (product.getItemId()));%>
window.parent.location.reload(false);"></a></td> When you are trying to create the onClick, you are invoking list.addItem. You are doing this for each item. By the way, I don't think the resulting onClick will actually do anything. It will evaluate to the item id and nothing will happen. You need to trigger a request to the server here (e.g. by submitting a form and including the correct item id).

Similar Messages

  • Native - Java Method Call problem - "Wrong Method ID..."

    I am writing a 3d game engine using c++, with all the game logic code in Java, for the purpose of making the thing extendible, easily modifyable, etc...
    I am using J2SE JDK 1.2.2.
    Most things work fine (engine-wise), but i have a few questions about problems i am having getting the JNI to work correctly with calls to Java Methods.
    1. If I use FindClass() to get a jclass reference to a named class, I get one number back. If I then instantiate this class, and then call GetObjectClass() with the instance, I get another number, **which doesnt appear to work for anything**. What is going on here? Can the JVM give different jclass numbers for the same class? Is GetObjectClass() supposed to work?
    2. Is AllocObject() alright for instantiating Java objects? It does seem to allocate memory, and method calls work to the new object. I am aware that it doesn't call a constructor, but I like that, seeing as the initialization is handled through a different [network-synchronized] means.
    3. Using a jclass retrieved using FindClass(), which I store in a global variable, I am able to call methods on an instance that I created in a certain function. I then make sure (?) that the GC can't reclaim the class or object memory by getting a NewGlobalReference to both of them [just to be safe]. However, in a later function, I am unable to call methods using my stored method IDs, ["Wrong Method ID....JVM has been asked to shut down this application in an unusual manner..."]. I am also unable to acquire new methodIDs, as the system returns 0xCCCCCCCC for all method ID queries. Obviously, attempting to use those bogus method IDs results in a JVM crash, in a segment called [2 deep in the untraceable depths of JVM.dll] from the JNI CallVoidMethodV() function. Why is this happening? Is the GC getting in there despite my best efforts? Is it illegal to cache methodIDs, jclass references or jobject references? aaarrggh! :)
    Thanks
    Chris Forbes
    Lead Programmer
    Sprocket Interactive
    [email protected]

    Hi Chris,
    I hit the same sort of problem, when writing a JVMDI ( VM debugger hook ), in C++.
    My question remained unanswered too
    http://forum.java.sun.com/thread.jsp?forum=47&thread=461503&tstart=30&trange=30
    I didn't try a call to NewGlobalRef, as you did... but it sounds like it could be what I was missing.
    I've a couple of ideas, but nothing definite for you.
    1) maybe there's more than one classloader, so that multiple copies of the class are loaded
    2) ensure you're compiling your DLL with "quad-word" ( 8 byte ) alignment.
    Otherwise all your JNI references will be misaligned !
    Since the JNI reference maps to a C++ pointer, it's possible that you can't cache any JNI references.
    That's my vague feeling on the subject.
    As a workaround, you may have to keep requesting any JNI references, eg. jclass & jmethod's, as you need them.
    regards,
    Owen

  • Easy method call problem

    Hi,
    Does anyone know how to call a certain method in a parent
    script from a behaviour script? Have a method called startit but
    when it I compile it says its the handler is not found.
    Cheers,
    Brenden

    Hi,
    > beginConn = new(member("beginscript").script)
    A more common way of doing this is with this syntax:
    beginConn = script("beginscript").new()
    > As the target instance is not being found now even if I
    have converted
    > to a parent script. Seems very strange!
    An object is an object regardless of the script type that
    made it (the reason why behaviours and parent scripts are generally
    better suited for making objects is that they have a 'protect
    scope' - if you call a handler without specifying the 'object' with
    that handler, then Director looks in all movie scripts for that
    handler; it wont attempt to call the handler or method defined in a
    parent script or behaviour unless you specify that script or an
    instance of that script ).
    > beginConn.startit()
    > on startit me
    > checker = timeout("looker").new(10000, #looker, me)
    > end
    Assuming 'beginConn' contains a reference to an instance of
    the script containing the 'startit' method, then your code looks
    fine (unless you are using DirectorMX2004, in which case it should
    be checker = timeout().new("looker", 10000, #looker, me)).
    Put a debug line in just before you create the timeout, and
    see what 'me' points to. eg.
    on startit me
    put "#startIt message received by " & me
    checker = timeout("looker").new(10000, #looker, me)
    end
    on looker (me, timeoutObject)
    put "#looker message sent by " & timeoutObject & "
    was received by " & me
    end
    -- Luke

  • EJB method Calling automatically

    Hi
    I am using jboss. My requirement is the bean should be called after the EAR deployed automatically without
    client.
    After it calls i can call the EJB Timer for the next process.
    Can u advice me
    thanks

    I achived the same as follows.
    Create startupServlet with override init() method.
    public class StartupServlet extends HttpServlet {
         @Override
         public void init() throws ServletException {
               // Call the EJB or whatever ... this will be called on startup of jboss without any client.
    }And define to load on startup in web.xml
         <servlet>
              <servlet-name>config</servlet-name>
              <servlet-class>
                   com.servlet.StartupServlet
              </servlet-class>
              <load-on-startup>1</load-on-startup>
         </servlet>

  • Method calling problem

    I dont know why this line of code is not executing
    dbpassword = dao.getMemberPass(username);
    the getMemberPass() method is not being entered. why not??
    Heres some info:
    dbpassword is defined as a String
    dao is an instance of BookDAO, the interface for My Data Access Object.
    getMemberPass() is defined in my BookDAO interface and implemented in the MySQLBookDAO class. MySQLBookDAO implements the BookDAO interface.
    username is a String value.
    any help??

    Could you include the enclosing method's code?
    - Saish
    "My karma ran over your dogma." - Anon

  • EJB Method Response Time

    Hello All,
    Is there any way to get the response time (min, max and avg) for each EJB method
    call? There was a way to do this BEA Tuxedo, does WLS 7.x provide any way for
    such profiling?
    Thanks in advance.
    rgds
    MS

    Hello All,
    Is there any way to get the response time (min, max and avg) for each EJB method
    call? There was a way to do this BEA Tuxedo, does WLS 7.x provide any way for
    such profiling?
    Thanks in advance.
    rgds
    MS

  • Java.rmi.RemoteException: EJB Exception: while calling an EJB method,

    Hi
    I am getting below error while calling a stateless EJB method. There is some validation checks while performing ejb's modify() method and a RuntimeException is thrown in case of validation failure.The modify() method internally calls other stateless ejb as well.
    The problem I'm facing is, instead of getting the expected RuntimeException in the Servlet, i am getting RemoteException. I am using WLS 9 MP1, all participating ejbs are stateless and i am using default transaction attributes(Supports) for these ejbs.
    The interesting part is, at the ejb layer RuntimeException is thrown as expected, but this exception changed to RemoteException at the servlet's end where i am catching the ejb call exceptions.
    I am new to WLS, please suggest/help me out of this exception.
    Any help is truly appreciated.
    java.rmi.RemoteException: EJB Exception: ; nested exception is: java.lang.RuntimeException:
         at weblogic.ejb.container.internal.EJBRuntimeUtils.throwRemoteException(EJBRuntimeUtils.java:95)
         at weblogic.ejb.container.internal.BaseEJBObject.handleSystemException(BaseEJBObject.java:713)
         at weblogic.ejb.container.internal.BaseEJBObject.handleSystemException(BaseEJBObject.java:681)
         at weblogic.ejb.container.internal.BaseEJBObject.postInvoke1(BaseEJBObject.java:447)
         at weblogic.ejb.container.internal.StatelessEJBObject.postInvoke1(StatelessEJBObject.java:72)
         at weblogic.ejb.container.internal.BaseEJBObject.postInvokeTxRetry(BaseEJBObject.java:374)
         at com.mycomp.base.BaseController_8x2e52_EOImpl.modify(BaseController_8x2e52_EOImpl.java:149)
         at com.mycomp.webgui.servlet.FrontComponent.service(FrontComponent.java:207)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:223)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3245)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2003)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1909)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1359)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    Thanks!
    Edited by: user10721298 on Feb 23, 2009 4:16 AM

    Hi,
    If i don't misunderstand, you are using the RuntimeException as an application exception, right?
    Have you annotated it or denoted it in deployment descriptor?
    Thanks,
    Amy

  • Problem in getting Updated EJB methods in JSC for a Same Project

    I'm Using Sun Studio Enterprise for developing EJB sets.After that i'm importing the EJB set in to JSC & using it my Project.
    If i need to add some more business methods/edit the business method i'm able to do that in the Sun Enterprise IDE.After editing the EJB ,redeploying & reimporting to JSC i couldn't get the updated version of EJB in my Current Project.
    We could be able to get the updated EJBs,if we are using it in a new project other than using it in the Previous one.
    It's being a great problem for me.Vat shall i do for this problem?Please help me,a project is in Pending stage because of this problem.
    Regards
    Kajanan

    Hi MWH@Keystroke,
    Thanks for your consideration of my problem.I also use an EJB layer built in Sun Enterprise for the backend to my Creator-based web application.My Current problem is getting the updated EJB sets to my current project.
    For Ex:
    If i add a new Business method called doSomething( ),then i should be able to get that method in JSC using FinalFacadeRemoteClient1.doSomething().
    But after typing FinalFacadeRemoteClient. , doSomething() method is not displaying.
    If i use that in a new project [Previously not used Same Session Facades]all the updated EJB business methodss are coming.I want to use updated EJBs in the project i'm already working.
    Regards
    Kajanan

  • Urgent - calling EJB methods from thread

    Dear all
    I am aware of EJB spec that does not permit developer managed threads within EJB components. However, I need to call EJB methods from my own thread. Hence, it there any way to to call EJB methods from developer managed thread ?? If yes, please advice me, thanks in advance and your help will be appriciated.
    Hava a nice day

    You can call EJB's from your threads. Your thread will act as the client and the call will to EJB will be same as any other client invoking EJB's. Hope I understand your question !.

  • Can an EJB method return processing results to its calling program?

    Hi there,
    I have an EJB method which does JDBC connection to a UDB. I want the ResultSet to be returned to JSP so I can format them in the page itself. I got an ClassCastException at the return statement. Could anybody point out what I might be missing?
    Thanks a lot.
    Andy

    Here is the code related:
              try
                   Context jndi = AuditPublicService.getContext();
                   Object obj = jndi.lookup(AuditInterface.ALIAS);
                   AuditHome auditHome =
                        (AuditHome) PortableRemoteObject.narrow(obj, AuditHome.class);
                   Audit audit = auditHome.create();
                        this.rs = (ResultSet) audit.read();
              catch (Throwable t)
                   System.out.println("Test.read():failed." + t.toString());
                   t.printStackTrace();
    and this is what I got:
    Test.read():failed.java.lang.ClassCastException
    java.lang.ClassCastException
    P.S. When I track down to the return statement(return rs) in the audit.read(), I can see that the rs is exactly what I want, but failed when the EJB stub tries to cast it to Serializable. I tried to implements java.io.Serializable in both the calling class and the EJB. it didn't work.

  • Finding extra info on caller of ejb method

    Is there any way to find out more information about the caller of an EJB
    method. I know you can get the principal from the context, as well as the
    protocol, etc. But what I am looking for is something like the equivalent
    of getRemoteAddr() from the web side. I'd like to find out the IP address,
    machine name, etc., from the caller. Does anyone know if this information
    is readily available somewhere in one of the existing classes, or would
    something have to be home grown to do this?
    Thanks in advance,
    Chris

    Is there any way to find out more information about the caller of an EJB
    method. I know you can get the principal from the context, as well as the
    protocol, etc. But what I am looking for is something like the equivalent
    of getRemoteAddr() from the web side. I'd like to find out the IP address,
    machine name, etc., from the caller. Does anyone know if this information
    is readily available somewhere in one of the existing classes, or would
    something have to be home grown to do this?
    Thanks in advance,
    Chris

  • Timeout a method call made from an EJB

    Hi,
    Is there a way to implement a timeout in a SOAP method call which I'm invoking from an EJB. I'm trying to use a web service RPC method in my client and I need to know if there is some way by which I can timeout the method invocation.
    For eg, what happens if the web service is down? I want to be able to tell the user that the call did not go through because the web service was down. I'm assuming that I'll have to specify some sort of a timeout period for which the call will wait for a response. If no response is received during this time, I want to say that a timeout occured.
    So, if I do something like
    webServiceA.invokeSoapMethod(parmaeters);
    from an EJB I want that this method should wait for, say 10 seconds, for a response and then say that the call timed out. Is there any way to do such a thing?
    Alternatively, if somebody can give me some pointers to whether SOAP or RPC (or some other component!) specify some way to timeout the RPC call, I'll appreciate that too..:-).
    Thanks in advance..:-)
    Ruchi

    Unfortunetly, I am on the same ship.... has anyone a solution for the same?

  • Passing DataObject to EJB Method Problem

    Dear All,
    I got a problem when I pass a data to a EJB Method.
    Here is the situration:
    BaseClass.java <-- It's an abstract class
    private LinkedList baseList; <-- It is a private attribute which is
    LinkedList.
    public LinkedList getBaseList(){ ... };
    public void setBaseList(LinkedList newList){ ... }; <-- A pair of getter /
    setter methods of the private attribute.
    MyClass.java <-- It's extends BaseClass and implements Serializable
    MySessionBean.java <-- It's implements SessionBean
    public void process( BaseClass dataObject) thorws Exception <-- A business
    method which support both Local and Remote Access.
    MyTestClass.java
    public void process( BaseClass dataObject) <-- Just a simple method which
    has an argument.
    Problem:
    When I create a MyClass object and set the baseList( which has 1 element) by
    the setter method then pass it to the process method of the session bean by
    remote interface, the baseList becomes empty.
    However, I just pass it to a simple MyTestClass java, the baseList has no
    problem.
    Could anybody tell me what's the problem of it? and Could give me some hints
    to solve it?
    Many thanks,
    Dennis

    Is one of your bean methods createDoc(String,String,FileOutputStream). If so, you must know that bean methods, arguments and return values that must travel over an RMI protocol, must be one of these: (RMI-IIOP compatible) Primitives, serialized objects, a remote object, or an array or collection (of serialized objects, primitives, or remote objects). FileOutputStream is not a serializable object. Neither is FileInputStream. Why are you trying to pass an InputStream or OutputStream to an EJB? Because you are not allowed to access the file system from an EJB. Anyways, that's my best guess. I hope it helps.

  • JDBC, JMS and EJB transactions - possible problem?

    Hello,
              I am using Oracle 9, Weblogic 8.1 SP 4, MyEclipse and
              XDoclet.
              In my current project I have the following piece of code
              in one of my message driven beans (code cited as pseudocode
              without unnecessary details):
              * @ejb.bean name="MyMessageProcessor"
              * display-name="Display name for a MyMessageProcessor"
              * jndi-name="ejb/MyMessageProcessor"
              * description="Bean MyMessageProcessor"
              * destination-type="javax.jms.Queue"
              * transaction-type="Container"
              * acknowledge-mode="Auto-acknowledge"
              * subscription-durability="Durable"
              * generate="false"
              * @ejb.transaction type="Required"
              public class MyMessageProcessor implements MessageDrivenBean, MessageListener {
              public void onMessage(Message msg) {
                   try {
                        //obtaining connections to two different databases via JNDi
                        java.sql.Connection connOne =
                        ((DataSource)ctx.lookup("DataSourceOne")).getConnection();          
                        java.sql.Connection connTwo =
                             ((DataSource)ctx.lookup("DataSourceTwo")).getConnection();
                        // performing some UPDATEs and INSERTs on connOne and connTwo
                        // calling some other methods of this bean
                        //creating the reply JMS message and sending it to another JMS queue
                        Message msgTwo = this.createReplyMessage(msg)
                        this.queueSender.send(msgTwo);
                        //commiting everything
                        this.queueSession.commit();          
                   } catch (Exception ex) {
                   try {
                        if (this.queueSession!=null) this.queueSession.rollback();
                   } catch (JMSException JMSEx) {};     
                   this.context.setRollbackOnly();
              Some days ago (before the final remarks from my client) there used to be only one DataSource configurated on the basis of the
              connection pool with non-XA jdbc driver. Everything worked fine
              including the transactions (if anything wrong happend not only wasn't the replymessage sent, but also no changes were written
              to database and the incomming message was thrown back to the my bean's
              queue).
              When I deployed the second DataSource I was informed by an error message, that only one non-transactional resource may
              participate in a global transaction. When I changed both datasources
              to depend on underlying datasources with transatcional (XA) jdbc drivers, everything stopped working. Even if
              EJB transaction was theoretically successfully rolledbacked, the changed were written to the database
              and the JMS message wasn't resent to the JMS queue.
              So here are my questions:
                   1. How to configure connection pools to work in such situations? What JDBC drivers should I choose?
                   Are there any global server configurations, which may influence this situation?
                   2. Which jdbc drivers should I choose so that the container was able to rollback the database transactions
                   (of course, if necessary)?
                   3. Are there any JMS Queue settings, which would disable the container to send message back to the
                   queue in case of setRollbackOnly()? How should be the Queue configurated?
              As I am new to the topic and the deadline for the project seems to be too close I would be grateful
              for any help.
              This message was sent to EJB list and JDBC list.
              Sincerely yours,
              Marcin Zakidalski

    Hi,
              I found these information extremely useful and helpful.
              The seperate transaction for sending messages was, of course, unintentional. Thanks a lot.
              Anyway, I still have some problems. I have made some changes to the
              code cited in my previous mail. These changes included changing QueueSessions
              to non-transactional. I also set the "Honorate global transactions" to true.
              I am using XA JDBC driver. After setting "Enable local transactions" to false
              (I did it, because I assume that JDBC transactions should be part on the global
              EJB transaction) I got the following error:
              java.sql.SQLException: SQL operations are not allowed with no global transaction by default for XA drivers. If the XA
              driver supports performing SQL operations with no global transaction, explicitly allow it by setting
              "SupportsLocalTransaction" JDBC connection pool property to true. In this case, also remember to complete the local
              transaction before using the connection again for global transaction, else a XAER_OUTSIDE XAException may result. To
              complete a local transaction, you can either set auto commit to true or call Connection.commit() or Connection.rollback().
              I have also inspected the calls of methods of bean inside of onMessage() method just to check, whether
              the transactions are correctly initialized (using the weblogic.transaction.Transaction class).
              My questions are as follows:
              1. Any suggestions how to solve it? I have gone through the google answers on that problem and only
              thing I managed to realize that JDBC must start its own transaction. Is there any way to prohibit it
              from doing that? Can using setAutocommit(true/false) change the situation for better?
              2. How to encourage the JDBC driver to be a part of EJB transaction?
              3. As I have noticed each of ejb method has its own transactions (transactions have different
              Xid). Each method of the bean has "required" transaction attribute. Shouldn't it work in such
              way that if already started transaction exists it is used by the called method?
              4. The DataSources are obtained in my application via JNDI and in the destination environment I will have slight
              impact on the configuration of WebLogic. What is least problematic and most common WebLogic configuration which would
              enable JDBC driver to participate in the EJB transaction? Is it the WebLogic configuration problem or can it be
              solved programmically?
              Currently my module works quite fine when "enable local transactions" for DataSources is set to true, but this way
              I am loosing the ability to perform all actions in one transaction.
              Any suggestions / hints are more than welcomed. This message was posted to jdbc list and ejb list.
              Marcin

  • Can't fill ByteArray in EJB-Method with generated Model-Class from WD-Model

    Hello everybody,
    i try to call an ejb-method with data from an FileUpload-UI-Element in WD. The EJB-Method is receiving the byte-data to create a document in KM via a Web-Service.
    The ebj-methid has the following signature:
    public FObject putFileDataSimple (byte [] btContent, String fullFileName, String username, String password)
    After importing the Model and creating a context node i have the following structure:
    Request_X_putFileDataSimple
    +---btContent (Node)
          +-- item
    + fullFileName
    + username
    + password
    btContent is of the generated Type Byte_Item, which is itself a generated Model-Class of modelClassType ARRAY
    item is of Type byte
    But i simply have problems to fill the context node (or the binded model-object). i tried different ways and looked at thread [https://www.sdn.sap.com/irj/scn/thread?messageID=1954223] but i cant get it work.
    So my Method in WD looks like this to fill the structure and start the ejb-method:
    public boolean putKMDataSimple( com.sap.tc.webdynpro.services.sal.datatransport.api.IWDResource fin )  {
    try
      wdContext.currentRequest_X_putFileDataSimpleElement().setFullFileName("abc");
      wdContext.currentRequest_X_putFileDataSimpleElement().setUsername("def");
      wdContext.currentRequest_X_putFileDataSimpleElement().setPassword("xxx");
      byte[] buffer = new byte[1];
      InputStream in = fin.read(false);
      int i = 1;
      int j = 0;
      while (i!=-1)
         i = in.read(buffer);
         if (i!=-1)
           Byte_Item bi = new Byte_Item(mAlf);     // mAlf ist global defined Model-Class-Instance
           bi.setItem(buffer[0]);
            wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().addBtContent(bi);
      wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().execute();
    Doing this results in Error-Messages like:
    Model-Object is not a complex type for every byte added this way.
    And finally an IllegalArgumentException at java.lang.reflect.Array.set(Native Method)
    The second way i tried is:
    public boolean putKMDataSimple( com.sap.tc.webdynpro.services.sal.datatransport.api.IWDResource fin )  {
    try
      wdContext.currentRequest_X_putFileDataSimpleElement().setFullFileName("abc");
      wdContext.currentRequest_X_putFileDataSimpleElement().setUsername("def");
      wdContext.currentRequest_X_putFileDataSimpleElement().setPassword("xxx");
      byte[] buffer = new byte[1];
      ArrayList<Byte> btlist = new ArrayList<Byte>();
      InputStream in = fin.read(false);
      int i = 1;
      int j = 0;
      while (i!=-1)
         i = in.read(buffer);
         if (i!=-1)
              btList.add(buffer[0]);
      wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().setBtContent(btList);
      wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().execute();
    Trying so results in:
    java.lang.ClassCastException: class java.lang.Byte:null incompatible with interface com.sap.tc.cmi.model.ICMIModelClass:library:com.sap.tc.cmi(at-sign)[email protected]@alive
    whenn calling the setBtContent Method
    I don't what to do now to fill the context/model-object the right way.
    Any helpfull hints are very welcome
    Edited by: Matthias Hayk on Dec 1, 2008 5:51 PM
    Edited by: Matthias Hayk on Dec 2, 2008 10:56 AM

    Ok Vesselin and thanx for your idea,
    so i adapted the source in the way you told like the following:
                     ArrayList<Byte_Item> btlist = new ArrayList<Byte_Item>();
                     byte[] buffer = new byte[1];
                     InputStream in = fin.read(false);
                     int i = 1;
                     int j = 0;
                     while (i!=-1)
                          i = in.read(buffer);
                          if (i!=-1)
                               // Byte gelesen
                               Byte_Item bi = new Byte_Item(mAlf);
                               bi.setItem(buffer[0]);
                               btlist.add(bi);
                               j++;
                     wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().setBtContent(btlist);     
                     wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().execute();
    This results also in the following Exception when exceuting the WS-proxy:
    execute
    [EXCEPTION]
    java.lang.IllegalArgumentException
    at java.lang.reflect.Array.set(Native Method)
    at com.sap.tc.webdynpro.model.ejb.model.EJBGenericModelClassExecutable.getInputParameters(EJBGenericModelClassExecutable.java:215)
    at com.sap.tc.webdynpro.model.ejb.model.EJBGenericModelClassExecutable.execute(EJBGenericModelClassExecutable.java:112)

Maybe you are looking for