" Stripes uses the flash scope implicitly"
Right, I was thinking that might be the case. So even if I'm not deliberately
using it, I am actually using it and can't disable it. That's fine - so
nevermind about the disable feature.
But this doesn't look very good, see the FlashRequest constructor:
/**
* Creates a new FlashRequest by copying all appropriate attributes from
the prototype
* request supplied.
*
* @param prototype the HttpServletRequest to create a disconnected copy of
*/
@SuppressWarnings({ "unchecked", "deprecation" })
public FlashRequest(HttpServletRequest prototype) {
..... snip .....
// copy headers
for (String key : Collections.list((Enumeration<String>)
prototype.getHeaderNames())) {
headers.put(key, Collections.list(prototype.getHeaders(key)));
try {
dateHeaders.put(key, prototype.getDateHeader(key));
} catch (Exception e) {
}
}
// copy locales
locales = Collections.list(prototype.getLocales());
// copy parameters
parameters.putAll(prototype.getParameterMap());
}
Maybe we can do better there. Can we add a specific set of header names that
can be converted to dates, instead of blindly trying to convert every single
header to a date which results in many many exceptions occurring and being
suprressed. If you can prevent an exception with a simple if check, it is far
less expensive to do that first instead of letting it occur and catching it.
Right?
-------------------- patch
private static final Set<String> possibleDateHeaders = new HashSet<String>();
static {
possibleDateHeaders.add("Date");
possibleDateHeaders.add("If-Modified-Since");
... see http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
}
... if (possibleDateHeaders.contains(key)) {
try {
dateHeaders.put(key, prototype.getDateHeader(key));
} catch (IllegalArgumentException e) {
// should no longer occur since we only call when it
will succeed. Right?
}
}
That would eliminate the issue I saw this morning, all this extra failed date
parsing on things like the content-type header etc.
-J
-----Original Message-----
From: Freddy Daoud [mailto:[email protected]]
Sent: Thursday, January 13, 2011 11:54 AM
To: Stripes Users List
Subject: Re: [Stripes-users] Disabling the flash scope feature?
Hi John,
> Should I
> look at using flash scope because I’m missing how powerful it is? (I
> haven’t seen a need for it yet).
Well, it's not so much that you would use the flash scope directly, but it is
used implicitly in some useful ways. One common example that comes to mind is
when you submit a form that saves some data to the database. Afterwards, you
want to do a redirect (to avoid resubmitting the form on a browser refresh) and
you want to show some kind of "the data has been saved" message on the page.
You would use a Stripes message and <stripes:messages/> for that.
Stripes uses the flash scope implicitly to make the messages survive the
additional request done by the redirect.
Cheers,
Freddy
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks Learn about various
malware tactics and how to avoid them. Understand malware threats, the impact
they can have on your business, and how you can protect your company and
customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users