cancel
Showing results for 
Search instead for 
Did you mean: 

Pass value from iView to anoher

Former Member
0 Kudos

Hi all,

I create two iView: the first is used for insert a value in the input field, the second iView show the value insert in the first iView. I used the EPCF with the EVENT API but my work don't work! How can pass the value in the JavaScript function to the variable in PortalComponent?

Anyone can help me?

Thanks in advance

Stefano

Accepted Solutions (1)

Accepted Solutions (1)

darrell_merryweather
Active Contributor
0 Kudos

Stefano

One method you could use would be to do the following

1) The first iView raises the event

2) The second iview receives the event and then gets the value of the event object

3) Once you have the value from the event object then you can simply change the 'location.search' to include a parameter value pair, i.e. location.search='?myparam=paramvalue'

4) This will trigger the receiving iview to refresh, at which point it can then retrieve the parameter from the request and populate the input field

The other method would be to use a Drag and Drop scenario, where you could drag the value from one iView to another. This is documented in the PDK documentation

I hope this helps

Thanks

D

Former Member
0 Kudos

Hi Darrel,

thank you for your reply!!!!

I have another question, if I have more parameter how can pass them?

Thanks a lot

Stefano

darrell_merryweather
Active Contributor
0 Kudos

The location.search is basically the HTML query string, and therefore has the same format. any parameters to be passed to a URL use ?param1=value1&param2=value&param3=value3....

With the drag and drop scenario you would need to simply append the values to the value of the drag and then parse this value when the receiving iview retrieves the values.

I hope this helps

D

Former Member
0 Kudos

Hi Darrell,

my work don't run! Help me! When I click the button the page not refreshed, and the Top Level Navigation go to the first node of my role;

Why?

Thanks in advance

Stefano

darrell_merryweather
Active Contributor
0 Kudos

Stefano

A couple of things

1) Make sure that the isolation level of each iView is set to isolated (level 3/4 I believe)

Try this. If this doesn't work (which I feel it may) let me have the JSP code that defines your HTMLb button and also the Javascript in both the sending iView and the receiving iView so that I can see how you are declaring the EPCF functions

D

Former Member
0 Kudos

Hi Darrell,

I use EP 6.0 and I try to modify the isolation method of iView and if I don't select EMBEDDED the javascript error occurred.(both I select URL or PUMPED method).

I send you my code:

Sender

public class Spedizioniere extends AbstractPortalComponent

{

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)

{

.....

.....

Form myForm = myContext.createFormDocument("Inserimento Parametri");

myForm.addRawText("<script language ='JavaScript'>"+

"function fireEvent(evtData){" +

"EPCM.raiseEvent( 'urn:myOwnNameSpace', 'TrasportoNome', evtData );" +

"}" +

"</script>");

...

...

Button myButton = new Button("Trasferimento");

myButton.setText("Trasferire Nome");

myButton.setOnClientClick("javascript:fireEvent('" + nome + "')");

Reveicer

public class Ricevitore extends AbstractPortalComponent

{

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)

{

....

....

Form myForm = myContext.createFormDocument("Ricezione Parametri");

myForm.addRawText("<script language ='JavaScript'>" +

"function handle_Event( eventObject ){" +

"location.search = " +

"'?evtData='+eventObject.dataObject;}" +

"EPCM.subscribeEvent( 'urn:myOwnNameSpace', 'TrasportoNome', handle_Event);" +

"</script>");

String dataObject = request.getParameter("evtData");

Thanks in advance

Stefano

darrell_merryweather
Active Contributor
0 Kudos

Hi

There are a couple of things that I can see which are incorrect

1) The load method needs to be URL for both iviews

2) For the setOnClientClick you need to remove the javascript: part of it as it automatically puts this in when it is rendering it. Therefore you only need to put the javascript function name

Also, what does the Javascript error say. If this still doesn't work, then please send me the HTML code that has been rendered to the client by doing a view source on each iView. They must both be set to URL though

D

Former Member
0 Kudos

Hi Darrell,

