on 08-14-2008 5:15 AM
Hi all,
I hhave a scenario where i am inserting and retrieving data from dict table using web service.
For this i have created a session bean and a wrapper class.
The session bean has two methods: insertRecords(), and viewRec().
so while creating a web service i need to include two methods.
I want to have only one method where i can pass a parameter as operation and if it is "I", then i can call the insert method and if it is "S" i can call view method.
I tried doing that bt i am stuck up with the return type.
Insert method has return type as array of wrapper class and
view method has wrapper class as return type ...
Is this scenario possible..??
or is there any other way to do this???
Plz let me knw..
Thankls n regards,
Ankita
Hi Ankita,
According to my understanding of your problem ,
you can keep the return type of your wrapper method which is internally calling the view method as Array of Wrapper class objects.
When you will call the view method according to the passed parameter and when it will return the wrapper class object then you can again create an Array of that wrapper class which will hold only 1 object and return it.
And in case of insert method return type will be Array of Wrapper class, so by doing this you can use the same method with same return type.
Hope this helps.
Regards,
Siddharth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Siddharth,
Im really sorry..
i cudnt get u ..
Actually these r methods:
public DemoDicModel[] viewRecords()
{
}
and
public DemoDicModel insertRecords(
String title,
String desc,
String status)
{
}
and im trying this:
public DemoDicModel[] getMethods(String operation,String title,String desc, String st)
{
DemoDicModel[] demoModel =null;
DemoDicModel model = new DemoDicModel();
if(operation == "show")
{
demoModel = viewRecords();
}
if(operation == "ins")
{
model = insertRecords(title,desc,st);
model.setMsg("RECORDS GENERATED");
demoModel=
}
return demoModel;
}
im stuck up with insert operation.
can u plz explain me in detail.
thanks,
ankita
Hi,
1. No need to change insertRecords method (it returns DemoDicModel type)
2. No need to change viewRecords method (it returns DemoDicModel array)
3. Change the getMethods method as follow
public DemoDicModel[] getMethods(String operation,String title,String desc, String st)
{
DemoDicModel[] demoModel =null;
if(operation == "show")
{
demoModel = viewRecords();
}
if(operation == "ins")
{
demoModel = new DemoDicModel[1];
model = insertRecords(title,desc,st);
model.setMsg("RECORDS GENERATED");
demoModel[0] = model;
}
return demoModel;
}
Hope this will solve your problem.
Thanks
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.