You are on page 1of 2

CONTROLLER AND WEBAPP COOKBOOK

==============================
* Securing controller requests
Use the <security > tag inside your <request-map ..> 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 /contro
l/ (so it can only be accessed in a request-chain
* Running services asynchronously
<event type="service" path="async" ...>
* Making sure user doesn't double submit form
<response type="request-redirect" ...>
instead of type="view"
AVOID USING request-redirect AS THE type OF A response. request-redirect caus
es 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 thi
s:
<response name="viewContact" type="request-redirect" value="viewContact"
/>
Do this instead:
<response name="viewContact" type="request" value="viewContact"/>
* 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 suffi
x
* Here's how to loop through a number in freemarker
<#assign numberOfTimes = 10>
<#list [0..numberOfTimes] as number>
</#list>
* 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 mess
ages. 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 "r
eq2"
* How to add pre-filled fields to a lookup button
Lookup buttons are created with a Javascript which calls a URL for doing the l
ookup, 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,'LookupPartyN
ame?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 anot
her, so the system doesn't ask you to login again:
&externalLoginKey=${externalLoginKey}

You might also like