You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by pa...@apache.org on 2002/04/22 04:54:42 UTC
cvs commit: jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html Tool_jslink_examples.vm
paulsp 02/04/21 19:54:42
Modified: src/java/org/apache/jetspeed/util/template
BaseJetspeedLink.java JetspeedLink.java
webapp/WEB-INF/templates/vm/portlets/html
Tool_jslink_examples.vm
Log:
o Added PSML information, Country, Language, MediaType
o Added setAction() methods that accept Portlet, Portlets, Entry, and peid
as second parameter. This avoids the need to append a addQueryData() to
setAction(action_name).
o Removed setAnonymous. Do do not know URL for anonymous page
o Cleaned up imports
o Cleaned up Tool_jslink_examples.vm
Revision Changes Path
1.6 +143 -48 jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/BaseJetspeedLink.java
Index: BaseJetspeedLink.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/BaseJetspeedLink.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- BaseJetspeedLink.java 20 Apr 2002 12:51:57 -0000 1.5
+++ BaseJetspeedLink.java 22 Apr 2002 02:54:42 -0000 1.6
@@ -55,23 +55,18 @@
package org.apache.jetspeed.util.template;
// Jetspeed
+import org.apache.jetspeed.om.profile.Entry;
import org.apache.jetspeed.om.profile.Profile;
import org.apache.jetspeed.om.profile.Portlets;
import org.apache.jetspeed.om.profile.ProfileException;
import org.apache.jetspeed.om.profile.ProfileLocator;
import org.apache.jetspeed.portal.Portlet;
-import org.apache.jetspeed.portal.PortletSet;
-import org.apache.jetspeed.portal.PortletController;
-import org.apache.jetspeed.portal.PanedPortletController;
import org.apache.jetspeed.services.Profiler;
import org.apache.jetspeed.services.resources.JetspeedResources;
import org.apache.jetspeed.services.rundata.JetspeedRunData;
import org.apache.jetspeed.util.template.JetspeedLink;
// Turbine
-import org.apache.turbine.om.security.Role;
-import org.apache.turbine.om.security.Group;
-import org.apache.turbine.om.security.User;
import org.apache.turbine.util.RunData;
import org.apache.turbine.util.Log;
import org.apache.turbine.util.DynamicURI;
@@ -91,7 +86,7 @@
* rendering code. This is done currently in VelocityPortlet.</p>
*
* @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
- * @version $Id: BaseJetspeedLink.java,v 1.5 2002/04/20 12:51:57 paulsp Exp $
+ * @version $Id: BaseJetspeedLink.java,v 1.6 2002/04/22 02:54:42 paulsp Exp $
*/
public class BaseJetspeedLink implements ApplicationTool, JetspeedLink
{
@@ -298,7 +293,22 @@
*/
public DynamicURI setAction(String action)
{
- return setAction(action, null);
+ return setAction(action, (String) null);
+ }
+
+ /**
+ * Return a link that includes an action to a specific portlet, as defined
+ * by a portlets
+ *
+ * @param action Desired action
+ * @param portlets to receive the action
+ * @return DynamicURI that includes the desire action
+ */
+ public DynamicURI setAction(String action, Portlets portlet)
+ {
+ if (portlet != null)
+ return setAction(action, portlet.getId());
+ return setAction(action, (String) null);
}
/**
@@ -308,59 +318,56 @@
* @param portlet to receive the action
* @return DynamicURI that includes the desire action
*/
- public DynamicURI setAction(String action, Portlets portlet)
+ public DynamicURI setAction(String action, Portlet portlet)
{
- try
- {
- DynamicURI uri = getRoot();
-
- // Add current template to URI, if their is one
- if (action != null)
- uri.addQueryData( JetspeedResources.PATH_ACTION_KEY, action);
- if (portlet != null)
- {
- String peid = portlet.getId();
- if ((peid != null) && (peid.length() > 0))
- uri.addPathInfo( JetspeedResources.PATH_PORTLETID_KEY, peid);
- }
- return uri;
- } catch (ProfileException e)
- {
- Log.error(e);
- return null;
- }
+ if (portlet != null)
+ return setAction(action, portlet.getID());
+ return setAction(action, (String) null);
}
/**
- * Return a link to a default page for the anonymous user
+ * Return a link that includes an action to a specific portlet, as defined
+ * by an entry
*
- * @return DynamicURI that to the desired page
+ * @param action Desired action
+ * @param portlet to receive the action
+ * @return DynamicURI that includes the desire action
*/
- public DynamicURI setAnonymous()
+ public DynamicURI setAction(String action, Entry entry)
{
- return setAnonymous( null);
+ if (entry != null)
+ return setAction(action, entry.getId());
+ return setAction(action, (String) null);
}
/**
- * Return a link to a desired page for the anonymous user
+ * Return a link that includes an action to a specific portlet, as defined
+ * by a PEID
*
- * @param page Desired page
- * @return DynamicURI that to the desired page
+ * @param action Desired action
+ * @param portlet to receive the action
+ * @return DynamicURI that includes the desire action
*/
- public DynamicURI setAnonymous(String page)
+ public DynamicURI setAction(String action, String peid)
{
- DynamicURI uri = new DynamicURI();
-
- // Cleanup URI
- uri.removePathInfo( Profiler.PARAM_GROUP);
- uri.removePathInfo( Profiler.PARAM_ROLE);
- uri.removePathInfo( Profiler.PARAM_PAGE);
- uri.removePathInfo( Profiler.PARAM_USER);
-
- // Add Path items to URI
- if ((page != null) && (page.length() > 0))
- uri.addPathInfo( Profiler.PARAM_PAGE, page);
- return uri;
+ try
+ {
+ DynamicURI uri = getRoot();
+
+ // Add the action to URI, if their is one
+ if (action != null)
+ uri.addQueryData( JetspeedResources.PATH_ACTION_KEY, action);
+
+ // Add the peid to URI, if their is one
+ if ((peid != null) && (peid.length() > 0))
+ uri.addPathInfo( JetspeedResources.PATH_PORTLETID_KEY, peid);
+
+ return uri;
+ } catch (ProfileException e)
+ {
+ Log.error(e);
+ return null;
+ }
}
/**
@@ -652,6 +659,11 @@
return JetspeedResources.PATH_ACTION_KEY;
}
+ /**
+ * Is the PSML for the anonymous user?
+ *
+ * @return True = PSML is for the anonymous user
+ */
public boolean getAnonymous()
{
try
@@ -664,6 +676,28 @@
}
}
+ /**
+ * Return country of the PSML file
+ *
+ * @return Country of PSML, or null if no country
+ */
+ public String getCountry()
+ {
+ try
+ {
+ return locator.getCountry();
+ } catch (Exception e)
+ {
+ Log.error(e);
+ return null;
+ }
+ }
+
+ /**
+ * Return Group name of the PSML file
+ *
+ * @return Group name of PSML, or null if no Group name
+ */
public String getGroupName()
{
try
@@ -676,6 +710,62 @@
}
}
+ /**
+ * Return Language of the PSML file
+ *
+ * @return Language of PSML, or null if no Language
+ */
+ public String getLanguage()
+ {
+ try
+ {
+ return locator.getLanguage();
+ } catch (Exception e)
+ {
+ Log.error(e);
+ return null;
+ }
+ }
+
+ /**
+ * Return Media Type of the PSML file
+ *
+ * @return Media Type of PSML, or null if no Media Type
+ */
+ public String getMediaType()
+ {
+ try
+ {
+ return locator.getMediaType();
+ } catch (Exception e)
+ {
+ Log.error(e);
+ return null;
+ }
+ }
+
+ /**
+ * Return Page name of the PSML file
+ *
+ * @return Page name of PSML, or null if no Page name
+ */
+ public String getPage()
+ {
+ try
+ {
+ return locator.getName();
+ } catch (Exception e)
+ {
+ Log.error(e);
+ return null;
+ }
+ }
+
+ /**
+ * Return Role name of the PSML file
+ *
+ * @return Role name of PSML, or null if no Role name
+ */
public String getRoleName()
{
try
@@ -688,6 +778,11 @@
}
}
+ /**
+ * Return User name of the PSML file
+ *
+ * @return User name of PSML, or null if no User name
+ */
public String getUserName()
{
try
1.5 +199 -55 jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedLink.java
Index: JetspeedLink.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedLink.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JetspeedLink.java 14 Apr 2002 16:49:09 -0000 1.4
+++ JetspeedLink.java 22 Apr 2002 02:54:42 -0000 1.5
@@ -56,6 +56,7 @@
// Jetspeed
import org.apache.jetspeed.portal.Portlet;
+import org.apache.jetspeed.om.profile.Portlets;
// Turbine
import org.apache.turbine.util.DynamicURI;
@@ -71,80 +72,234 @@
* rendering code. This is done currently in VelocityPortlet.</p>
*
* @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
- * @version $Id: JetspeedLink.java,v 1.4 2002/04/14 16:49:09 paulsp Exp $
+ * @version $Id: JetspeedLink.java,v 1.5 2002/04/22 02:54:42 paulsp Exp $
*/
-public interface JetspeedLink
+public interface JetspeedLink
{
/**
- * This will initialise a JetspeedLink object that was
- * constructed with the default constructor
+ * Adds a name=value pair to the path_info string.
*
- * @param rundata to be a RunData object
+ * @param name A String with the name to add.
+ * @param value An Object with the value to add.
+ * @return DynamicURI that to the desired page
*/
- public void init(RunData rundata);
-
+ public DynamicURI addPathInfo(String name, Object value);
+
+ /**
+ * Adds a name=value pair to the query string.
+ *
+ * @param name A String with the name to add.
+ * @param value An Object with the value to add.
+ * @return DynamicURI that to the desired page
+ */
+ public DynamicURI addQueryData(String name, Object value);
+
+ /**
+ * Return the action key. Used by velocity templates, i.e. $jlink.ActionKey
+ *
+ * @return the action parameter name
+ */
+ public String getActionKey();
+
/**
* Return link to the home page without user,
* page, group, or role refrenances
*
* @return DynamicURI to the home page
- */
- public DynamicURI getHomePage();
-
- /**
- * Return a link that includes the template
- * from rundata
- *
- * @return DynamicURI to template
- */
- public DynamicURI getTemplate();
-
+ */
+ public DynamicURI getHomePage();
+
+ /**
+ * This will initialise a JetspeedLink object that was
+ * constructed with the default constructor
+ *
+ * @param rundata to be a RunData object
+ */
+ public void init(RunData rundata);
+
+ /**
+ * Return a link that includes the template
+ * from rundata
+ *
+ * @return DynamicURI to template
+ */
+ public DynamicURI getTemplate();
+
+ /**
+ * Is the PSML for the anonymous user?
+ *
+ * @return True = PSML is for the anonymous user
+ */
+ public boolean getAnonymous();
+
+ /**
+ * Return country of the PSML file
+ *
+ * @return Country of PSML, or null if no country
+ */
+ public String getCountry();
+
+ /**
+ * Return Group name of the PSML file
+ *
+ * @return Group name of PSML, or null if no Group name
+ */
+ public String getGroupName();
+
+ /**
+ * Return Language of the PSML file
+ *
+ * @return Language of PSML, or null if no Language
+ */
+ public String getLanguage();
+
+ /**
+ * Return Media Type of the PSML file
+ *
+ * @return Media Type of PSML, or null if no Media Type
+ */
+ public String getMediaType();
+
+ /**
+ * Return Page name of the PSML file
+ *
+ * @return Page name of PSML, or null if no Page name
+ */
+ public String getPage();
+
+ /**
+ * Return Role name of the PSML file
+ *
+ * @return Role name of PSML, or null if no Role name
+ */
+ public String getRoleName();
+
+ /**
+ * Return User name of the PSML file
+ *
+ * @return User name of PSML, or null if no User name
+ */
+ public String getUserName();
+
/**
* Return a link that includes an action
*
+ * @param action action
+ * @return DynamicURI that includes the desire action
+ */
+ public DynamicURI setAction(String action);
+
+ /**
+ * Return a link that includes an action to a specific portlet
+ *
* @param action Desired action
+ * @param portlet to receive the action
* @return DynamicURI that includes the desire action
- */
- public DynamicURI setAction(String action);
-
+ */
+ public DynamicURI setAction(String action, Portlets portlet);
+
+ /**
+ * Return a link to a default page for the group
+ *
+ * @param group Desired group
+ * @return DynamicURI that to the desired page
+ */
+ public DynamicURI setGroup(String group);
+
/**
- * Return a link to a desired page in for the
+ * Return a link to a desired page for the group
+ *
+ * @param page Desired page
+ * @param group Desired group
+ * @return DynamicURI that to the desired page
+ */
+ public DynamicURI setGroup(String group, String page);
+
+ /**
+ * Return a link to a default page for the
* current user, group, or role.
+ *
+ * @return DynamicURI that to the desired page
+ */
+ public DynamicURI setPage();
+
+ /**
+ * Return a link to a desired page for the
+ * current user, group, or role.
+ *
* @param page Desired page
* @return DynamicURI that to the desired page
- */
+ */
public DynamicURI setPage(String page);
- /**
- * Return a link to the template.
+
+ /**
+ * Return an link to a specific portlet using the portet's id
*
- * @param template to add to link
+ * @param peid of the portlet
* @return DynamicURI to specific portlet
- */
- public DynamicURI setTemplate(String template);
-
+ */
+ public DynamicURI setPortletById(String peid);
+
/**
* Return an link to a specific portal element
*
* @param peid of the portal element
* @return DynamicURI to specific portal element
*/
- public DynamicURI setPortalElement(String peid);
-
+ public DynamicURI setPortalElement(String peid);
+
/**
- * Return an link to a specific portlet using the portet's id
+ * Add a portlet reference in the link.
*
- * @param peid of the portlet
+ * Note: This must be used with caution, since a portlet may exist may times
+ * in a PSML. setPortletById() is the perfered method.
+ *
+ * @param portletName the name of the portlet to link to
+ * @return a DynamicURI referencing the named portlet for easy link construction in template
+ */
+ public DynamicURI setPortletByName(String portletName);
+
+ /**
+ * Return a link to a default page for the role
+ *
+ * @param role Desired role
+ * @return DynamicURI that to the desired page
+ */
+ public DynamicURI setRole(String role);
+
+ /**
+ * Return a link to a desired page for the role
+ *
+ * @param role Desired role
+ * @param page Desired page
+ * @return DynamicURI that to the desired page
+ */
+ public DynamicURI setRole(String role, String page);
+
+ /**
+ * Return a link to the template.
+ *
+ * @param template to add to link
* @return DynamicURI to specific portlet
*/
- public DynamicURI setPortletById(String peid);
+ public DynamicURI setTemplate(String template);
/**
- * Return a link to a specific pane using the pane's id
+ * Return a link to a default page for the user
*
- * @param paneId of the Pane
- * @return URI to specific portlet
+ * @param user Desired user
+ * @return DynamicURI that to the desired page
*/
- public DynamicURI setPaneById(String paneId);
+ public DynamicURI setUser(String user);
+
+ /**
+ * Return a link to a desired page for the user
+ *
+ * @param page Desired page
+ * @param user Desired user
+ * @return DynamicURI that to the desired page
+ */
+ public DynamicURI setUser(String user, String page);
/**
* Return a URL, as a string, the the root page or pane.
@@ -154,12 +309,14 @@
public String toString();
/**
- * Return the action key. Used by velocity templates, i.e. $jlink.ActionKey
+ * Return a link to a specific pane using the pane's id
*
- * @return the action parameter name
+ * @param paneId of the Pane
+ * @return URI to specific portlet
*/
- public String getActionKey();
-
+ public DynamicURI setPaneById(String paneId);
+
+
/**
* Depracated methods from JetspeedTemplateLink.
*/
@@ -176,17 +333,4 @@
*/
public void setPortlet(Portlet portlet);
-
- /**
- * Add a portlet reference in the link.
- *
- * Note: This must be used with caution, since a portlet may exist may times
- * in a PSML. setPortletById() is the perfered method.
- *
- * @param portletName the name of the portlet to link to
- * @return a DynamicURI referencing the named portlet for easy link construction in template
- */
-
- public DynamicURI setPortletName(String portletName);
-
}
1.2 +10 -4 jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/Tool_jslink_examples.vm
Index: Tool_jslink_examples.vm
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/Tool_jslink_examples.vm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Tool_jslink_examples.vm 20 Apr 2002 12:51:57 -0000 1.1
+++ Tool_jslink_examples.vm 22 Apr 2002 02:54:42 -0000 1.2
@@ -5,6 +5,9 @@
<th>Value</th>
</tr>
<tr>
+ <th colspan="2"><center>General URL</center></th>
+ </tr>
+ <tr>
<td>jslink</td>
<td>$jslink</td>
</tr>
@@ -13,12 +16,15 @@
<td>$jslink.HomePage</td>
</tr>
<tr>
+ <th colspan="2"><center>Templates in the URL</center></th>
+ </tr>
+ <tr>
<td>jslink.Template</td>
<td>$jslink.Template</td>
</tr>
<tr>
- <td>jslink.setTemplate("myScreen)</td>
- <td>$jslink.setTemplate("myScreen)</td>
+ <td>jslink.setTemplate("myScreen")</td>
+ <td>$jslink.setTemplate("myScreen")</td>
</tr>
<tr>
<th colspan="2"><center>Path and Query item on URL</center></th>
@@ -47,8 +53,8 @@
<td>$jslink.setAction("update","p12345")</td>
</tr>
<tr>
- <td>jslink.setAction("update",$PORTLET)</td>
- <td>$jslink.setAction("update",$PORTLET)</td>
+ <td>jslink.setAction("update",\$portlet)</td>
+ <td>$jslink.setAction("update",$portlet)</td>
</tr>
<tr>
<th colspan="2"><center>Group/Role/User/Page element on URL</center></th>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>