Hi Farrukh, On 26/06/2010, at 10:56 PM, Farrukh Ijaz wrote:
> The worequest class is er.extensions.appserver.ERXRequest > The wocontext raises NullPointerException as request.context() returns null. Sorry - better if do this in one of your components: @Override public void appendToResponse(WOResponse response, WOContext context) { super.appendToResponse(response, context); NSLog.out.appendln("request class:" + context.request().getClass().getName()); NSLog.out.appendln("context class:" + context.getClass().getName()); NSLog.out.appendln(); } This should confirm that you're getting com.webobjects.jspservlet.WOServletContext at runtime which isn't what you want with Wonder. Anyway, I've just committed the fix for the original commit for WONDER-389 (which obviously didn't get tested properly at the time). I've tested this with both WO5.3.3 and WO5.4.3 and in both cases _rewriteURL gets called appropriately allowing you to customise the url as desired. As a work-around (prior to the updated build being available) you can do the following in your ERXApplication subclass: @Override public void installPatches() { super.installPatches(); // if you're using WO5.3.3 setContextClassName(ERXWOServletContext.class.getName()); // if you're using WO5.4.3 setContextClassName(ERXWOServletContext54.class.getName()); } So to rework your example to do the rewriting you could do the following... ------------------------------------------ @Override public WOResponse dispatchRequest(WORequest request) { String urlAlias = request.stringFormValueForKey("_alias"); if (!ERXStringUtilities.stringIsNullOrEmpty(urlAlias)) { ERXThreadStorage.takeValueForKey(urlAlias, "url._alias"); } return super.dispatchRequest(request); } // and to customise the urls I'd do something like... @Override public String _rewriteURL(String url) { String resultURL = url; // your custom rules here String urlAlias = ERXThreadStorage.valueForKey("url._alias"); if (ERXStringUtilities.stringIsNullOrEmpty(urlAlias)) { /* either */ resultURL = resultURL.replace(servletConnectURL(), urlAlias); /* or, in case of multi-domain hosting */ String appBundleName = applicationName() + ".woa"; int index = url.indexOf(appBundleName); if (index >= 0) { index += appBundleName.length(); resultURL = urlAlias + resultURL.substring(index); } } return resultURL; } > > On 2010-06-26, at 2:03 PM, Lachlan Deck wrote: > >> Hi Farrukh, >> >> On 26/06/2010, at 2:05 PM, Farrukh Ijaz wrote: >> >>> I don't know why installPatches() didn't bring the change. Although I'm >>> using Wonder's latest stable release so the change mentioned in the >>> WONDER-389 should be reflected. >> >> So are you using WO5.3.3 or WO5.4.3? >> >> Well, let's confirm a few things first: >> >> @Override >> public WOResponse dispatchRequest(WORequest request) { >> LOG.warn("worequest class:" + request.getClass().getName()); >> LOG.warn("wocontext class:" + request.context().getClass().getName()); >> ... >> } >> >> What do you get? >> >>> However, I did my work around and thought to share with you as I found it >>> to be flexible and dynamic and perhaps wonder team could implement >>> something like this. <...snip custom application code...> >> >> No. That's custom code. See below. >> >>> And defined following rewrite rules: >>> >>> RewriteRule ^/app/(.*)$ >>> /Application/WebObjects/MyApplication.woa/$1?_alias=/app [L,PT,QSA] >>> RewriteRule ^/xyz/(.*)$ >>> /Application/WebObjects/MyApplication.woa/$1?_alias=/xyz [L,PT,QSA] >>> RewriteRule ^/abc/(.*)$ >>> /Application/WebObjects/MyApplication.woa/$1?_alias=/abc [L,PT,QSA] >>> >>> Now my application be accessed with three different aliases /app, /xyz and >>> /abc and the response contains the corresponding rewritten url. No need to >>> set the properties in the Properties for pattern and replace as that can be >>> directly controlled with apache config file. >>> >>> However, I would like to know I've implemented this change at right place >>> or there is any other method which more appropriate such as _rewriteURL but >>> that is still not working for me. >> >> Yes, _rewriteURL is intended to be overridden by your subclasses for custom >> rewrite rules. with regards, -- Lachlan Deck _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com