image from servlets in version 2.0?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

image from servlets in version 2.0?

havarti
This post was updated on .
I am using shadowbox in a JSP application and my image targets are jsp servlets that don't have an image extension (but are JPGs). They worked fine in version 1.0 but are broken in 2.0. 

Error from Firebug console:

gallery[i] is undefined
[Break on this error] if(gallery[i].player == 'unsupported'){ // don't support this at all

I then tried forcing the type to image using the player setting in the rel tag, but it then gave me the following error:

Exception... "'Unknown player 'img'' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no

Here is what my servlet call looks like:

<a href="/myApp/servlet/com.myApp.image.ImageView?dbid=EH2xT2uzmtM7_OXs86yt3cPdoPhfwF4J&width=600&height=600&preview=true&defaultIcon=asp/images/defaultPreviewIcon.gif" rel="shadowbox[previews];player='img';" title="House_Of_Ponder_by_er0k.jpg"/>

Any info on what I can do to use this type of servlet is greatly appreciated.



Reply | Threaded
Open this post in threaded view
|

Re: image from servlets in version 2.0?

mjijackson
Administrator

Are you loading the image player?

Reply | Threaded
Open this post in threaded view
|

Re: image from servlets in version 2.0?

havarti

Yes I did, but here is the code for loading shadowbox in case you see something that I didn't. I also verified with firebug that all the directories (lang,player,skin) all were found:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="shadowbox-jquery.js"></script>
<script type="text/javascript" src="shadowbox.js"></script>
<script type="text/javascript">

Shadowbox.loadSkin('classic', 'skin'); // use the "classic" skin
Shadowbox.loadLanguage('en', 'lang'); // use the English language
Shadowbox.loadPlayer(['img', 'qt'], 'player'); // use img and qt players

$(document).ready(function(){

  Shadowbox.init();
}); 

</script>
Reply | Threaded
Open this post in threaded view
|

Re: image from servlets in version 2.0?

mjijackson
Administrator
Try checking out the Firebug DOM tab. Do you see the img/qt classes defined on the Shadowbox object? It would help if you could post a link to a sample page because I can't reproduce the error here.
Reply | Threaded
Open this post in threaded view
|

Re: image from servlets in version 2.0?

Wizzud
In reply to this post by havarti
Try changing your rel attribute from ...

rel="shadowbox[previews];player='img';"

...to...

rel="shadowbox[previews];player=img"

ie. take out the single quotes around img, and remove the trailing semi-colon
Combine literacy with curiosity and a whole world of information opens up to you
Reply | Threaded
Open this post in threaded view
|

Re: image from servlets in version 2.0?

havarti
Yup, that worked and it initiates the correct player and my image servlet displays. Thanks for noticing that.
Reply | Threaded
Open this post in threaded view
|

Re: image from servlets in version 2.0?

havarti
In reply to this post by mjijackson
Turned out to be a syntax error in the "rel" settings from the link. I can instantiate the correct player now. I am curious though if there are any plans to determine the player type from the content type setting the file header instead of parsing the filename for the extension? This would help those of us who create content dynamically.

Thanks alot for taking a look at my issue. You have a great looking script and I hope I can incorporate it into our product.
Reply | Threaded
Open this post in threaded view
|

Re: image from servlets in version 2.0?

mjijackson
Administrator

As far as I know, there's not very much that you can do with headers and JavaScript. The only way for JavaScript to get header information from a server is through the XMLHttpRequest object, and that only works on the local domain. Shadowbox provides the ability to load content from all over the place, so the header information will not always be available. The automatic content-type detection already works for 99% of Shadowbox users. The other 1% can use the player attribute to coerce Shadowbox when the automatic detection fails. I don't see any need to complicate things.

Reply | Threaded
Open this post in threaded view
|

Re: image from servlets in version 2.0?

havarti
Yeah, I can see your point.

Great script and thank you very much for the support.