0% found this document useful (0 votes)
149 views1 page

DEV101 Javascript Controllers Quickcard 9-14-2016 PDF

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
149 views1 page

DEV101 Javascript Controllers Quickcard 9-14-2016 PDF

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

JavaScript Controllers QuickCard

Import an Object Displaying a Form (Equivalent of ICN node)


var ISML = require('dw/template/ISML'); ISML.renderTemplate(
'editpreferences.isml',
var guard = require('storefront_controllers/cartridge/scripts/guard');
{
ContinueURL : dw.web.URLUtils.https('JEditPreferences-
Function Declaration and Exposure HandleForm')
function start() { }
} );
exports.Start = guard.ensure([ 'get'], start);
exports.Start = guard.ensure([ 'get', 'https', 'loggedIn' ], start);
Submit Button
Dealing with Query Parameters var submitButton = request.triggeredFormAction.formId;
var parameterId = request.httpParameterMap.pid.stringValue

Writing to Browser Directly


Handling Forms response.getWriter().println(“Hello from controllers”);
/* assuming forms/default/preferences.xml is the metadata */
var preferencesForm = session.forms.preferences; Explicit Transactions
preferencesForm.clearFormElement(); var Transaction = require('dw/system/Transaction);
preferencesForm.copyFrom(customer.profile); Transaction.begin();
preferencesForm.copyTo(customer.profile); Transaction.commit();
preferencesForm.interestElectronics.value; Transaction.rollback();
preferencesForm.invalidateFormElement();

Redirecting to Another Pipeline


Giving Control to ISML (Equivalent of Interaction node) var URLUtils = require('dw/web/URLUtils');
ISML.renderTemplate( response.redirect(URLUtils.https('Account-Show'));
'productnotfound.isml',
{ Invoking a Script (js or ds)
message:'product'+parameterId+'found' var myModel = require('~/cartridge/scripts/MyModel');
} var co = myModel.doJobForMe(takeThisObject);
);

© 2016 Demandware, Inc.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy