cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dumon <br...@outerthought.org>
Subject Re: How to return a JDom document from a action?
Date Thu, 02 Feb 2006 14:53:48 GMT
On Thu, 2006-02-02 at 07:33 -0700, Jason Johnston wrote:
> Andre Juffer wrote:
> > Tino Breddin wrote:
> >> Hi,
> >>
> >> i tried your way:
> >>
> >> Request request = ObjectModelHelper.getRequest(objectModel);
> >>        Session session = request.getSession(true);
> >>        session.setAttribute("testparamsession",doc);
> >>
> >> Then:
> >> ${session.getAttribute('testparamsession')}
> > 
> > It should be something like
> > 
> > ${cocoon.session.getAttribute("testparamsession")}
> > 
> > assuming that you doc in the action contains a proper (J)DOM document
> > and the session was properly created.
> 
> Before we go any farther down this path, I don't think getting access to
> the object is the problem; it seemed pretty clear from his original
> example that he was already successfully getting access to the object,
> but it is just not being serialized in the way he expects.
> 
> I haven't tried it to verify, but I believe to have a DOM document get
> serialized into the XML stream you need to use <jx:out
> value="${request.getAttribute('testparamrequest')}" /> since the jx:out
> element treats certain objects like DOM documents specially whereas the
> ${} expression just calls toString() or something like that.

${} should also work. The problem is rather that it is a JDOM object,
not a DOM object. JXTemplate does not recognize JDOM objects.

What you could do is wrap the JDOM object in an object that implements
the XMLizable interface, that is:

org.apache.excalibur.xml.sax.XMLizable

this is a simply interface with just a toSAX method.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message