on 03-22-2004 2:43 PM
Hi,
i'm trying to display a PDF file in the browser but i cannot change the Content-type display. I know it works in Tomcat but in the Portal there's a lot of generated code that restrict me from diplaying a PDF to the client.
How can i remove the Portal generated code??
Thanks,
Marjolaine
You need to make you class extend from AbstractPortalComponent (instead of dynpage or similar) and overwrite the onNodeReady method.
Cutting in example from iviewstudio.com thread, but I think you need to set the content type on the response (but you should see the general picture)
import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
import com.sapportals.portal.prt.pom.IEvent;
public class XMLComponent extends AbstractPortalComponent
{
protected void doOnNodeReady(IPortalComponentRequest arg0, IEvent arg1) {
try {
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
// modify the empty document here, something like this:
Element root = doc.createElement("myRoot");
doc.appendChild(root);
HttpServletResponse response = arg0.getServletResponse(true);
DOMSource domSource = new DOMSource(doc);
StreamResult result = new StreamResult(response.getOutputStream());
Transformer copyTransformer = TransformerFactory.newInstance().newTransformer();
copyTransformer.transform(domSource,result);
} catch (Exception e) {
arg0.getLogger().severe(e,"while putting out my xml");
}
}
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
{
// will never be invoked, since 'getServletResponse(true)' (see above)
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.