cancel
Showing results for 
Search instead for 
Did you mean: 

ivews and popup

Former Member
0 Kudos

Hello,

I have a parent page , which has a button,on click of that button I want to show a pop-up child window (like a confirmation box asking the user yes or no). When a user clicks on yes or no, i want to close the child window and pass the users input (yes / no) to the parent page and then either save or cancel.

For the child window , I implemented an iview which has text and yes / no buttons. From my parent page , on click of button i do a window.open to open this iview. On my child window , i raise an epcm event on click of yes / no button to call the parent page where i have subscribed to this event. My problem is event is not getting fired up , if it is a separate window. For a test i put the child window iview in the page where parent iview is, and it works just fine (all events get fired up). can event model be used by the iviews only if they are in the same page. Is there any workaround or any other way of doing it.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Tarun,

Client side event between portal components using the EPCM is only possible if the portal components are on the same portal page. Other wise these are different requests to the portal.

Instead of implementing your own portal component for confirmation you could use a the javascript confirm message box in the BUTTONCLICK property and act according to the user's input.

Regards,

Tsachi

Former Member
0 Kudos

Thanks Tsachi for your response....

but on the same lines

In my page i have a delete button, i want to show a confirmation box asking yes/no, even if i use confirmation box and get the users input, how do i make sure that only a yes executes the server side code.

i didnt see a attributes property with the button , that i can use to add javascript functionality and also make it post back.

If i just write <b>return confirm("Are you sure")</b>

irrespective whether user clicks yes or no, control still goes in to the button_click event.

I even tried doing

<b>var result = confirm ("are you sure");

if (result==true)

{

<% strTemp = "yes"%>

}

else

{

<% strTemp ="no"%>

}</b>

strTemp is a public string variable declared in .vb page and it's intial value is String.Empty.

When user clicks on yes/no on confirmation box, everytime it goes in to event handlr for the button ,

strTemp is still empty.

Any idea....

Message was edited by: Tarun Gogia

Former Member
0 Kudos

Hi Tarun,

Here is a work-around that might help u:

Add this javascript function to the portal component (inside the body tag):

<script language="javascript">
    function btnDeleteClick() {
        var cancel = confirm("Are u sure?");
        if(cancel == true) {
            document.forms["<%=this.Form.ID %>"].onsubmit = function(){return false;};
        }
    }
</script>

Now, call this function in the BUTTONCLICK client event of the button:


<sap:Button ID="btnDelete" runat="server" BUTTONCLICK='btnDeleteClick();' OnAction="btnDelete_Action" Text="Delete"></sap:Button>

The new function will prevent the form from being submitted.

I hope that helps u.

Reshef

Former Member
0 Kudos

Reshef ,

I tried what you suggested, but it's result is still the same, for a yes / no, it still goes to the event handler. Only change i did was to change the event handler scope to public from private, beacuse it was giving inaccessible error.

Here is the code...

<b><body class="prtlBody" xmlns:sap="urn:http://schemas.sap.com/SAP.Web.UI.Controls">

<script language="javascript">

function btnDeleteClick() {

var cancel = confirm("Are u sure?");

if(cancel == true) {

document.forms["<%=Me.Form.ID %>"].onsubmit = function(){return false;};

}

}

</script>

<sap:Button id="Button2" Text="Delete" runat="server" BUTTONCLICK='btnDeleteClick();' OnAction='Button2_Action' ></sap:Button>

<sap:Label id="Label1" runat="server" Text="Test"></sap:Label>

</body></b>

Following is the code for the event handler where i have changed the scope to public

<b>Public Sub Button2_Action(ByVal sender As System.Object, ByVal e As SAP.Web.UI.Controls.AbstractButton.ActionEventArgs) Handles Button2.Action

Label1.Text = "Button2 clicked me"

End Sub</b>

Former Member
0 Kudos

Hi Trun,

U r right. I had a mistake in the code I sent u.

the form function is named <b>submit</b> and <u>not</u> <b>onsubmit</b>.