when the page is loaded the two error occurred:

1)OBJECT NEEDED

2)_htmlbMessageBar NOT DEFINIED

here the html code:

<html><head><LINK REL=stylesheet HREF="/irj/portalapps/com.sap.portal.themes.lafservice/themes/portal/sap_standard/prtl_std/prtl_std_ie6.css?6.0.2.10.0">

<LINK REL=stylesheet HREF="/irj/portalapps/com.sap.portal.themes.lafservice/themes/portal/sap_standard/glbl/glbl_ie6.css?6.0.2.10.0">

<!-- EPCF: BOB Core -->

<META http-equiv="Content-Script-Type" content="text/javascript">

<SCRIPT src="/irj/portalapps/com.sap.portal.epcf.loader/script/standard/js13_epcf.js?6.0129"></SCRIPT>

<SCRIPT>

<!--

EPCM.relaxDocumentDomain();

EPCM.init( );

EPCM.DSM.init( );

function SAPWP_receiveSessInfo( sessInfo, frameRef ){

EPCM.DSM.processSession( sessInfo, frameRef );

EPCM.DSM.notifyMonitor( sessInfo );

}

//-->

</SCRIPT>

<!-- EPCF: EOB Core -->

<!-- HTML Business for Java, 60_SP2P4_REL, 78143, Thu Jun 24 18:36:14 CEST 2004 -->

<!-- HTMLB: begin VARS -->

<script language="JavaScript">

ur_system = ;

var popup_emptydoc = "/irj/portalapps/com.sap.portal.htmlb/jslib/emptyhover.html";

</script>

<!-- HTMLB: end VARS -->

<title >SAP Enterprise Portal 6.0</title><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"><link REL=STYLESHEET HREF="/irj/portalapps/com.sap.portal.themes.lafservice/themes/portal/sap_standard/ur/ur_ie6.css?6.0.2.10.0" TYPE="text/css" ></head><body class="prtlBody">

<!-- EPCF: BOB Applet (default) -->

<APPLET CODEBASE="/irj/portalapps/com.sap.portal.epcf.loader/applet" ARCHIVE="epcf.jar" CODE="com.sapportals.portal.epcf.EPCMfactory" ID="_EPCMfactory_" NAME="_EPCMfactory_" STYLE="POSITION: absolute;" WIDTH="0" HEIGHT="0" MAYSCRIPT>

<PARAM name="trace.level" value="2">

<PARAM name="DSM.serverUrl" value="/irj/servlet/prt/portal/prtroot/com.sap.portal.dsm.Terminator">

<PARAM name="DSM.scope" value="f387d5c9d2c4bca6b3d68101235c612d">

</APPLET>

<!-- EPCF: EOB Applet (default) -->

<!-- EPCF: Component ComunicazioneIview.Spedizioniere, bmkmngmmeopehcanopimopabcdfmgbdn -->

