It worked!!!!!
Thank you! Thank you!!

On 2/1/07, Michael Horwitz <[EMAIL PROTECTED]> wrote:

Hi Chris, Misun,

I am going to attempt to answer these both here as there seems to be some
interest in Dojo on AppFuse. First a note of warning: I use Spring MVC, so
all instructions are known to work for Spring MVC only. Time permitting (and
enough interest in the user community) I could look into expanding this into
other web frameworks and writing a tutorial, but this has yet to happen.
These instructions are also not going to be very detailed - they give an
outline as to what needs to be done, and hopefully will be enough to get
your projects working.

To get Dojo to work in AppFuse:

1) Dojo and Scriptaculous do not co-exist happily. By default all AppFuse
pages import the Scriptaculous javascript files. To get around this I had to
modify the default template and created a new include JSP called
javascript.jsp. The latter exists in two flavours: javascript.jsp (the
default scriptaculous stuff - don't want to break existing AppFuse pages!)
and javascript-dojo.jsp which is dojo specific. Those pages that require
dojo widgets declare <meta name="scriptType" content="dojo"/> in their
header, and default.jsp does the following:

 <c:set var="scriptType"><decorator:getProperty property="meta.scriptType
"/></c:set>
        <c:choose>
          <c:when test="${scriptType == 'dojo'}">
            <%@ include file="/common/javascript-dojo.jsp" %>
          </c:when>
          <c:otherwise>
            <%@ include file="/common/javascript.jsp" %>
          </c:otherwise>
        </c:choose>
2) global.js has a window.onload function which uses scriptaculous stuff.
I now have three flavours: global.js, global-scriptaculous.js and global-
dojo.js.

3) Configuring the filter in web.xml. This is the bit that is most Spring
MVC specific. If you want to use another framework you are going to need to
do some adapting.


