Interesting we should look at making those methods protected visibility, as this class is designed to be extended.
regards Malcolm Edgar On Wed, Jul 8, 2009 at 4:12 PM, Bob Schellink<[email protected]> wrote: > If you don't want to manually map JSP to Page classes it might be worth > looking at creating a customized ConfigService to handle the mapping. > > Look at subclassing XmlConfigService and overriding: > > public boolean isJspPage(String path); > public Class getPageClass(String path); > > > Here is rough untested example: > > public class MyConfigService extends XmlConfigService { > > private Map<String, Class> jspPathMap = new ConcurrentHashMap(); > > public boolean is isJspPage(String path) { > boolean isJsp = super.isJspPage(path); > if (!isJsp) { > isJsp = jspPathMap.containsKey(path); > } > return isJsp; > } > > public Class getPageClass(String path) { > Class cls = super.getPageClass(path); > > // Check if Page class could be found for the path > if (cls == null) { > > if (jspPathMap.containsKey(path)) { > cls = jspPathMap.get(path); > > } else { > Class cls = lookupPageClass(path); > > // If Page class was found for path, add it to jsp map > if (cls != null) { > jspPathMap.put(path, cls); > } > } > } > return cls; > } > > private String lookupPageClass(String path) { > // Add rules to map path to Page class, e.g: > for (int i = 0; i < pagePackages.size(); i++) { > String pagesPackage = pagePackages.get(i).toString(); > Class cls = getPageClass(String path, pagesPackage); > > if (cls != null) { > return cls.getName(); > } > } > return null; > } > } > > One problem with the above example is it uses a package private method so > this class will have to be placed in the "org.apache.click.service" package. > > See ConfigService JavaDoc[1] on how to configure it. > > Hope this helps. > > bob > > [1]:http://incubator.apache.org/click/docs/click-api/org/apache/click/service/ConfigService.html > > > ljnb01 wrote: >> >> Thanks Bob. But I really like auto mapping... >> >> >> sabob wrote: >>> >>> ljnb01 wrote: >>>> >>>> JSPs can be precompiled and commercial products do it. >>>> They don't deliver the JSPs - only the precompiled files. How would >>>> Click >>>> work in this case? >>>> >>>> I need to work this out since we have an old code base/scripts that >>>> automate >>>> pre-compiling jsps and now my click jsp's would not pass nightly build. >>>> Any >>>> directions? >>> >>> Interesting. To answer its probably worth explaining what is happening >>> under the hood. >>> >>> At application startup Click recursively scans through the web folder >>> looking for any JSP and htm templates. For every JSP and template found, >>> Click >>> attempts to find its matching Page class. It derives the Page class from >>> the >>> template name. This feature is called page-automapping[1]. >>> >>> Problem with compiled JSPs is that there is no JSP template Click can use >>> to lookup the corresponding Page class. >>> >>> My only suggestions at this point is to try and manually map the JSPs to >>> Page classes. >>> >>> For example: >>> >>> <pages package="com.myapp.page"> >>> <!-- map index.jsp to com.myapp.page.Home --> >>> <page path="index.jsp" classname="Home"/> >>> >>> <page path="customer/edit-customer.jsp" >>> classname="customer.EditCustomer"/> >>> <page path="customer/view-customers.jsp" >>> classname="customer.ViewCustomers"/> >>> </pages> >>> >>> >>> kind regards >>> >>> bob >>> >>> [1]: >>> http://incubator.apache.org/click/docs/user-guide/html/ch04s02.html#application-automapping >>> >>> >> >> >> ----- >> http://blogs.dengsoft.com/index.php/tech/ Java Technology Blog > > >
