CONTROLLER AND WEBAPP COOKBOOK ============================== * Securing controller requests Use the tag inside your tag. https="true" makes the page https auth="true|false" determines whether user must be logged in direct-request="false" makes the request unavailable to the browser at /control/ (so it can only be accessed in a request-chain * Running services asynchronously * Making sure user doesn't double submit form instead of type="view" AVOID USING request-redirect AS THE type OF A response. request-redirect causes all your original parameters to be part of the URL parameter, and special characters such as # or % would cause a problem. So do not do this: Do this instead: * Using the same field value for multiple lines of service calls ServiceMultiEventHandler now accepts a checkGlobalScope flag which defaults to true, so if it doesn't find a parameter with the multi-line suffix then it should find it just fine without the suffix * Here's how to loop through a number in freemarker <#assign numberOfTimes = 10> <#list [0..numberOfTimes] as number> * Error and event messages are set in request attributes _ERROR_MESSAGE_ (String), _EVENT_MESSAGE_ (String), _ERROR_MESSAGE_LIST_ (String), _EVENT_MESSAGE_LIST_ (String). They can be set with request.setAttribute() and retrieved with request.getAttribute(). See framework/common/webcommon/includes/messages.ftl. * There is also an org.ofbiz.base.util.MessageString for working with error messages. For example, it could help you retrieve the error message related to a particular field. * Re-directing after a request Use "/control/req1/req2" and the controller will do request "req1" and then "req2" * How to add pre-filled fields to a lookup button Lookup buttons are created with a Javascript which calls a URL for doing the lookup, and you can add pre-populated fields to it just by adding a parameter to the end, like this: "javascript:call_fieldlookup2(document.addProductStoreRole.partyId,'LookupPartyName?productStoreId=${productStoreId}');" * A couple of tips on XSL:FO 1. Always put ?xml after your description or text or use <#escape x as x?xml>, or you'll eventually get a crash * Keeping logged in state when Switching between webapps Always put this externalLoginKey parameter so when you go from one app to another, so the system doesn't ask you to login again: &externalLoginKey=${externalLoginKey}