morciuch 2003/01/27 20:46:21
Modified: docs/site changes.html
src/java/org/apache/jetspeed/modules/actions/portlets
JspPortletAction.java QuestionnaireAction.java
src/java/org/apache/jetspeed/portal/portlets JspPortlet.java
webapp/WEB-INF/conf demo-portlets.xreg
xdocs changes.xml
Added: webapp/WEB-INF/templates/jsp/portlets/html
JetspeedQuestionnaireConfirmation.jsp
Log:
Fixed setTemplate functionality in JspPortletAction + added example of using
setTemplate in the questionnaire portlet (see Bugzilla bug# 16443)
Revision Changes Path
1.103 +3 -0 jakarta-jetspeed/docs/site/changes.html
Index: changes.html
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/docs/site/changes.html,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -r1.102 -r1.103
--- changes.html 22 Jan 2003 16:27:41 -0000 1.102
+++ changes.html 28 Jan 2003 04:46:20 -0000 1.103
@@ -133,6 +133,9 @@
</li>
-->
<li>
+ Fixed - Bug # 16443 - 2003/01/27 - Corrected the setTemplate functionality in
JspPortletAction (MO)
+</li>
+<li>
Fixed - Bug # 16325 - 2003/01/21 - Updated FAQ (MO)
</li>
<li>
1.3 +3 -2
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/JspPortletAction.java
Index: JspPortletAction.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/JspPortletAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JspPortletAction.java 27 Sep 2002 20:46:15 -0000 1.2
+++ JspPortletAction.java 28 Jan 2003 04:46:21 -0000 1.3
@@ -60,6 +60,7 @@
// Jetspeed stuff
import org.apache.jetspeed.portal.Portlet;
+import org.apache.jetspeed.portal.portlets.JspPortlet;
import org.apache.jetspeed.services.rundata.JetspeedRunData;
import org.apache.jetspeed.util.PortletSessionState;
@@ -92,7 +93,7 @@
*/
public void setTemplate(RunData data, String template)
{
- data.getRequest().setAttribute("template", template);
+ data.getRequest().setAttribute(JspPortlet.TEMPLATE, template);
}
/**
1.3 +7 -2
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/QuestionnaireAction.java
Index: QuestionnaireAction.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/QuestionnaireAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- QuestionnaireAction.java 26 Jan 2003 05:04:03 -0000 1.2
+++ QuestionnaireAction.java 28 Jan 2003 04:46:21 -0000 1.3
@@ -211,8 +211,13 @@
// send the message
Transport.send(message);
- rundata.setMessage("Email successfully sent");
+ // Display confirmation
+ rundata.getRequest().setAttribute("email", emailBody.toString());
+ String confirmTemplate =
portlet.getPortletConfig().getInitParameter("confirm.template",
+
"JetspeedQuestionnaireConfirmation.jsp");
+ this.setTemplate(rundata, confirmTemplate);
+ rundata.setMessage("Email successfully sent");
}
catch (Exception e)
{
1.7 +48 -34
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/JspPortlet.java
Index: JspPortlet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/JspPortlet.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JspPortlet.java 24 Oct 2002 14:59:25 -0000 1.6
+++ JspPortlet.java 28 Jan 2003 04:46:21 -0000 1.7
@@ -62,10 +62,7 @@
import org.apache.turbine.modules.ActionLoader;
// Jetspeed portal
-import org.apache.jetspeed.portal.Portlet;
-import org.apache.jetspeed.portal.portlets.AbstractInstancePortlet;
import org.apache.jetspeed.portal.PortletException;
-import org.apache.jetspeed.portal.PortletConfig;
import org.apache.jetspeed.services.template.TemplateLocatorService;
// Ecs
@@ -81,37 +78,27 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Santiago Gala</a>
*/
public class JspPortlet extends AbstractInstancePortlet
-
{
+ public static final String TEMPLATE = "template";
+
/**
By default the data is non cacheable
*/
public void init() throws PortletException
{
- setCacheable( false );
+ setCacheable(false);
}
- public ConcreteElement getContent( RunData rundata )
+ public ConcreteElement getContent(RunData rundata)
{
String template = "";
- try {
+ try
+ {
- //
- // gets the jsp page from the xreg configuration
- // NOTE: wouldn't it be better to get the param from the PSML?
- //
- template = getPortletConfig().getInitParameter("template");
-
- //we use the template locator service to translate the template
- TemplateLocatorService lserv =
(TemplateLocatorService)TurbineServices.getInstance()
- .getService(TemplateLocatorService.SERVICE_NAME);
- String locatedTemplate = lserv.locatePortletTemplate( rundata,
- template );
-
- JspService service = (JspService)TurbineServices.getInstance()
+ JspService service = (JspService) TurbineServices.getInstance()
.getService(JspService.SERVICE_NAME);
// this is only necessary if we ddon't run in a JSP page environment
// but better be safe than sorry...
@@ -123,31 +110,58 @@
// Add js_peid out of convenience
rundata.getRequest().setAttribute("js_peid", this.getID());
- // Retrieve and execute the action object
- String actionName = getPortletConfig().getInitParameter("action");
- if (actionName != null)
+ // Retrieve and execute the action object
+ String actionName = getPortletConfig().getInitParameter("action");
+ if (actionName != null)
{
- try
+ try
{
if (Log.getLogger().isDebugEnabled())
{
Log.debug("JspPorlet: Executing action [" + actionName + "]
for portlet [" + this.getName() + "]");
}
- ActionLoader.getInstance().exec(rundata, actionName);
- }
- catch( Exception e)
+ ActionLoader.getInstance().exec(rundata, actionName);
+ }
+ catch (Exception e)
{
- Log.error(e);
- }
- }
-
+ Log.error(e);
+ }
+ }
+
+ // either the action selected the template, or use the default template
+ // defined in the registry
+ if (rundata.getRequest().getAttribute(TEMPLATE) != null)
+ {
+ template = (String) rundata.getRequest().getAttribute(TEMPLATE);
+ if (Log.getLogger().isDebugEnabled())
+ {
+ Log.debug("JspPorlet: Template switched per request attribute
to [" + template + "] for portlet [" +
+ this.getName() + "]");
+ }
+ }
+ else
+ {
+ //
+ // gets the jsp page from the xreg configuration
+ // NOTE: wouldn't it be better to get the param from the PSML?
+ //
+ template = getPortletConfig().getInitParameter(TEMPLATE);
+ }
+
+ //we use the template locator service to translate the template
+ TemplateLocatorService lserv = (TemplateLocatorService)
TurbineServices.getInstance()
+ .getService(TemplateLocatorService.SERVICE_NAME);
+ String locatedTemplate = lserv.locatePortletTemplate(rundata, template);
+
// handle request
service.handleRequest(rundata, locatedTemplate);
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
String message = "JspPortlet: Could not include the following JSP Page:
" + template + " : " + e.getMessage();
- Log.error( message, e );
- return new StringElement( message );
+ Log.error(message, e);
+ return new StringElement(message);
}
return new ElementContainer();
1.31 +1 -0 jakarta-jetspeed/webapp/WEB-INF/conf/demo-portlets.xreg
Index: demo-portlets.xreg
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/demo-portlets.xreg,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- demo-portlets.xreg 17 Jan 2003 18:39:54 -0000 1.30
+++ demo-portlets.xreg 28 Jan 2003 04:46:21 -0000 1.31
@@ -441,6 +441,7 @@
about their Jetspeed-powered sites</description>
</meta-info>
<parameter name="template" value="JetspeedQuestionnaire.jsp"
hidden="true" cachedOnName="true" cachedOnValue="true"/>
+ <parameter name="confirm.template"
value="JetspeedQuestionnaireConfirmation.jsp" hidden="true"/>
<parameter name="action" value="portlets.QuestionnaireAction"
hidden="true" cachedOnName="true" cachedOnValue="true"/>
<parameter name="q1" value="" type="style" hidden="false"
cachedOnName="true" cachedOnValue="true">
<meta-info>
1.1
jakarta-jetspeed/webapp/WEB-INF/templates/jsp/portlets/html/JetspeedQuestionnaireConfirmation.jsp
Index: JetspeedQuestionnaireConfirmation.jsp
===================================================================
<%@ taglib uri='/WEB-INF/templates/jsp/tld/template.tld' prefix='jetspeed' %>
<%
String email = (String) request.getAttribute("email");
%>
<p>
The following email has been successfully sent:
<P>
<B><%=email%></B>
<P>
<FORM METHOD="POST">
<INPUT TYPE="SUBMIT" VALUE="Continue">
</FORM>
<P>
Thank you again you for your contribution!
<P>
Jetspeed Development Team
<P>
<IMG SRC="<jetspeed:contentUri href="images/jetspeed-powered.gif"/>">
1.120 +4 -1 jakarta-jetspeed/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/xdocs/changes.xml,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -r1.119 -r1.120
--- changes.xml 22 Jan 2003 16:27:42 -0000 1.119
+++ changes.xml 28 Jan 2003 04:46:21 -0000 1.120
@@ -23,6 +23,9 @@
</li>
-->
<li>
+ Fixed - Bug # 16443 - 2003/01/27 - Corrected the setTemplate functionality in
JspPortletAction (MO)
+</li>
+<li>
Fixed - Bug # 16325 - 2003/01/21 - Updated FAQ (MO)
</li>
<li>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>