3.1) First the filter declaration:
 <filter>
      <filter-name>dojoFilter</filter-name>
      <filter-class>org.appfuse.webapp.filter.DojoFilter</filter-class>
      <init-param>
        <param-name>includes</param-name>
        <param-value>*.html,/reports/*</param-value>
      </init-param>
      <init-param>
        <param-name>excludes</param-name>
        <param-value>/scripts/dojo/*</param-value>
      </init-param>
  </filter>

This will include (i.e. send to the dispatcher servlet) everything that
ends .html or starts with /reports/ (I have JasperReports integrated as
well), excluding anything that starts with /scripts/dojo/ (the location in
which I have installed the dojo scripts). I have also left the filter
default for the dispatcher servlet name in place, which fowards to a servlet
called "action". Depending on how the dispatcher servlet is configured in
your web.xml you may need to change this.

3.2) Now the filter mapping:
  <filter-mapping>
    <filter-name>dojoFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

In my case I have placed this last in the chain.

3.3) Comment out/remove the existing dispatcher servlet URL mapping (the
dojo filter takes full responsibility for fowarding all requests to the
servlet):

    <!--<servlet-mapping>-->
        <!--<servlet-name>action</servlet-name>-->
        <!--<url-pattern>*.html</url-pattern>-->
    <!--</servlet-mapping>-->

3.4) I changed the mapping for the hibernate filter so it only gets
applied to requests for active pages:

   <filter-mapping>
        <filter-name>hibernateFilter</filter-name>
        <servlet-name>action</servlet-name>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>

And that should pretty much do it.

Mike.
 On 2/1/07, chris wang <[EMAIL PROTECTED]> wrote:
>
>
> still got the error:
> PageNotFound.noHandlerFound(1005) | No mapping
>
> please help, how do config ur web.xml..
>
> tks a lot !!!
>
> chris
>
>
>
> Michael Horwitz wrote:
> >
> > Matt,
> >
> > I have attached a simple filter class which works well with Spring
> MVC.
> > The
> > basic operation works on the following principles:
> >
> > 1) The servlet container retains responsibility for serving all static
> > resources. This ensures optimum performance (resources can be cached,
> have
> > their timestamps checked for updates, etc) and avoids any I/O nasties
> that
> > might arise if the filter itself tries to read and serve up these
> > resources.
> > 2) The filter redirects any requests for active pages to the relevant
> > processing chain, which includes all filters related to active
> content,
> > e.g.
> > Hibernate filter. This helps ensure that the minimum number of filters
> are
> > applied to static content.
> > 3) The filter requires reasonably sophisticated pattern matching
> abilities
> > to sort active from static page requests. This implies the use of an
> > excludes filter on top of the normal include filter provided by
> default as
> > part of the servlet standard.
> >
> > The attached implementation is Spring MVC specific. Any request that
> the
> > filter believes matches an active page are redirected to the dispatch
> > servlet by name. All other requests are allowed to pass straight
> through
> > for
> > normal processing by the servlet container. The solution also relies
> on
> > the
> > use of the <dispatcher> filter configuration element available as of
> the
> > servlet 2.4 spec to separate filtering on active page requests from
> those
> > for static content, which leads me to believe the solution could be
> made
> > to
> > work for the other web frameworks.
> >
> > Let me know what you think.
> >
> > Mike.
> >
> >
> > On 1/29/07, mraible <[EMAIL PROTECTED]> wrote:
> >>
> >>
> >> Any update on this Mike? It looks like most folks would prefer to
> stick
> >> with
> >> *.html (as would I).
> >>
> >> http://appfuse.org/pages/viewpage.action?pageId=495
> >>
> >> Thanks,
> >>
> >> Matt
> >>
> >>
> >> Matt Raible-3 wrote:
> >> >
> >> > On 1/17/07, Michael Horwitz <[EMAIL PROTECTED]> wrote:
> >> >> Matt,
> >> >>
> >> >> I have successfully used Dojo with SpringMVC while still keeping
> the
> >> >> .html
> >> >> extension by using a filter to redirect any non-dojo requests to
> the
> >> >> Spring
> >> >> servlet. This approach has two nice side effects: 1) the servlet
> >> >> container
> >> >> can use its default handling for all static content and 2) one can
>
> >> reduce
> >> >> the number of filters that get applied to such content.
> >> >>
> >> >> If people are interested I would be more than happy to share the
> >> >> solution.
> >> >
> >> > I'd definitely be interested in this and having folks test it with
> >> > Struts 2.  It might be best to post it here, as well as in JIRA
> >> > ( http://issues.appfuse.org/browse/APF-431).
> >> >
> >> > Matt
> >> >
> >> >>
> >> >> Mike.
> >> >>
> >> >>
> >> >> On 1/17/07, Matt Raible < [EMAIL PROTECTED]> wrote:
> >> >> > I've created a poll so everyone can vote on their favorite
> >> extension.
> >> >> >
> >> >> > http://appfuse.org/pages/viewpage.action?pageId=495
> >> >> >
> >> >> > You'll need to create an account and login to vote. To do this,
> go
> >> to
> >> >> > View > Account > Sign Up (or login if you already have an
> account).
> >> >> >
> >> >> > Thanks!
> >> >> >
> >> >> > Matt
> >> >> >
> >> >> > On 1/16/07, Sanjiv Jivan <[EMAIL PROTECTED]> wrote:
> >> >> > > I like .html but the problem I've faced with using this
> extension
> >> is
> >> >> that
> >> >> > > serving static html file with the .html file extension (like
> >> >> documentation,
> >> >> > > Dojo templates or FckEditor files) becomes very hard to map to
> not
> >> go
> >> >> to
> >> >> the
> >> >> > > applications MVC controller. I've spent countless number of
> hours
> >> >> messing
> >> >> > > with the url-pattern in web.xml without much success.
> >> >> > >
> >> >> > >  So I usually use .htm for the application extension.
> >> >> > >
> >> >> > >  Sanjiv
> >> >> > >
> >> >> > >
> >> >> > > On 9/20/06, Matt Raible < [EMAIL PROTECTED]> wrote:
> >> >> > > >
> >> >> > > > Dear AppFuse users,
> >> >> > > >
> >> >> > > > As many of you likely know, there are a couple of issues
> with
> >> using
> >> >> > > > the *.html extension with some frameworks in AppFuse.  For
> >> example,
> >> >> > > > with WebWork - it loads Dojo template files from a *.html
> >> >> extension.
> >> >> > > > If you want to use Dojo with WebWork, you have to modify
> your
> >> >> default
> >> >> > > > extension.
> >> >> > > >
> >> >> > > > http://issues.appfuse.org/browse/APF-431
> >> >> > > >
> >> >> > > > Because of this, we're starting to look at other extensions.
> >> I'd
> >> >> > > > rather use one for all frameworks, rather than the
> recommended
> >> ones
> >> >> > > > for each framework b/c it allows us to have one
> >> security.xmlfiles,
> >> >> > > > rather than one for each framework.  Another option is to
> use
> >> >> > > > path-based mapping, for example:
> >> >> > > >
> >> >> > > > http://localhost:8080/yourapp/go/users
> >> >> > > >
> >> >> > > > Where "/go/*" is the path that front-controller
> servlet/filters
> >> are
> >> >> > > > mapped to.  The only problem with this is stat trackers
> >> typically
> >> >> like
> >> >> > > > to track extensions, and so we'd be unfriendly to those
> >> companies
> >> >> who
> >> >> > > > like to watch their stats.
> >> >> > > >
> >> >> > > > Here's a couple thoughts - feel free to add your own
> suggestions
> >> >> and
> >> >> > > thoughts:
> >> >> > > >
> >> >> > > > 1. *.htm
> >> >> > > > 2. *.aspx
> >> >> > > > 3. *.php
> >> >> > > > 4. *.app
> >> >> > > > 5. *.a
> >> >> > > > 6. *.o
> >> >> > > > 7. *.apf (would help us track AppFuse-based applications,
> but
> >> it's
> >> >> a
> >> >> > > > pretty ugly extension)
> >> >> > > > 8. *.em
> >> >> > > > 9. *.fun
> >> >> > > > 10. *.page
> >> >> > > >
> >> >> > > > I still like *.html the best b/c it doesn't give away the
> >> >> underlying
> >> >> > > > technology, so *.htm seems like the best option after
> that.  But
> >> of
> >> >> > > > course, I'm open to suggestions. ;-)
> >> >> > > >
> >> >> > > > Matt
> >> >> > > >
> >> >> > > >
> >> >> > >
> >> >>
> ---------------------------------------------------------------------
> >> >> > > > To unsubscribe, e-mail:
> >> >> > > [EMAIL PROTECTED]
> >> >> > > > For additional commands, e-mail:
> [EMAIL PROTECTED]
> >> >> > > >
> >> >> > > >
> >> >> > >
> >> >> > >
> >> >> >
> >> >> >
> >> >> > --
> >> >> > http://raibledesigns.com
> >> >> >
> >> >> >
> >> >>
> ---------------------------------------------------------------------
> >> >> > To unsubscribe, e-mail:
> >> >> [EMAIL PROTECTED]
> >> >> > For additional commands, e-mail: [EMAIL PROTECTED]
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > http://raibledesigns.com
> >> >
> >> >
> ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> > For additional commands, e-mail: [EMAIL PROTECTED]
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> 
http://www.nabble.com/Changing-default-extension-from-*.html-to-*.---tf2307780s2369.html#a8699069
> >> Sent from the AppFuse - User mailing list archive at 
Nabble.com<http://nabble.com/>
> .
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >
> > package org.appfuse.webapp.filter;
> >
> > import org.apache.commons.lang.StringUtils;
> > import org.apache.commons.logging.Log;
> > import org.apache.commons.logging.LogFactory;
> > import org.springframework.util.PatternMatchUtils;
> > import org.springframework.web.util.UrlPathHelper ;
> >
> > import javax.servlet.Filter;
> > import javax.servlet.FilterChain;
> > import javax.servlet.FilterConfig;
> > import javax.servlet.RequestDispatcher;
> > import javax.servlet.ServletContext ;
> > import javax.servlet.ServletException;
> > import javax.servlet.ServletRequest;
> > import javax.servlet.ServletResponse;
> > import javax.servlet.http.HttpServletRequest;
> > import javax.servlet.http.HttpServletResponse ;
> > import java.io.IOException;
> > import java.util.Iterator;
> > import java.util.Set;
> >
> > /**
> >  * A simple filter that allows the application to continue using the
> .html
> > prefix for active
> >  * pages but still allows Dojo to serve up its HTML template code. The
> > filter works on an
> >  * include/exclude basis where all requests for active pages are
> > redirected by the filter to
> >  * the dispatch servlet. All Dojo related .html requests are allowed
> to
> > pass straight through
> >  * to be processed by the servlet container as per normal.
> >  */
> > public class DojoFilter implements Filter {
> >
> >  private static Log log = LogFactory.getLog (DojoFilter.class);
> >
> >  private final static String DEFAULT_INCLUDES = "*.html";
> >
> >  private final static String DEFAULT_EXCLUDES = "";
> >
> >  public static final String INCLUDES_PARAMETER="includes";
> >
> >  public static final String EXCLUDES_PARAMETER="excludes";
> >
> >  public static final String
> > ACTION_SERVLET_NAME_PARAMETER="action_servlet_name";
> >
> >  public static final String _REQUEST_PARSED =
> > "org.appfuse.webapp.request.parsed";
> >
> >  private String[] excludes;
> >
> >  private String[] includes;
> >
> >  private String actionServletName = "action";
> >
> >  private RequestDispatcher actionServletRequestDispatcher;
> >
> >   /**
> >    * Read the includes/excludes paramters and set the filter
> accordingly.
> >    */
> >   public void init(FilterConfig filterConfig)
> >   {
> >    String includesParam =
> > filterConfig.getInitParameter(INCLUDES_PARAMETER);
> >     if (StringUtils.isEmpty(includesParam))
> >     {
> >       includes = parsePatterns(DEFAULT_INCLUDES);
> >     }
> >     else
> >     {
> >       includes = parsePatterns(includesParam);
> >     }
> >     String excludesParam =
> > filterConfig.getInitParameter(EXCLUDES_PARAMETER);
> >     if ( StringUtils.isEmpty(excludesParam))
> >     {
> >       excludes = parsePatterns(DEFAULT_EXCLUDES);
> >     }
> >     else
> >     {
> >       excludes = parsePatterns(excludesParam);
> >     }
> >     String actionServletNameParam =
> > filterConfig.getInitParameter(ACTION_SERVLET_NAME_PARAMETER);
> >     if (StringUtils.isNotEmpty(actionServletNameParam))
> >     {
> >       actionServletName = actionServletNameParam;
> >     }
> >     ServletContext servletContext = filterConfig.getServletContext();
> >     actionServletRequestDispatcher =
> > servletContext.getNamedDispatcher(actionServletName);
> >     if (actionServletRequestDispatcher == null)
> >     {
> >       log.error("No action servlet named [" + actionServletName + "]
> could
> > be found. Please check configuration in web.xml.");
> >       throw new RuntimeException("Could not instantiate dojo filter:
> no
> > valid action servlet specified, or action servlet not found.");
> >     }
> >   }
> >
> >   private String[] parsePatterns(String delimitedPatterns)
> >   {
> >     //make sure no patterns are repeated.
> >     Set patternSet =
> > org.springframework.util.StringUtils.commaDelimitedListToSet
> (delimitedPatterns);
> >     String[] patterns = new String[patternSet.size()];
> >     int i = 0;
> >     for (Iterator iterator = patternSet.iterator(); iterator.hasNext
> ();
> > i++)
> >     {
> >       //no trailing/leading white space.
> >       String pattern = (String) iterator.next();
> >       patterns[i] = pattern.trim();
> >     }
> >     return patterns;
> >   }
> >
> >   public void doFilter(ServletRequest request, ServletResponse
> response,
> >                        FilterChain chain) throws IOException,
> > ServletException {
> >
> >    if (request.getAttribute(_REQUEST_PARSED) != null)
> >    {
> >      chain.doFilter(request, response);
> >      return;
> >    }
> >
> >    final HttpServletRequest req = (HttpServletRequest) request;
> >    final HttpServletResponse res = (HttpServletResponse) response;
> >
> >    UrlPathHelper urlPathHelper = new UrlPathHelper();
> >    String path = urlPathHelper.getPathWithinApplication(req);
> >    boolean pathExcluded = PatternMatchUtils.simpleMatch(excludes,
> path);
> >    boolean pathIncluded = PatternMatchUtils.simpleMatch(includes,
> path);
> >
> >    if (pathIncluded && ! pathExcluded)
> >    {
> > //     req.setAttribute (_REQUEST_PARSED, Boolean.TRUE);
> >      actionServletRequestDispatcher.forward(req, res);
> >      return;
> >    }
> >
> >    chain.doFilter(req, res);
> >   }
> >
> >   public void destroy() {
> >     actionServletRequestDispatcher = null;
> >   }
> > }
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
> --
> View this message in context:
> 
http://www.nabble.com/Changing-default-extension-from-*.html-to-*.---tf2307780s2369.html#a8742724
> Sent from the AppFuse - User mailing list archive at 
Nabble.com<http://nabble.com/>
> .
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to