Hello there, just yesterday, I was asked to make sure an image read from the database gets always a fixed URL. Thus
(i) I replaced my original HTML code === <wo:if condition="$sess.currentLanguageEnglish"> <wo:img data = "$sess.currentMarket.marketBannerDataEN" mimeType = "$sess.currentMarket.marketBannerMIMEEN" /> </wo:if><wo:else> <wo:img data = "$sess.currentMarket.marketBannerDataCZ" mimeType = "$sess.currentMarket.marketBannerMIMECZ" /> </wo:else> === by simple === <img src="$bannerImageURL"/> === (ii) in the component code, I've added a method === String bannerImageURL() { NSData id=sess.currentLanguageEnglish?sess.currentMarket.marketBannerDataEN:sess.currentMarket.marketBannerDataCZ def url=context.directActionURLForActionNamed('banner',new NSDictionary([mkpk:sess.currentMarket.primaryKeyStringValue, size:id.length, lang:sess.currentLanguageEnglish?'EN':'CZ']), NO/*session ID*/) println "BANNERURL: $url" return url } === (iii) I've added an appropriate direct action === WOActionResults bannerAction() { def mpk=request().formValueForKey('mkpk'),lang=request().formValueForKey('lang') println "DA: reading $lang banner image for market $mpk..." ERXEC ec=ERXEC.newEditingContext() DBMarket market=EOUtilities.objectWithPrimaryKeyValue(ec,'DBMarket',mpk as Integer) def mime=market."marketBannerMIME$lang",data=market."marketBannerData$lang" WOResponse wor=new WOResponse() wor.setHeader(mime,"content-type") wor.setContent(data) wor } === Most time, it works just as presumed, I'm getting logs like === BANNERURL: /cgi-bin/WebObjects/REBOISx.woa/wa/banner?size=102614&mkpk=1000001&lang=CZ ... DA: reading CZ banner image for market 1000001... === and the banner displays all right. So far so good. Now, though, I have checked the server logs, and there's lots of exceptions there like === DA: reading null banner image for market null... 09:01:51.619 ERROR Exception caught: null Extra info: { ... "Headers" = { "remote_host" = "172.19.18.1"; "server_software" = "Apache/2.2.24 (Unix) mod_ssl/2.2.24 OpenSSL/0.9.8y"; "user-agent" = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.2.5 (KHTML, like Gecko) Version/8.0.2 Safari/600.2.5"; "document_root" = "/Library/WebServer/Documents/rebois.cmkbk.cz"; "server_name" = "rebois.cmkbk.cz"; "accept" = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; "x-webobjects-adaptor-version" = "Apache"; "remote_addr" = "172.19.18.1"; "host" = "rebois.cmkbk.cz"; "x-webobjects-request-id" = "5475dfe90000004300001e15"; "x-webobjects-request-method" = "GET"; "server_admin" = "ad...@example.com"; "server_port" = "80"; "accept-encoding" = "gzip, deflate"; "remote_port" = "50420"; "script_filename" = "/cgi-bin"; "accept-language" = "cs-cz"; "connection" = "close"; }; "URL" = "/cgi-bin/WebObjects/REBOISx.woa/1/wa/banner?size=107683&mkpk=1000001&lang=CZ%22"; } //log:er.extensions.appserver.ERXApplication [WorkerThread4] IllegalArgumentException: Attempt to insert null object into an com.webobjects.foundation.NSDictionary. at com.webobjects.foundation.NSDictionary.<init>(NSDictionary.java:254) at com.webobjects.eoaccess.EOUtilities._primaryKeyDictionary(EOUtilities.java:372) at com.webobjects.eoaccess.EOUtilities.objectWithPrimaryKeyValue(EOUtilities.java:431) ... skipped 3 stack elements at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:43) at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124) at app.DirectAction.bannerAction(DirectAction.groovy:22) === It's self-evident why the mangled URL fails, but has anybody an idea where the URL might come from? In whole my log, there is *no* "BANNERURL: /cgi-bin/WebObjects/REBOISx.woa/1" -- not once. All "BANNERURL" logs are OK (and followed by one OK "DA:..." log, too). These "1/wa/...&..." URLs must come from somewhere else ... well I don't know, but *not* from my bannerImageURL method :-O Can you see where they might come from? Would be grateful for any advice, OC _______________________________________________ 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: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com