You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Paul Benedict <pa...@yahoo.com> on 2006/08/15 02:14:13 UTC

TagUtils.getModuleConfig

I tried to use the Spring framework to automatically map *.html to a special directory of non-application pages. Site mesh filters the returned markup and applies my decorator. The decorator contains struts tag libraries to render a search box form. Okay.. got it so far?

Well I am not going through the Struts controller for *.html extension. I was hoping I could still render forms and all, but I guess that's not the case, correct? In any event, I found something interesting...

The first version of getModuleConfig is suppose to return null if the default module cannot be found. But it delegates to an overloaded version which throws a NPE if it is null. Isn't that a bug? If it didn't throw an NPE, do you think I would be rendering just fine?

Paul

/**
 * Return the default ModuleConfig object if it exists, null if
 * otherwise.
 *
 * @param pageContext The page context.
 * @return the ModuleConfig object
 */
public ModuleConfig getModuleConfig(PageContext pageContext) {
    return getModuleConfig(null, pageContext);
}

/**
 * Return the specified ModuleConfig object for the given prefix if it
 * exists, otherwise a NullPointerException will be thrown.
 *
 * @param module      The module prefix
 * @param pageContext The page context.
 * @return the ModuleConfig object
 * @throws NullPointerException Thrown when module cannot be found
 */
public ModuleConfig getModuleConfig(String module, PageContext pageContext) {
    ModuleConfig config =
        ModuleUtils.getInstance().getModuleConfig(module,
            (HttpServletRequest) pageContext.getRequest(),
            pageContext.getServletContext());

    // ModuleConfig not found
    if (config == null) {
        throw new NullPointerException("Module '" + module + "' not found.");
    }

    return config;
}


 		
---------------------------------
How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.