Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
ATL Control Embedded in JSP Page

ATL Control Embedded in JSP Page

2003-07-30       - By Chanian, Raj

 Back
Hi,

Hi All,

I have my ATL control working in a full browser window, embedded in a HTML
page.

However when I embed it into HTML HEAD of JSP page the control works fine,
provides Print Preview but then the screen freezes and then I can do nothing
with the browser.

What extra interfaces do I need to add to my control so that it integrates
perfectly with JSP/HTML without crashing the browser.

Our solution targets IE5.5 browser hence the ATL control to tap into IE's
native COM interfaces for implementing Print Preview.

Regards,

Raj Chanian

-- --Original Message-- --
From: Chanian, Raj
Sent: 29 July 2003 12:21
To: 'Discussion related to the Active Template Library and COM development'
Subject: RE: [ATL] Debug Assertion failed in atlbase.h Line 474


Thanks Maxine,

I think it was because the code below which WORKS in a normal browser
window, does not work in a modal dialog window. It threw the assert between
the following two lines of code

//QueryService for WebBrowser
       hresult= spIServiceProvider->QueryService(SID_SWebBrowserApp,
IID_IWebBrowser, (void**)&spIWebBrowser2);

//Errs here! Possibly due to null value on constructor for spIWebBrowser2

       //Get IDispatch Interface for Document
       hresult= spIWebBrowser2->get_Document(&spIDispatch);

I got it to work by using window.open instead of window.showModalDialog in
my javascript. And grabbed arguments to opened window by using
window.document.getelementbyid("openedwindowelement")=
window.opener.document.getelementbyid("openerwindowelement");

The question I have is what com interfaces are not supported in the dialog
window compared to full browser window. And what tweak on this function can
be made to make it work in a dialog window?

Below is the function that encapsulates this behaviour.


STDMETHODIMP CPreviewer::PreviewDefault()
{
       HRESULT hresult=S_OK;

       try
       {
       //Smart Pointer Declarations
       CComPtr<IOleContainer> spIOleContainer;
       CComPtr<IServiceProvider> spIServiceProvider;
       CComPtr<IWebBrowser2> spIWebBrowser2;
       CComPtr<IDispatch> spIDispatch;
       CComPtr<IHTMLDocument2> spIHTMLDocument2;
       CComPtr<IOleCommandTarget> spIOleCommandTarget;

       //Member of CComControlBase::m_spClientSite
       //A pointer to the control's client site within the container
       //CComPtr<IOleClientSite> m_spClientSite;

       //Get IOleContainer
       hresult= m_spClientSite->GetContainer(&spIOleContainer);

       //QueryInterface for IServiceProvider
       hresult= spIOleContainer->QueryInterface(IID_IServiceProvider,
(void**)&spIServiceProvider);

       //QueryService for WebBrowser
       hresult= spIServiceProvider->QueryService(SID_SWebBrowserApp,
IID_IWebBrowser, (void**)&spIWebBrowser2);

       //Get IDispatch Interface for Document
       hresult= spIWebBrowser2->get_Document(&spIDispatch);

       //QueryInterface for IHTMLDocument2
       hresult= spIDispatch->QueryInterface(IID_IHTMLDocument2,
(void**)&spIHTMLDocument2);

       //QueryInterface for IOleCommandTarget
       hresult= spIHTMLDocument2->QueryInterface(IID_IOleCommandTarget,
(void**)&spIOleCommandTarget);

       //Do not pass a custom template as we are using default template
       //Invoke PrintPreview
       hresult= spIOleCommandTarget->Exec(&CGID_MSHTML, IDM_PRINTPREVIEW,
NULL, NULL, NULL);


       //If No Errors Return Default Status
       return S_OK;
       }
       catch(...)
       {
               //Need to Expand Here
               //return E_FAIL;
               //HRESULT May Differ Here
               ATLASSERT(0);
               return hresult;
       }

}



-- --Original Message-- --
From: LABELLE, Maxime [mailto:mlabelle@(protected)]
Sent: 28 July 2003 13:17
To: ATL@(protected)
Subject: Re: [ATL] Debug Assertion failed in atlbase.h Line 474

Oops!

> He already has. :-)

That's my mistake. Sorry. I overlooked the subject.
OK, well, here's what I've got at the specified line:


472:    _NoAddRefReleaseOnCComPtr<T>* operator->() const
473:    {
474:            ATLASSERT(p!=NULL);
475:            return (_NoAddRefReleaseOnCComPtr<T>*)p;
476:    }

That seems pretty clear to me. It is illegal to dereference
a null pointer. So the question is why is the smart pointer
containing a null pointer ?

I see several options:

1. the p member has never been assigned a value other than the default
(431).
2. .Release() has already been called on the smart pointer (452).
3. .operator &() has been called by passing the smart-pointer in one of the
  returned arguments of ::CoCreateInstance, but the ::CoCreateInstance call
  failed for some reason. Lookup the resulting HRESULT (470).
4. .Attach() has been called with a null pointer (516).
5. .Detach() has been explicitely called (521).
6. .CoCreateInstance() failed. Lookup the resulting HRESULT (705).

Cheers.
Maxime.


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----
You can read messages from the ATL archive, unsubscribe from ATL, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.
***
To unsubscribe, either go to http://discuss.develop.com and use the Web
interface, or send an email from the *subscribed* account to:
listserv@(protected), with a *message body* of: unsubscribe atl

This e-mail and any attachment is for authorised use by the intended recipient
(s) only.  It may contain proprietary material, confidential information and/or
be subject to legal privilege.  It should not be copied, disclosed to, retained
or used by, any other party.  If you are not an intended recipient then please
promptly delete this e-mail and any attachment and all copies and inform the
sender.  Thank you.

===========================================================================
To unsubscribe: mailto listserv@(protected) with body: "signoff JSP-INTEREST".
For digest: mailto listserv@(protected) with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com



©2008 junlu.com - Jax Systems, LLC, U.S.A.