<DIV style="height:100%; width:100%" class="urTrcBodyBox urTrcBodyBoxMrg"><form style="margin:0px 0px 0px 0px;" name="htmlb_16629_0" id="htmlb_16629_0" method="POST" action="/irj/servlet/prt/portal/prteventname/HtmlbEvent/prtroot/pcd!3aportal_content!2fIT05648!2fRuoli!2fMyUWL!2fPagine!2fDocumentiPaolo!2fTrasmissioneDati1" onsubmit="return htmlbCheckSubmit('htmlb_16629_0');" ondragover="htmlbFormDragOver()" ondragleave="htmlbFormDragLeave()"><SCRIPT language="JavaScript" defer>htmlb_formid = 'htmlb_16629_0';var htmlb_messageBarId = 'MessageBar7f131b';</SCRIPT><div class="urMsgBarStd" id="MessageBar7f131b" style="display:none;"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="urTxtStd" valign="top"><span id="MessageBar7f131b_ur_bar_img" class="urMsgBarImg"><img height="12" width="12" src="/irj/portalapps/com.sap.portal.themes.lafservice/themes/portal/sap_standard/common/1x1.gif"></span><td><span id="MessageBar7f131b_ur_bar_text" class="urTxtStd"></span></tr></tbody></table></div><input type="hidden" name="htmlbevt_ty"><input type="hidden" name="htmlbdoc_id" value="htmlb_16629"><input type="hidden" name="htmlbevt_frm" value="htmlb_16629_0"><input type="hidden" name="htmlbevt_oid"><input type="hidden" name="htmlbevt_id"><input type="hidden" name="htmlbevt_cnt"><input type="hidden" name="htmlbevt_par1"><input type="hidden" name="htmlbevt_par2"><input type="hidden" name="htmlbevt_par3"><input type="hidden" name="htmlbevt_par4"><input type="hidden" name="htmlbevt_par5"><input type="hidden" name="htmlbevt_par6"><input type="hidden" name="htmlbevt_par7"><input type="hidden" name="htmlbevt_par8"><input type="hidden" name="htmlbevt_par9"><input type="hidden" name ="htmlbScrollX"><input type="hidden" name ="htmlbScrollY"><input type="hidden" name="htmlbValueHelpFieldId" value=""><input type="hidden" name ="htmlbJavaScriptPath" value="/irj/portalapps/com.sap.portal.htmlb/jslib/"><input type="submit" name="htmlb_submit" style="position:absolute;top:-1;width:0;height:0;" onClick="return htmlbCheckSubmit('htmlb_16629_0');"><script language ='JavaScript'>function fireEvent(evtData){EPCM.raiseEvent( 'urn:myOwnNameSpace', 'TrasportoNome', evtData );}</script><label for="htmlb_16629_0_1" class="urLblStd"><nobr>Inserimento Nome</nobr></label><span id="htmlb_16629_0_1_ur_r" style="font-size:1em;"><input class="urEdfTxtEnbl" dsbl="false" autocomplete="off" maxlength="150" id="htmlb_16629_0_1" name="htmlb_16629_0_1" value=""></span><a href="javascript:void(0);" onclick="if (htmlbButton_checkClick('htmlb_16629_0_2', event)) {return htmlbDoEvent(this,'C','onclick','0','htmlb_16629_0',2,1,'',0);}" onkeypress="if (htmlbButton_checkClick('htmlb_16629_0_2', event)) {return htmlbDoEvent(this,'C','onclick','0','htmlb_16629_0',2,1,'',0);}" class="urBtnStd" id="htmlb_16629_0_2"><nobr>Trasferire Nome</nobr></a><input type="hidden" name="htmlbfrm_htmlb_16629_0_0" value="2;Inserimento_Nome;1;0_1;Trasferimento;2;2;2;@csh@.event.ButtonClickEvent;@0@;3;@csh@.InputField;@csh@.type.DataString;@"><input type="hidden" name="htmlbfrm_htmlb_16629_0_1" value="csh@.Button;"><input type="hidden" id="htmlb_16629_0_complete" code="OK"><script defer>sapUrMapi_initLinkStatus()</script></form><script defer>function htmlb_16629_0_2_click(htmlbevent){fireEvent('Paolo');}

function htmlb_16629_0_2_onclick(htmlbevent){htmlb_formid = 'htmlb_16629_0';fireEvent('Paolo');}var MessageBar7f131b= new htmlbMessageBar("htmlb16629_0","MessageBar7f131b","htmlb_16629");var htmlb_16629_0_2= new htmlbButton("htmlb16629_0","htmlb_16629_0_2");</script></DIV>

<!-- EPCF: BOB BODY -->

<DIV style="DISPLAY:none">

<FORM name="DSMSenderf387d5c9d2c4bca6b3d68101235c612d" action="" method="POST" target="" >

<input type="hidden" name="TermString">

<input type="hidden" name="SerPropString">

<input type="hidden" name="SerKeyString">

<input type="hidden" name="LogoffMode">

<input type="hidden" name="Autoclose">

<input type="hidden" name="LogTerm">

</FORM>

</DIV>

<!-- EPCF: EOB BODY -->

