taylor 2004/08/10 23:40:24
Modified: fusion/src/java/org/apache/jetspeed/fusion/portal/portlets
JetspeedFusionPortlet.java
Log:
completing support for window state and mode integration for JSR 168 portlets
running in Fusion
help, edit, min, max, restore
originating from both j1 actions and j2 links, test keep state in tabs, and
combinations of max + modes
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS: If this change addresses a PR in the problem report tracking
CVS: database, then enter the PR number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system, such as NCSA,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to Apache by someone else; i.e.,
CVS: they sent us a patch or a new module, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.
Revision Changes Path
1.4 +85 -42
jakarta-jetspeed/fusion/src/java/org/apache/jetspeed/fusion/portal/portlets/JetspeedFusionPortlet.java
Index: JetspeedFusionPortlet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/fusion/src/java/org/apache/jetspeed/fusion/portal/portlets/JetspeedFusionPortlet.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JetspeedFusionPortlet.java 10 Aug 2004 04:15:38 -0000 1.3
+++ JetspeedFusionPortlet.java 11 Aug 2004 06:40:23 -0000 1.4
@@ -60,7 +60,15 @@
private static final String PORTLET_DEFINITION_NAME =
FusionResources.getString(FusionResources.PORTLET_DEFINITION_PARAMETER);
private static final String J2_ENTITY =
FusionResources.getString(FusionResources.J2_ENTITY);
- private static final String J1_HELP_ACTION =
FusionResources.getString(FusionResources.J1_HELP_ACTION);
+ private static final String J1_HELP_ACTION =
FusionResources.getString(FusionResources.J1_HELP_ACTION);
+ private static final String J1_RESTORE_ACTION =
FusionResources.getString(FusionResources.J1_RESTORE_ACTION);
+ private static final String J1_MINIMIZE_ACTION =
FusionResources.getString(FusionResources.J1_MINIMIZE_ACTION);
+ private static final String J1_MAXIMIZE_ACTION =
FusionResources.getString(FusionResources.J1_MAXIMIZE_ACTION);
+ private static final String J1_EDIT_ACTION =
FusionResources.getString(FusionResources.J1_EDIT_ACTION);
+ private static final String J1_PRINT_ACTION =
FusionResources.getString(FusionResources.J1_PRINT_ACTION);
+
+ public static final String FUSION_NAV_STATE =
"org.apache.jetspeed.fusion.navstate";
+
private NavigationalStateComponent navState;
private PortletWindowAccessor windowAccessor;
private PortletEntityAccessComponent entityAccess;
@@ -81,9 +89,10 @@
registryAccess = (PortletRegistryComponent)
Jetspeed.getComponentManager().getComponent(PortletRegistryComponent.class);
}
+
- public ConcreteElement getContent(RunData data)
- {
+ public ConcreteElement getContent(RunData data)
+ {
JetspeedRunData jrun = (JetspeedRunData)data;
HttpServletResponse response = data.getResponse();
String entityId = null;
@@ -105,7 +114,7 @@
}
int mode = jrun.getMode();
- syncNavigationalState(window, jrun, mode);
+ syncNavigationalState(window, jrun, mode, instance);
}
catch (Exception e)
@@ -117,7 +126,7 @@
// return dispatch(data, entityId);
}
- protected PortletWindow getPortletWindow(String id, String registryKey)
+ public PortletWindow getPortletWindow(String id, String registryKey)
{
PortletWindow window = windowAccessor.getPortletWindow(id);
if (window == null)
@@ -150,26 +159,6 @@
}
return window;
}
-/*
- public boolean providesCustomization()
- {
- return true;
- }
- */
-
- /*
- public HttpServletResponse getResponseForWindow(HttpServletRequest req,
HttpServletResponse resp)
- {
- PortletContent myContent = new PortletContent();
-
- synchronized (contents)
- {
- contents.put(window.getId(), myContent);
- }
-
- return new
HttpBufferedResponse(request.getResponse(),myContent.getWriter());
- }
- */
public ConcreteElement service(RunData data, String entityId)
{
@@ -180,15 +169,22 @@
try
{
HttpServletRequest request = data.getRequest();
- HttpServletResponse response = // TODO: test new
FusionResponseWrapper(data.getResponse());
- data.getResponse();
+ HttpServletResponse response = data.getResponse();
ServletConfig config = data.getServletConfig();
Engine engine = Jetspeed.getEngine();
contextComponent =
(RequestContextComponent)Jetspeed.getComponentManager().getComponent(RequestContextComponent.class);
- context = contextComponent.create(request, response, config);
+
+ context = (RequestContext)
data.getRequest().getAttribute(FUSION_NAV_STATE);
+ if (context == null)
+ {
+ context = contextComponent.create(request, response, config);
+
data.getRequest().setAttribute(JetspeedFusionPortlet.FUSION_NAV_STATE, context);
+ }
context.setAttribute(PortalReservedParameters.PORTLET_ENTITY, entityId);
- engine.service(context);
- // TODO: test result = response.toString();
+ context.getRequest().removeAttribute(PortalReservedParameters.PIPELINE);
+
+ engine.service(context);
+
}
catch (Throwable t)
{
@@ -203,7 +199,7 @@
}
}
- return new JetspeedClearElement(result);
+ return new JetspeedClearElement(result);
}
/**
@@ -252,12 +248,18 @@
return new JetspeedClearElement(result);
}
+ public NavigationalState getNavigationalState(JetspeedRunData data)
+ {
+ return
+ (NavigationalState)data.getSession().getAttribute(NAVSTATE_SESSION_KEY);
+ }
+
private void syncNavigationalState(PortletWindow window,
JetspeedRunData data,
- int mode)
+ int mode,
+ PortletInstance instance)
{
- NavigationalState nav =
- (NavigationalState)data.getSession().getAttribute(NAVSTATE_SESSION_KEY);
+ NavigationalState nav = getNavigationalState(data);
if (null == nav)
{
return;
@@ -277,12 +279,20 @@
String action = data.getAction();
- if (action.equals(J1_HELP_ACTION))
+ boolean targeted = isTargeted(data, instance, action);
+ if (targeted && action.equals(J1_HELP_ACTION))
{
nav.setMode(window, PortletMode.HELP);
return;
}
-
+ if (targeted && action.equals(J1_RESTORE_ACTION))
+ {
+ nav.setMode(window, PortletMode.VIEW);
+ nav.setState(window, WindowState.NORMAL);
+ return;
+ }
+
+ /*
switch (mode)
{
case JetspeedRunData.NORMAL:
@@ -307,7 +317,8 @@
nav.setMode(window, PortletMode.EDIT);
}
break;
- }
+ }
+ */
}
public boolean providesCustomization()
@@ -318,7 +329,6 @@
public void setMinimized(boolean flag, RunData rundata)
{
super.setMinimized(flag, rundata);
-System.out.println("MINIMIZING...");
JetspeedRunData jrun = (JetspeedRunData)rundata;
String entityId = null;
@@ -331,9 +341,7 @@
}
int mode = jrun.getMode();
- syncNavigationalState(window, jrun, mode);
-System.out.println("MINIMIZED...done: " + window.getId());
-
+ syncNavigationalState(window, jrun, mode, instance);
}
public boolean getAllowEdit( RunData rundata )
@@ -354,4 +362,39 @@
return super.getAllowEdit(rundata);
}
+ public boolean isTargeted(JetspeedRunData jdata, PortletInstance instance,
String action)
+ {
+ String peid = jdata.getJs_peid();
+ if (peid == null)
+ {
+ return false;
+ }
+ if (action == null || action.length() == 0)
+ {
+ return false;
+ }
+ return (peid.equals(instance.getEntry().getId()));
+ }
+
+ /*
+ public boolean providesCustomization()
+ {
+ return true;
+ }
+ */
+
+ /*
+ public HttpServletResponse getResponseForWindow(HttpServletRequest req,
HttpServletResponse resp)
+ {
+ PortletContent myContent = new PortletContent();
+
+ synchronized (contents)
+ {
+ contents.put(window.getId(), myContent);
+ }
+
+ return new
HttpBufferedResponse(request.getResponse(),myContent.getWriter());
+ }
+ */
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]