cancel
Showing results for 
Search instead for 
Did you mean: 

communication between jsp and abstractportalcomponent

former_member445109
Active Participant
0 Kudos

Hello All

Communication between jsp and abstractPortalComponent.

jsp contains one input text field and one submit button.

when the user clicks on submit button it will call the component and that input value will

display in same jsp page.

how this communication will happen?

Rgrds

Sri

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Srikanth,

I am unable to include the snippet of javascript as the thread is not allowing me to submit the same(even with code dsiplay).

Shoot a mail to <<address removed by moderator - please maintain your business card>> I will send you the jsp file.

P.S : I tried using the code snippet gallery in wiki as well, but sadly it doesn't allow javascripts.

Thanks,

Jakes.

Former Member
0 Kudos

Hi Srikanth,

With your requirement I believe you can achieve this pretty much without any interaction b/w abstract portal component and jsp page. You only have to read one value and display it on the same page right.

Kindly find the below snippet of code in which I have read the value of First name and displayed it on the second input field. You can easily tailor it to suit your need(replacing i/p field with label or sth else).

Thanks,

Jakes.

Former Member
0 Kudos

>

> Hello All

>

>

> Communication between jsp and abstractPortalComponent.

> jsp contains one input text field and one submit button.

> when the user clicks on submit button it will call the component and that input value will

> display in same jsp page.

>

> how this communication will happen?

>

>

> Rgrds

> Sri

Hi Sri,

You can read out the submitted value in your component by request.getParameter("NameOfYourInputField").

Before you load the JSP again from your component you can set this value as an attribute to the HttpServletRequest:


String myValue = request.getParameter("myInputField"); //Suppose request is an object of IPortalComponentRequest
request.getServletRequest().setAttribute("myValue", myValue);
...
//include jsp in request...

In your JSP file you can then read out this attribute by the following code:


String myValueInJsp = (String)request.getAttribute("myValue"); //request is an implicit object in every JSP file and is a type of HttpServletRequest

former_member445109
Active Participant
0 Kudos

Hi Clemens

Thank you very much for your response.

for "request.getServletRequest().setAttribute("myValue", myValue);"

getServletRequest() is not available in "request" object which is type of IPortalComponentRequest.

How to get the setAttribute() and also provide the portalapp.xml what to enter in the section <component-config> and <component-profile>

Rgrds

Sri

Former Member
0 Kudos

Hi Srikanth,

In the JAVA File,

OnSubmit Event,

String inputvalue ;
InputField myInputField = (InputField) getComponentByName("Input_Field_ID");
if (myInputField != null) {
			inputvalue = myInputField.getValueAsDataType().toString();
		       }
request.putValue("textvalue", inputvalue);

request is IPORTALCOMPONENTREQUEST Object.

In JSP File, to retreive the value,

<%
String  textstring = (String) ComponentRequest.getValue("textvalue");
%>

In PORTALAPP.XML File,

<component name="component name">
      <component-config>
        <property name="ClassName" value="classname"/>
        <property name="SafetyLevel" value="no_safety"/>
      </component-config>
      <component-profile>
        <property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
      </component-profile>
    </component>

Using the code above, You can pass and read values between abstract portal component and Jsp Page.

Instead of this, I suggest you to use JSPDYNPAGE Component for Data Exchange.

Check the [Link|http://help.sap.com/saphelp_nw2004s/helpdata/de/ce/e0a341354ca309e10000000a155106/frameset.htm].

Hope this helps you.

Regards,

Eben Joyson

Former Member
0 Kudos

>

> Hi Clemens

>

> Thank you very much for your response.

>

> for "request.getServletRequest().setAttribute("myValue", myValue);"

>

> getServletRequest() is not available in "request" object which is type of IPortalComponentRequest.

>

> How to get the setAttribute() and also provide the portalapp.xml what to enter in the section <component-config> and <component-profile>

>

>

> Rgrds

> Sri

Hi Sri,

this method should be available, please take a look at the Javadocs:

[http://help.sap.com/javadocs/NW04/current/ep/com/sapportals/portal/prt/component/IPortalComponentRequest.html#getServletRequest()|http://help.sap.com/javadocs/NW04/current/ep/com/sapportals/portal/prt/component/IPortalComponentRequest.html#getServletRequest()]

Hope it helps,

Clemens