Sorry for the length of this mail but everything here seems to be
flowing together.
For the past few days, I've been working with the CocoonPorlet. I've
noticed a few things which I'd like to bring to the list's attention.
1) Since JetSpeed doesn't *know* the content of the xml retrieved when
the CocoonPorlet is used, as opposed to the RSSPortlet where Castor does
its magic, I'm proposing that the CP(CocoonPortlet) use the <metainfo>
element for its title and description.
2) I've added an additional getPI() method which takes the RunData as a
parameter. This is because when you click 'Edit,' the CP can't find the
stylesheet parameter because the info is being passed along so the xml
is just displayed as a mass of text. This new method is called during
the getContent() process. If the initial getPI() returns null, we call
getPI(rundata) to see if the info is being passed through a Query
string.
3) To support #2, I changed the way the DefaultPorletControl creates
the 'Edit' link so that it also includes the parameters for the portlet.
4) Back to the CocoonPorlet, I commented out the call to the
PersistentDocument within getPI() as I don't see the need for it nor was
it working. Once commented out, it worked. I'll keep looking into that
one.
I think that's it but feel free to ping me with any questions. Also, is
there a plan for the cvs commits to be mailed to the list? That would
be cool and helpful.
josh
Index: DefaultPortletControl.java
===================================================================
RCS file:
/products/cvs/jetspeed/jetspeed/src/java/org/apache/jetspeed/portal/DefaultPortletControl.java,v
retrieving revision 1.25
diff -c -r1.25 DefaultPortletControl.java
*** DefaultPortletControl.java 2000/02/16 18:44:18 1.25
--- DefaultPortletControl.java 2000/02/21 23:10:53
***************
*** 65,71 ****
--- 65,74 ----
//turbine
import org.apache.turbine.util.*;
+ //java imports
+ import java.util.Enumeration;
+
/**
Represents a small dialog box within an HTML pages.
***************
*** 385,391 ****
if (url != null) {
uri.addQueryData( "url", url );
}
!
return uri;
}
--- 388,401 ----
if (url != null) {
uri.addQueryData( "url", url );
}
! Enumeration paramEnum =
this.getPortlet().getPortletConfig().getParameterNames();
! while (paramEnum.hasMoreElements()) {
! String key = (String)paramEnum.nextElement();
! String value =
this.getPortlet().getPortletConfig().getParameter(key);
! if (value != null) {
! uri.addQueryData( key, value );
! }
! }
return uri;
}
Index: CocoonPortlet.java
===================================================================
RCS file:
/products/cvs/jetspeed/jetspeed/src/java/org/apache/jetspeed/portal/portlets/CocoonPortlet.java,v
retrieving revision 1.6
diff -c -r1.6 CocoonPortlet.java
*** CocoonPortlet.java 2000/02/21 06:44:29 1.6
--- CocoonPortlet.java 2000/02/21 23:05:59
***************
*** 92,101 ****
private ElementContainer content = new ElementContainer()
.addElement( new
P().addElement("Error. Content not set.") );
! private ConcreteElement description = new P()
! .addElement("A generic Portlet
which converts a URL into HTML for display.");
! private ConcreteElement title = new P()
! .addElement("Cocoon Portlet");
private PortletConfig pc;
/**
--- 92,99 ----
private ElementContainer content = new ElementContainer()
.addElement( new
P().addElement("Error. Content not set.") );
! private ConcreteElement description = null;
! private ConcreteElement title = null;
private PortletConfig pc;
/**
***************
*** 119,125 ****
@version $Id: CocoonPortlet.java,v 1.6 2000/02/21 06:44:29 burton
Exp $
*/
public ConcreteElement getTitle() {
! return this.title;
}
--- 117,132 ----
@version $Id: CocoonPortlet.java,v 1.6 2000/02/21 06:44:29 burton
Exp $
*/
public ConcreteElement getTitle() {
! if ( this.getPortletConfig().getMetainfo().getTitle() == null
&&
! this.title == null ) {
!
! this.title = new StringElement("CocoonPortlet: Unknown
title");
!
! } else {
! this.title = new StringElement(
this.getPortletConfig().getMetainfo().getTitle() );
! }
!
! return this.title;
}
***************
*** 136,141 ****
--- 143,158 ----
@version $Id: CocoonPortlet.java,v 1.6 2000/02/21 06:44:29 burton
Exp $
*/
public ConcreteElement getDescription() {
+ if ( this.getPortletConfig().getMetainfo().getDescription() ==
null &&
+ this.description == null ) {
+
+ this.description = new StringElement("CocoonPortlet:
Unknown description");
+
+
+ } else {
+ this.description = new StringElement(
this.getPortletConfig().getMetainfo().getDescription() );
+ }
+
return this.description;
}
***************
*** 160,165 ****
--- 177,185 ----
try {
ByteArrayOutputStream bos= new ByteArrayOutputStream();
String pi = getPI();
+ if ( pi == null ) {
+ pi = getPI(rundata);
+ }
new SAXPIFilter(new PrintWriter(bos),(pi!=null),pi).print(
PersistentDocument.getInstance( rundata ).getEntry( pc.getURL()
).getURL() );
myContent=CocoonRenderer.transform( bos.toString() );
***************
*** 208,213 ****
--- 228,235 ----
*/
private String getPI() throws PortletException {
String style = (String)pc.getParameter("stylesheet");
+
+ /*
if (style == null) {
throw new PortletException("You need to specify a
stylesheet parameter for this portlet");
***************
*** 218,223 ****
--- 240,246 ----
} catch (IOException e) {
throw new PortletException( e.getMessage() );
}
+ */
String result =null;
***************
*** 231,236 ****
--- 254,281 ----
}
return result;
+ }
+
+ /**
+ Retrieve the PI passed within the RunData, if any
+
+ @author <A HREF+\="mailto:[EMAIL PROTECTED]">Josh Lucas</a>
+ */
+ private String getPI(RunData rundata) throws PortletException {
+ String style =
(String)rundata.getParameters().getString("stylesheet");
+
+ String result =null;
+
+ if (style!=null) {
+ StringBuffer res=new StringBuffer();
+ res.append("<?xml-stylesheet
href=\"").append(style).append("\" type=\"text/xsl\"?>");
+ res.append("<?cocoon-process type=\"xslt\"?>");
+ result=res.toString();
+
+ }
+
+ return result;
+
}
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]