So the javascript code should be:

<script language="javascript">
    function btnDeleteClick() {
        var cancel = confirm("Are u sure?");
        if(cancel == true) {
            document.forms["<%=Me.Form.ID %>"].<b>submit</b>=function(){return false;};
        }
    }
</script>

Sorry, Reshef

Former Member
0 Kudos

Hey Reshef ,

It didn't work. If i click on yes/no, either way it is not going to server side. I think it is the case-senstivity, i think the syntax is Submit (not submit). However, if i use Submit, either way (yes/no), it is going to server side function. I am starting to feel , is the portal add-in which has bugs. Because this seems to be a simple thing...

Let me know , what you think...

Tarun

Former Member
0 Kudos

Hi Tarun,

Can u please paste the html code of your portal component (by selecting View source when right clicking on the page)?

Thanks, Reshef

Former Member
0 Kudos

[code]

<html><head><LINK REL=stylesheet HREF="/irj/portalapps/com.sap.portal.design.portaldesigndata/themes/portal/customer/BASIS/glbl/glbl_ie6.css?6.0.14.0.1">

<LINK REL=stylesheet HREF="/irj/portalapps/com.sap.portal.design.urdesigndata/themes/portal/customer/BASIS/ur/ur_bdy_prtl_ie6.css?6.0.14.0.1">

<LINK REL=stylesheet HREF="/irj/portalapps/com.sap.portal.design.portaldesigndata/themes/portal/customer/BASIS/prtl_std/prtl_std_ie6.css?6.0.14.0.1">

<!-- 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.0723"></SCRIPT>

<SCRIPT>

<!--

EPCM.relaxDocumentDomain();

EPCM.init( );

EPCM.DSM.init( );

function SAPWP_receiveSessInfo( sessInfo, frameRef ){

EPCM.DSM.processSession( sessInfo, frameRef );

}

//-->

</SCRIPT>

<!-- EPCF: EOB Core -->

<!-- HTML Business for Java, 60NW_VAL_REL, 160652, Wed Sep 21 03:20:56 EDT 2005 -->

<!-- HTMLB: begin VARS -->

<script language="JavaScript">

ur_system = ;

</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.design.urdesigndata/themes/portal/customer/BASIS/ur/ur_ie6.css?6.0.14.0.1" TYPE="text/css" ><script SRC="/irj/portalapps/com.sap.portal.dotnet.framework/scripts/controls/dotNETHandler.js" ></script><script SRC="/irj/portalapps/com.sap.portal.htmlb/jslib/sapUrMapi_ie6.js" ></script><script SRC="/irj/portalapps/com.sap.portal.htmlb/jslib/popup_ie6.js" ></script><script SRC="/irj/portalapps/com.sap.portal.dotnet.framework/scripts/controls/urMessageBundle_en.js" ></script></head><body class="prtlBody urFontBaseFam urScrl">

<!-- EPCF: Component PortalApplication1.ChooseType, joekigblclcbeeihifhgilajhfbcffno -->

<SCRIPT>var oldDesign = document.body.className;var designStr = "urTrcBodyBox urTrcBodyBoxMrg"; if(oldDesign != null && oldDesign != ''){designStr = oldDesign + ' ' +designStr ;} document.body.className = designStr;</SCRIPT><form method="post" id="pcd_portal_content_com_citrix_Test_com_citrix_SimpleTestRole_com_citrix_SimplePage1_com_citrix_ChooseType" name="pcd_portal_content_com_citrix_Test_com_citrix_SimpleTestRole_com_citrix_SimplePage1_com_citrix_ChooseType" action="/irj/servlet/prt/portal/prteventname/POST_BACK/prtroot/pcd!3aportal_content!2fcom.citrix.Test!2fcom.citrix.SimpleTestRole!2fcom.citrix.SimplePage1!2fcom.citrix.ChooseType">

<input type="hidden" name="__VIEWSTATE" value="dDw1MzgxO3Q8O2w8aTwwPjsO2w8dDxwPGw8bWV0aG9kOz47bDxwb3N0Oz4OzsOz4Oz5Sw2zaq2jMqZJtb6htafLPH8m+Rg==" />

