on 07-31-2009 2:03 PM
I ceated a new Composite Application with a Business Object "test" and an Application Service "search" in the Netweaver Development Studio
Business Object - test
In the Tab Structure I added the attributes id:LONG and name:STRING.
Under Operations I added findByName with the Input Parameter name:<anonymous>(String), the Output Parameter Output:test (test as a Complex Type) and the Fault "CAFFindException".
Application Service - search
I added the test BO as a Dependent Object and the Operation findByName with the Input Parameter name:String, thevOutput Parameter erg:test (Complex Type) and the Fault "CAFFindException".
As Business Logic I added the following code:
package com.sap.demo.carpool.modeled.appsrv.search;
import java.util.List;
import com.sap.caf.rt.bol.util.QueryFilterFactory;
@javax.ejb.Stateless(name="com.sap.demo.carpool.modeled.appsrv.search.search")
@javax.ejb.Local(com.sap.demo.carpool.modeled.appsrv.search.searchServiceLocal.class)
@javax.interceptor.Interceptors(com.sap.caf.rt.interceptors.LogInterceptor.class)
public class searchBeanImpl extends com.sap.demo.carpool.modeled.appsrv.search.searchBean{ //$JL-SER$ - static final long serialVersionUID is not declared
public searchBeanImpl() {
}
@com.sap.caf.dt.CAFOperation(name="findByName")
public com.sap.demo.carpool.modeled.Test findByName(java.lang.String name) throws com.sap.caf.rt.exception.CAFServiceException {
List<Test> out = this.gettestService().findByName(QueryFilterFactory.createFilter(name));
return out;
}
}
I alway got the error: "Test cannot be resolved to a type" or "Type mismatch: cannot convert from List to Test"
I would be very thankful if you could help me.
Hi Obermueller_T
If you want to return a List you need to configure the cardinality of output parameter of method findByName as 0..n.
Probably the method findByName return just Test Object. In this case, your method return just Test no List<Test>.
Reards
Marcos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marcos,
thank you so much!!!
After changing the cardinality the return type of the operation "findByName" switches to "java.util.List". Everything is working now!
The code now looks like this:
@com.sap.caf.dt.CAFOperation(name="findByName")
public java.util.List<com.sap.demo.carpool.modeled.Test> findByName(java.lang.String name) throws com.sap.caf.rt.exception.CAFServiceException {
java.util.List<com.sap.demo.carpool.modeled.Test> out = this.gettestService().findByName(QueryFilterFactory.createFilter(name));
return out;
}
Thank you so much! I'm so happy .... This problem frustrated me ....
Thank you ....
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.