Skip to Content
0
Former Member
Jul 26, 2005 at 05:51 PM

Accessing javascript from the dynpage

16 Views

Hi,

I am creating the JSP from within the dynpage. So in the doProcessBeforeOut() I am creating the tableviews and assiging components into it.

I need to create a javascript that would display a confirmation message before the user deletes a record. On the SAP website, there is a sample code that helps do that. Although I followed the example, the code doesn't seem to be able to access and read the javascript file.

Details:

In the dynpage:

===============

IPortalComponentRequest request = (IPortalComponentRequest) getRequest();

String jsResource = request.getWebResourcePath() + "/com.nexeninc.tots.admin.group/dist/scripts/confirmation.js";

this.getPageContext().getDocument().addHeadResource(ResourceType.JAVASCRIPT, "test", jsResource);

In the confirmation.js file: just for now, and to simplify it further I am just displaying an allert

============================

function warn(){

alert("will be deleted")

}

In the dynpage again: where I am defining the button component

====================

Button btnDelete = new Button("btnDelete");

btnDelete.setText("Delete");

btnDelete.setJsObjectNeeded(true);

//then I am adding the button to the form

btnDelete.setClientEvent(EventTrigger.ON_CLICK, "warn()");

Did anybody face the same problem? If yes, what would you suggest to do?

Thanks