You're very kind to send this along. I appreciate it. Well, it turns out I am already using a filter (just did not realize it) because i'm using a threadlocal technique to handle Hibernate sessions in my app.
thanks again.
-Kristofer
On Nov 9, 2004, at 12:53 PM, [EMAIL PROTECTED] wrote:
Kristofer,
�
��� Here is a simplified�example of what I mean, it is not tested, I just wrote the code off the top of my head. You take
a filter like this and map it onto all your entry points of the application...using JSF we only have one servlet.
Also, you really have to have a look at J2EE filters to get the full picture, you can read all about them in the J2EE tutorial.
Furthermore, filters can be used for many other things like compression, security, etc...
�
public class FilterEnsureNoDoubleClick implements Filter
{
�public void destroy()
�{
�}
�
�public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException
�{
��
��
��HttpSession mySession = ((HttpServletRequest)req).getSession();
��
��Boolean requestInProgess = (Boolean)mySession.getAttribute("SEMAPHORE_REQUEST_IN_PROGRESS");
��
��if ( requestInProgess.booleanValue() == true )
��{
���((HttpServletResponse) resp).sendRedirect("to some other page telling the user to click only once or something");�
��}
��else
��{
���mySession.setAttribute("SEMAPHORE_REQUEST_IN_PROGRESS", Boolean.TRUE);
���chain.doFilter(req, resp);�
���mySession.setAttribute("SEMAPHORE_REQUEST_IN_PROGRESS", Boolean.FALSE);
��}
��
�}
�
�public void init(FilterConfig config) throws ServletException
�{
�}
}
HTH
�
Mark
�
�
De�: Kristofer Younger [mailto:[EMAIL PROTECTED]
Envoy�: mardi 9 novembre 2004 10:59
��: [EMAIL PROTECTED]
Objet�: Re: multiple submits...
Mark
having not done a filter yet, it would be very helpful if I could get the code example...
TIA,
-Kristofer
On Nov 9, 2004, at 10:25 AM, [EMAIL PROTECTED] wrote:
We solved the problem by updating a semaphore in a filter,
It is very simple, only a coule of lines of code in one method...of course,
assuming you are using http sessions.
If this is not clear, I can send you an example.
HTH
Mark
-----Message d'origine-----
De : Kristofer Younger [mailto:[EMAIL PROTECTED]]
Envoy� : mardi 9 novembre 2004 10:17
� : MyFaces Discussion
Objet : multiple submits...
Is there an idiomatic method to making sure a form only gets submitted once per session? I'm getting dizzy trying decide the best method for myfaces...
any advice would sure be appreciated.
-Kristofer