</body></html>

darrell_merryweather
Active Contributor
0 Kudos

Stefano

I am unsure at the moment. So, I have created the same (although very simplified) version of the two iViews. The first iView has a button which I click to raise the event and pass a value. The second simply displays the result on the screen. I created both iviews from the par file and set their load to be URL. I then put these on the same page and displayed the page. When I click on the button of the first iView the second one refreshes and displays the value from the request.

I hope this code helps. The only thing that I could do would be to have you send me the PAR files (via email) and to have a look at the complete projects and try them out on my own portal.

As a side note, which version of EP6 are you using ?

<u>Source code for EventRaiser iView</u>

<i>

import com.sapportals.portal.prt.component.*;

//Import the HTMLb rendering classes

import com.sapportals.htmlb.rendering.IPageContext;

import com.sapportals.htmlb.rendering.PageContextFactory;

import com.sapportals.htmlb.Form;

import com.sapportals.htmlb.Button;

public class EventRaiser extends AbstractPortalComponent

{

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)

{

IPageContext pageContext = PageContextFactory.createPageContext(request, response);

Form myForm = pageContext.createFormDocument("MyForm");

myForm.addRawText("<script language ='JavaScript'>"+

"function fireEvent(evtData){" +

"EPCM.raiseEvent( 'urn:myOwnNameSpace', 'TrasportoNome', evtData );" +

"}" +

"</script>");

Button myButton = new Button("Trasferimento");

myButton.setText("Trasferire Nome");

myButton.setOnClientClick("fireEvent('myvalue')");

myForm.addComponent(myButton);

pageContext.render();

}

}

</i>

<u>portalapp.xml for EventRaiser iView</u>

<i>

<?xml version="1.0" encoding="utf-8"?>

<application>

<application-config>

<property name="SharingReference" value="htmlb"/>

</application-config>

<components>

<component name="EventRaiser">

<component-config>

<property name="ClassName" value="com.sap.sdn.test.EventRaiser"/>

<property name="SecurityZone" value="com.sap.sdn.test/high_safety"/>

</component-config>

<component-profile/>

</component>

</components>

<services/>

</application>

</i>

<u>Source code for EventReceiver iView</u>

<i>

//Import the HTMLb rendering classes

import com.sapportals.htmlb.rendering.IPageContext;

import com.sapportals.htmlb.rendering.PageContextFactory;

import com.sapportals.htmlb.Form;

import com.sapportals.htmlb.TextView;

import com.sapportals.htmlb.enum.TextViewDesign;

public class EventReceiver extends AbstractPortalComponent

{

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)

{

IPageContext pageContext = PageContextFactory.createPageContext(request, response);

Form myForm = pageContext.createFormDocument("MyForm");

myForm.addRawText("<script language ='JavaScript'>" +

"function handle_Event( eventObject ){" +

"location.search = " +

"'?evtData='+eventObject.dataObject;}" +

"EPCM.subscribeEvent( 'urn:myOwnNameSpace', 'TrasportoNome', handle_Event);" +

"</script>");

String dataObject = request.getParameter("evtData");

TextView tv = new TextView("Result");

tv.setText("DataObject: " + dataObject);

tv.setDesign(TextViewDesign.EMPHASIZED);

myForm.addComponent(tv);

pageContext.render();

}

}

</i>

<u>Source code for EventReceiver iView</u>

<i>

<?xml version="1.0" encoding="utf-8"?>

<application>

<application-config>

<property name="SharingReference" value="htmlb"/>

</application-config>

<components>

<component name="EventReceiver">

<component-config>

<property name="ClassName" value="com.sap.sdn.test.EventReceiver"/>

<property name="SecurityZone" value="com.sap.sdn.test/high_safety"/>

</component-config>

<component-profile/>

</component>

</components>

<services/>

</application>

</i>

Former Member
0 Kudos

Hi Darrell,

thank you very very much for your replies! My work run!!!

The error was in the rendering of the iView!

Thanks a lot!

Happy new year!

Stefano

Answers (0)