on 01-15-2009 8:25 AM
Hello,
I want to create a portal service that calls our R/3 system and comes back with customer master data. For that I have to hand over the userid to the portal service.
The Interface looks like that:
import com.sapportals.portal.prt.service.IService;
import com.lgs.model.CustomerDataBean;
public interface IR3CustDataService extends IService
{
public static final String KEY = "R3CustDataService";
// returns an object with all customer master data from R/3
public CustomerDataBean getCustomerData(String userid);
}
The implementation of the method in the corresponding class is:
CustomerDataBean cdb = new CustomerDataBean();
public CustomerDataBean getCustomerData(String userid) {
return cdb;
}
Now I would implement the program logic (accessing R/3 and fill the CustomerDataBean) in the init method of the portal service class.
public void init(IServiceContext serviceContext) {
mm_serviceContext = serviceContext;
implementation of program logic, usage of userid necessary
}
My question is now how I can use the String userid in the init method? How can I hand over the userid to the init method so that I can use it?
Any hint is really appreciated!
Thanks a lot.
Arno
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arno,
You can create a method where you can get the userid and then call this method in the init().
Make the userid as Global Variable by declaring it in others.
Regards.
Rajat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You cannot pass any additional parameters in the init method. This is a method that gets automatically called by the portal itself and not by you. The init method is not thought for performing any complex logic, it's just there to set up the service itself and maybe also some of your own members.
You have to provide an own init method to which you can pass the userid (and maybe also other attributes that may be needed) that can afterwards be saved as class members. You can define an own boolean flag for assuring that your own init method gets called only once (if this is needed... but for your scenario this may not be needed, because I think you want to have the possibility to pass severeal different userids?).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arno,
declare the userId as class variable so that you can use it in any method of the class.
Regards
Narendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
10 | |
8 | |
8 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.