<!%@ PortalComponent name="ChooseType" %>

<script language="javascript">

function btnDeleteClick()

{

var cancel = confirm("Are u sure?");

if(cancel == true)

{

document.forms["pcd_portal_content_com_citrix_Test_com_citrix_SimpleTestRole_com_citrix_SimplePage1_com_citrix_ChooseType"].Submit=function(){return false;};

}

}

</script>

<a href="javascript:void(0);" onclick="btnDeleteClick();__doPostBack_pcd_portal_content_com_citrix_Test_com_citrix_SimpleTestRole_com_citrix_SimplePage1_com_citrix_ChooseType('_pcd_portal_content_com_citrix_Test_com_citrix_SimpleTestRole_com_citrix_SimplePage1_com_citrix_ChooseType$Button2','');return false;" onkeypress="btnDeleteClick();__doPostBack_pcd_portal_content_com_citrix_Test_com_citrix_SimpleTestRole_com_citrix_SimplePage1_com_citrix_ChooseType('_pcd_portal_content_com_citrix_Test_com_citrix_SimpleTestRole_com_citrix_SimplePage1_com_citrix_ChooseType$Button2','');return false;" class="urBtnStd" id="_pcd_portal_content_com_citrix_Test_com_citrix_SimpleTestRole_com_citrix_SimplePage1_com_citrix_ChooseType_Button2" ct="Button" style="white-space:nowrap;">Delete</a>

<label id="_pcd_portal_content_com_citrix_Test_com_citrix_SimpleTestRole_com_citrix_SimplePage1_com_citrix_ChooseType_Label1" ct="Label" class="urLblStd" onclick="sapUrMapi_Label_clickLabeledElement('_pcd_portal_content_com_citrix_Test_com_citrix_SimpleTestRole_com_citrix_SimplePage1_com_citrix_ChooseType_Label1','',event)" style="white-space:nowrap;"><span>Test</span></label>

<input type="hidden" name="__EVENTTARGET" value="" />

<input type="hidden" name="__EVENTARGUMENT" value="" />

<script language="javascript" type="text/javascript">

<!--

function __doPostBack_pcd_portal_content_com_citrix_Test_com_citrix_SimpleTestRole_com_citrix_SimplePage1_com_citrix_ChooseType(eventTarget, eventArgument) {

var theform;

if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {

theform = document.pcd_portal_content_com_citrix_Test_com_citrix_SimpleTestRole_com_citrix_SimplePage1_com_citrix_ChooseType;

}

else {

theform = document.forms["pcd_portal_content_com_citrix_Test_com_citrix_SimpleTestRole_com_citrix_SimplePage1_com_citrix_ChooseType"];

}

theform.__EVENTTARGET.value = eventTarget.split("$").join(":");

theform.__EVENTARGUMENT.value = eventArgument;

theform.submit();

}

// -->

</script>

</form>

<!-- EPCF: BOB BODY -->

<DIV style="DISPLAY:none">

<FORM name="DSMSenderb8da61836fa1df432c1409097512c790" 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>

[/code]

Former Member
0 Kudos

Hi Tarun,

I found the problem (once again...).

The problem with the previous script was that when after the first time that u clicked OK in the confirm message, the logic for the submit() command of the form was changed to always return false and cancel the submission of the form.

Therefore, the original logic should be chached so it can be restored later.

The following code handles this issue:

<script language="javascript">

    var cacheFormSubmit = document.forms["<%=this.Form.ID %>"].submit;
	
    function btnDeleteClick() {
        var cancel = confirm("Are u sure you want to cancel?");
        if(cancel == true) {
            document.forms["<%=this.Form.ID %>"].submit = function(){return false;};
        } 
        else {
	    document.forms["<%=this.Form.ID %>"].submit = cacheFormSubmit;
	}
    }
</script>

Bye, Reshef

Answers (0)