Hi,
I am getting a weird behaviour with StaticFilter. The filter itself is not
getting initialized. So I renamed it as DojoFilter and now it gets
initialized!!. But doFilterInternal() and initFilterBean() methods are not
called in that class and hence it is never applied at all.
I am using 4 dojo controls datepicker, tab, tree ,and richtext editor. The
tree is rendered without any error!!!! The other 3 result in the error
There is no Action mapped for namespace
/struts/dojo/src/widget/templates........
Any ideas would be very helpful.
My JSP Page Code
-------
<s:datetimepicker name="todayDate" label="Format (yyyy-MM-dd)"
displayFormat="yyyy-MM-dd"/>
<s:tabbedPanel id="test" theme="ajax">
<s:div id="three" label="remote" theme="ajax" >
One Tab
</s:div>
<s:div id="three" label="remote" theme="ajax" >
Another tab
</s:div>
</s:tabbedPanel>
<s:tree id="ParentTree" label="Parent Tree" theme="ajax">
<s:treenode id="Node1" label="Node1" theme="ajax" />
<s:treenode id="Node2" label="Node2" theme="ajax">
<s:treenode id="Node21" label="Node21" theme="ajax"/>
<s:treenode id="Node22" label="Node22" theme="ajax" />
</s:treenode>
<s:treenode id="Node3" label="Node3" theme="ajax"/>
</s:tree>
<s:textarea id="editor1" label="editor1" theme="ajax"/>
In my web.xml I have mentioned as given below at the beginning.
----------------
<filter>
<filter-name>dojoFilter</filter-name>
<filter-class>com.cpt.his.webapp.filter.DojoFilter</filter-class>
<init-param>
<param-name>includes</param-name>
<param-value>/scripts/dojo/*</param-value>
</init-param>
</filter>
-----------
<filter-mapping>
<filter-name>dojoFilter</filter-name>
<url-pattern>>/scripts/dojo/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
----------------
Filter Class Code
----------------
public class DojoFilter extends OncePerRequestFilter {
private final static String DEFAULT_INCLUDES = "*.html";
private final static String DEFAULT_EXCLUDES = "";
private static final String INCLUDES_PARAMETER = "includes";
private static final String EXCLUDES_PARAMETER = "excludes";
private static final String SERVLETNAME_PARAMETER = "servletName";
private String[] excludes;
private String[] includes;
private String servletName = null;
private static final Log log = LogFactory.getLog(StaticFilter.class);
/**
* Read the includes/excludes parameters and set the filter accordingly.
*/
public void initFilterBean() {
String includesParam =
getFilterConfig().getInitParameter(INCLUDES_PARAMETER);
log.debug("includesParam : " + includesParam);
if (StringUtils.isEmpty(includesParam)) {
includes = parsePatterns(DEFAULT_INCLUDES);
} else {
includes = parsePatterns(includesParam);
}
String excludesParam =
getFilterConfig().getInitParameter(EXCLUDES_PARAMETER);
if (StringUtils.isEmpty(excludesParam)) {
excludes = parsePatterns(DEFAULT_EXCLUDES);
} else {
excludes = parsePatterns(excludesParam);
}
// if servletName is specified, set it
servletName =
getFilterConfig().getInitParameter(SERVLETNAME_PARAMETER);
log.debug("servletName : " + servletName);
}
private String[] parsePatterns(String delimitedPatterns) {
//make sure no patterns are repeated.
Set patternSet =
org.springframework.util.StringUtils.commaDelimitedListToSet(delimitedPatterns);
log.debug("patternSet : " + patternSet);
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();
log.debug("pattern : " + pattern);
patterns[i] = pattern.trim();
}
return patterns;
}
/**
* This method checks to see if the current path matches includes or
excludes. If it matches includes and
* not excludes, it forwards to the static resource and ends the filter
chain. Otherwise, it forwards to the
* next filter in the chain.
*
* @param request the current request
* @param response the current response
* @param chain the filter chain
* @throws ServletException when something goes wrong
* @throws IOException when something goes terribly wrong
*/
public void doFilterInternal(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain) throws IOException,
ServletException {
UrlPathHelper urlPathHelper = new UrlPathHelper();
String path = urlPathHelper.getPathWithinApplication(request);
boolean pathExcluded = PatternMatchUtils.simpleMatch(excludes,
path);
boolean pathIncluded = PatternMatchUtils.simpleMatch(includes,
path);
log.debug("path : " + path);
log.debug("pathExcluded : " + pathExcluded);
log.debug("pathIncluded : " + pathIncluded);
if (pathIncluded && !pathExcluded) {
if (logger.isDebugEnabled()) {
logger.debug("Forwarding to static resource: " + path);
}
if (path.contains(".html")) {
response.setContentType("text/html");
}
RequestDispatcher rd =
getServletContext().getRequestDispatcher(path);
rd.include(request, response);
return;
}
log.debug("doFilterInternal servletName : " + servletName);
if (servletName != null) {
RequestDispatcher rd =
getServletContext().getNamedDispatcher(servletName);
rd.forward(request, response);
return;
}
chain.doFilter(request, response);
}
}
--------
mraible wrote:
>
> On Thu, Jun 19, 2008 at 9:35 PM, StrutsUser <[EMAIL PROTECTED]>
> wrote:
>
>>
>> Thanks Matt,
>> Did that and it works.
>> I also tried using the default extension (.html) itself as mentioned in
>> http://appfuse.org/display/APF/Ajax.
>> I copied the dojo related stuff to my /scripts directory and tested with
>> default extension. I am getting weired behaviour. Sometimes it works and
>> other times the same error is thrown. I would like to use
>> the default extension itself. Is there a complete workaround to use the
>> default .html extension as well as
>> DoJo.
>>
>
> I don't know. One thing you could try is no extension at all.
>
> http://raibledesigns.com/rd/entry/extensionless_urls_in_java_web
>
> Matt
>
>
>>
>> Thanks
>>
>> mraible wrote:
>> >
>> > You should be able to change the default extension by modifying
>> > struts.xml:
>> >
>> > <constant name="struts.action.extension" value="html"/
>> >
>> > You'll also need to change any references to .html in .xml and .jsp
>> files.
>> >
>> > Matt
>> >
>> > On Mon, Jun 16, 2008 at 10:09 PM, StrutsUser
>> <[EMAIL PROTECTED]
>> >
>> > wrote:
>> >
>> >>
>> >> Hi,
>> >> I am new to Affuse and need to use Dojo tags with Struts2. I am
>> getting
>> >> the
>> >> following error when I launch the JSP page
>> >> There is no Action mapped for namespace
>> /struts/dojo/src/widget/templates
>> >> and action name DatePicker
>> >> I searched in this forum and tried using the StaticFilter to solve
>> this
>> >> issue. But still it persists. Then I found a solution which specifies
>> >> that
>> >> the default .html mapping should be changed for Dojo tags to be used.
>> >> I am not sure how to change the default .html extension. Could you any
>> >> please explain how to change the extension and the configuration that
>> >> needs
>> >> to be done for it?
>> >> Any other solution to use Dojo tags with the same .html extension
>> would
>> >> also
>> >> be welcomed.
>> >>
>> >> Thanks
>> >> Ajay
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Changing-Affuse-default-.html-Extension-tp17877755s2369p17877755.html
>> >> Sent from the AppFuse - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >> For additional commands, e-mail: [EMAIL PROTECTED]
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Changing-Affuse-default-.html-Extension-tp17877755s2369p18022363.html
>> Sent from the AppFuse - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Changing-Affuse-default-.html-Extension-tp17877755s2369p18028117.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]