cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Action & Java class

Former Member
0 Likes
785

Experts,

I have a button called 'Go' in JSP.

1. When I click on the button, how can I capture the events?

2. After clicking on the event, I need to call the Java class to perform some backend activity. Pls guide me how?

3. After this, goto next page called result.jsp.

I've gone thro, "Development and Extension Guide u2013 SAP E-Commerce 7.0", but I dont understand how to intergrate the JSP & actions.

Please advise with steps & code..Appreciate your help..

BM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Likes

Hi Bharathi,

If you can open JSP file code in text editor then you can see what JavaScript function is called when you click Go.

Suppose you do not know JSP file name on which Go button is then call your application by below URL with parameter to display JSP File name.

http://<server>:<port>/b2b/b2b/init.do?showmodulename=true

Suppose your go button is on xyz.jsp file and your Go button call submitXYZform() JavaScript function. If submitXYZform() javascript function not define in the file xyz.jsp then try to find out in included Javascript file in xyz.jsp

If java script function just submit the form then check <form> element in xyz.jsp file.

Suppose you use below form.


<form action="<isa:webappsURL name="b2b/xyzformAction.do"/>"
		  id="form_positions"
		  name="form_positions"
		  method="post">

Go to config.xml file and try to find action as below


<action path="/b2b/xyzformAction" type="com.sap.isa.isacore.action.order.xyzformAction">
			<forward name="success" path="/b2b/result.do"/>
		</action>

If you want to add some custom code then you have to extend standard action class xyzformAction to Z_xyzformAction and update config.xml file


<!--<action path="/b2b/xyzformAction" type="com.sap.isa.isacore.action.order.xyzformAction">
			<forward name="success" path="/b2b/result.do"/>
		</action>-->
<action path="/b2b/xyzformAction" type="com.sap.isa.isacore.action.orderZ_.xyzformAction">
			<forward name="success" path="/b2b/result.do"/>
		</action>

As you have mentioned that you want to perform backend activity then you have to follow below step.

1. Create Backend Interface

2. Create Backend Object which Implement Backend Interface created in Step 1. Here you will use JCO API to call RFC, Set import parameter and get value and set value in Java varialbe from Export parameter

3. Add your backend Object class in "backend-config.xml file

4 Create Business Object to access Back end object

5 Create Business Object Manager to manage Business Object created in Step 4

6 Update "bom-config.xml" file for Business Object Manager created in Step 5

7 Use Busines Object in Action class or in JSP page to access data from Backend

After going through above step read Dev and Ext. Guide or Dev and Ext. Tutorial you will understand how to do it.

I hope this information will help you.

Regards.

eCommerce Developer

Former Member
0 Likes

Thanks a lot for the detailed explanation...

Let me give you some more details.

This is totally custom development. I have created 2 JSPs main.jsp & result.jsp. I don't have any ".do". .. Then How can I use "b2b/xyzformAction.do" in <form action="<isa:webappsURL name="b2b/xyzformAction.do"/>". Please advise.

BM

Former Member
0 Likes

Hi Bharathi,

I understand that you are going to develop 2 custom JSP file main.jsp and result.jsp. Now can you tell me How user will access main.jsp file?

Does User access it within ISA B2B or ISA B2C application? i.e. you are going to provide link on ISA B2B or ISA B2C and user will click on main.jsp , User will provide some value and click on Go button your Class will come in action fetch data from back end and display it on Result.jsp. Is it right? If yes then follow below steps.

1 Create <form> element with your required input field and submit button in Main.jsp file


           <form action="<isa:webappsURL name="b2b/xyzformAction.do"/>"> 

2 Add proper <action> in config.xml file


   <action path="/b2b/xyzformAction" type="com.sap.isa.isacore.action.order.xyzformAction">
			<forward name="success" path="/b2b/result.jsp"/>
                        <forward name="error" path="/b2b/main.jsp"/>
		</action>

3 Now create Action class "xyzfromAction.java". Here you will retrieve value of input field through "HttpServletRequest" object and call Business Object's method and set "Success" or "Error" base on your logic.

4 I have explained you how to write Business Object, Business Object Manager, Backend Interface and BackendObject.

I hope this will help you to resolve your issue. Also please refer Dev and Ext. Guide. This is th only document to understand How ISA application is working and how you can extend it.

Thanks and Regards.

eCommerce Developer

Former Member
0 Likes

Thanks for you patient in replying me...

<i>I understand that you are going to develop 2 custom JSP file main.jsp and result.jsp. Now can you tell me How user will access main.jsp file?

Does User access it within ISA B2B or ISA B2C application? i.e. you are going to provide link on ISA B2B or ISA B2C and user will click on main.jsp , User will provide some value and click on Go button your Class will come in action fetch data from back end and display it on Result.jsp. Is it right? If yes then follow below steps.</i>

<b>Yes, main.jsp will be called via B2C </b>

<i>1 Create <form> element with your required input field and submit button in Main.jsp file

<form action="<isa:webappsURL name="b2b/xyzformAction.do"/>"> </i>

<b>Just I want to make sure,in form "b2b/xyzformAction.do", Is it the Javaclass which we are creating?</b>

Bm

Former Member
0 Likes

Hi Bharathi,

ISA is using STRUTS frame work. It is based on Model View Controller (MVC) . When you submit any form in STRUTS it is submitted to Action Calss for processing.


<form action="<isa:webappsURL name="b2b/xyzformAction.do"/>"> 

When you hit Submit button on form it takes value /b2b/xyzformAction without .do from action parameter of the <form> element and try to find action path entry in config.xml file to find out which class will process this form.


<action path="/b2b/xyzformAction" type="com.sap.isa.isacore.action.order.xyzformAction">
	<forward name="success" path="/b2b/result.do"/>
</action>

when appropriate action path found it will call Action class defined in type parameter. Here it is com.sap.isa.isacore.action.order.xyzformAction This class process or further call Business Object class and return Success or Error forward mapping. Base on this value we will call or disply another class or JSP file in <forward> element.

If you read Interaction Components Topic in Dev. & Ext. Guide then you will get proper Idea how this is working.

I hope this will help you to understand how we call class from <form> element.

Regards.

eCommerce Developer

Former Member
0 Likes

Very useful information... Thanks... Now I'm clear... In my custom B2C application I don't see any <b>config.xml </b> file, do I need to create separately or it should have come automatically?

same way, backend-config also missing... Please advise..

YOu have been a great help .. Appreciated..

BM

Former Member
0 Likes

I have a question here, when I define a custom action like in the example above, does it have to be in the same package? because I created my own package structure, added a new class, extended the original action and overrode the parent method with a dummy which just calls super.method(params)

now I got this error:

Sep 21, 2009 3:05:11 PM,652 SAPEngine_Application_Thread[impl:3]_22 Error com.sap.isa.ipc.ui.jsp.action.IPCBaseAction invalid value caller:

Former Member
0 Likes

Stefan A. Ernst please dont cross post...if you have any question, open new thread...Thanks

Former Member
0 Likes

In my custom B2C application I don't see any <b>config.xml</b> file, do I need to create separately or it should have come automatically?

same way, backend-config also missing... Please advise..

BM

Former Member
0 Likes

It should come automatically. You can find under B2C project under WEB-INF folder.

eCommerce Developer