. Added URL addressability to dashboards

- the External Access servlet now supports jumping to the My Alfresco dashboard for a user
   - pages other than the default are supported
   - URL is of the form /alfresco/navigate/myalfresco or /alfresco/navigate/myalfresco?page=id

. Added configuration so that the web-client can be configured to jump to any of the following start locations:
   My Home (current defaut), Company Home, Guest Home or My Alfresco dashboard
   see the <initial-location> web-client-config element

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3398 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-07-25 17:09:10 +00:00
parent f6f2ca6d5b
commit 62c0ecf132
10 changed files with 205 additions and 107 deletions

View File

@@ -52,6 +52,10 @@
<!-- see org.alfresco.service.cmr.security.PermissionService for allowed values -->
<home-space-permission>Consumer</home-space-permission>
<!-- The default location to display when the browse screen is first shown -->
<!-- This value should be one of 'companyhome', 'userhome', 'guesthome' or 'myalfresco' -->
<initial-location>userhome</initial-location>
<!-- the URL to the client Help file -->
<help-url>http://www.alfresco.org/help/webclient</help-url>

View File

@@ -34,6 +34,7 @@ import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.dashboard.DashboardManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -64,9 +65,11 @@ public class ExternalAccessServlet extends BaseServlet
private final static String OUTCOME_DOCDETAILS = "showDocDetails";
private final static String OUTCOME_SPACEDETAILS = "showSpaceDetails";
private final static String OUTCOME_BROWSE = "browse";
private final static String OUTCOME_MYALFRESCO = "myalfresco";
private final static String OUTCOME_LOGOUT = "logout";
private static final String ARG_TEMPLATE = "template";
private static final String ARG_PAGE = "page";
/**
* @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
@@ -224,6 +227,19 @@ public class ExternalAccessServlet extends BaseServlet
navigationHandler.handleNavigation(fc, null, outcome);
}
}
else if (OUTCOME_MYALFRESCO.equals(outcome))
{
// setup the Dashboard Manager ready for the page we want to display
if (req.getParameter(ARG_PAGE) != null)
{
DashboardManager manager = (DashboardManager)FacesHelper.getManagedBean(fc, "DashboardManager");
manager.getPageConfig().setCurrentPage(req.getParameter(ARG_PAGE));
}
// perform the appropriate JSF navigation outcome
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
navigationHandler.handleNavigation(fc, null, outcome);
}
else if (OUTCOME_LOGOUT.equals(outcome))
{
// special case for logout

View File

@@ -325,9 +325,19 @@ public class LoginBean
}
else
{
// special case to handle jump to My Alfresco page initially
String location = Application.getClientConfig(FacesContext.getCurrentInstance()).getInitialLocation();
if (NavigationBean.LOCATION_MYALFRESCO.equals(location))
{
return "myalfresco";
}
else
{
// generally this will navigate to the generic browse screen
return "success";
}
}
}
catch (AuthenticationException aerr)
{
Utils.addErrorMessage(Application.getMessage(fc, MSG_ERROR_UNKNOWN_USER));

View File

@@ -187,11 +187,93 @@ public class NavigationBean
}
/**
* @param toolbarLocation The toolbar Location to set.
* @param location The toolbar Location to set.
*/
public void setToolbarLocation(String toolbarLocation)
public void setToolbarLocation(String location)
{
this.toolbarLocation = toolbarLocation;
processToolbarLocation(location, true);
}
/**
* Process the selected toolbar location. Setup the breadcrumb with initial value and
* setup the current node ID. This method can also perform the navigatin setup if requested.
*
* @param location Toolbar location constant
* @param navigate True to perform navigation, false otherwise
*/
private void processToolbarLocation(String location, boolean navigate)
{
this.toolbarLocation = location;
FacesContext context = FacesContext.getCurrentInstance();
if (LOCATION_COMPANY.equals(location))
{
List<IBreadcrumbHandler> elements = new ArrayList<IBreadcrumbHandler>(1);
Node companyHome = getCompanyHomeNode();
elements.add(new NavigationBreadcrumbHandler(companyHome.getNodeRef(), companyHome.getName()));
setLocation(elements);
setCurrentNodeId(companyHome.getId());
// we need to force a navigation to refresh the browse screen breadcrumb
if (navigate)
{
context.getApplication().getNavigationHandler().handleNavigation(context, null, OUTCOME_BROWSE);
}
}
else if (LOCATION_HOME.equals(location))
{
List<IBreadcrumbHandler> elements = new ArrayList<IBreadcrumbHandler>(1);
String homeSpaceId = Application.getCurrentUser(context).getHomeSpaceId();
NodeRef homeSpaceRef = new NodeRef(Repository.getStoreRef(), homeSpaceId);
String homeSpaceName = Repository.getNameForNode(this.nodeService, homeSpaceRef);
elements.add(new NavigationBreadcrumbHandler(homeSpaceRef, homeSpaceName));
setLocation(elements);
setCurrentNodeId(homeSpaceRef.getId());
// we need to force a navigation to refresh the browse screen breadcrumb
if (navigate)
{
context.getApplication().getNavigationHandler().handleNavigation(context, null, OUTCOME_BROWSE);
}
}
else if (LOCATION_GUEST.equals(location))
{
List<IBreadcrumbHandler> elements = new ArrayList<IBreadcrumbHandler>(1);
Node guestHome = getGuestHomeNode();
elements.add(new NavigationBreadcrumbHandler(guestHome.getNodeRef(), guestHome.getName()));
setLocation(elements);
setCurrentNodeId(guestHome.getId());
// we need to force a navigation to refresh the browse screen breadcrumb
if (navigate)
{
context.getApplication().getNavigationHandler().handleNavigation(context, null, OUTCOME_BROWSE);
}
}
else if (LOCATION_MYALFRESCO.equals(location))
{
List<IBreadcrumbHandler> elements = new ArrayList<IBreadcrumbHandler>(1);
elements.add(new IBreadcrumbHandler()
{
public String navigationOutcome(UIBreadcrumb breadcrumb)
{
setLocation( (List)breadcrumb.getValue() );
return OUTCOME_MYALFRESCO;
};
public String toString()
{
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_MYALFRESCO);
};
});
setLocation(elements);
// we need to force a navigation to refresh the browse screen breadcrumb
if (navigate)
{
context.getApplication().getNavigationHandler().handleNavigation(context, null, OUTCOME_MYALFRESCO);
}
}
}
/**
@@ -425,26 +507,13 @@ public class NavigationBean
{
if (this.location == null)
{
// set the current node to the users Home Space Id if one has not already been set
NodeRef homeSpaceRef;
List<IBreadcrumbHandler> elements = new ArrayList<IBreadcrumbHandler>(1);
if (getCurrentNodeId() == null)
// get the initial location from the client config
String initialLocation = clientConfig.getInitialLocation();
if (initialLocation == null || initialLocation.length() == 0)
{
User user = Application.getCurrentUser(FacesContext.getCurrentInstance());
homeSpaceRef = new NodeRef(Repository.getStoreRef(), user.getHomeSpaceId());
initialLocation = LOCATION_HOME;
}
else
{
homeSpaceRef = new NodeRef(Repository.getStoreRef(), getCurrentNodeId());
}
// set initial node ID
setCurrentNodeId(homeSpaceRef.getId());
// setup the breadcrumb with the same initial location
String homeSpaceName = Repository.getNameForNode(this.nodeService, homeSpaceRef);
elements.add(new NavigationBreadcrumbHandler(homeSpaceRef, homeSpaceName));
setLocation(elements);
processToolbarLocation(initialLocation, false);
}
return this.location;
@@ -591,63 +660,6 @@ public class NavigationBean
UIModeList locationList = (UIModeList)event.getComponent();
String location = locationList.getValue().toString();
setToolbarLocation(location);
if (LOCATION_COMPANY.equals(location))
{
List<IBreadcrumbHandler> elements = new ArrayList<IBreadcrumbHandler>(1);
Node companyHome = getCompanyHomeNode();
elements.add(new NavigationBreadcrumbHandler(companyHome.getNodeRef(), companyHome.getName()));
setLocation(elements);
setCurrentNodeId(companyHome.getId());
// we need to force a navigation to refresh the browse screen breadcrumb
context.getApplication().getNavigationHandler().handleNavigation(context, null, OUTCOME_BROWSE);
}
else if (LOCATION_HOME.equals(location))
{
List<IBreadcrumbHandler> elements = new ArrayList<IBreadcrumbHandler>(1);
String homeSpaceId = Application.getCurrentUser(context).getHomeSpaceId();
NodeRef homeSpaceRef = new NodeRef(Repository.getStoreRef(), homeSpaceId);
String homeSpaceName = Repository.getNameForNode(this.nodeService, homeSpaceRef);
elements.add(new NavigationBreadcrumbHandler(homeSpaceRef, homeSpaceName));
setLocation(elements);
setCurrentNodeId(homeSpaceRef.getId());
// we need to force a navigation to refresh the browse screen breadcrumb
context.getApplication().getNavigationHandler().handleNavigation(context, null, OUTCOME_BROWSE);
}
else if (LOCATION_GUEST.equals(location))
{
List<IBreadcrumbHandler> elements = new ArrayList<IBreadcrumbHandler>(1);
Node guestHome = getGuestHomeNode();
elements.add(new NavigationBreadcrumbHandler(guestHome.getNodeRef(), guestHome.getName()));
setLocation(elements);
setCurrentNodeId(guestHome.getId());
// we need to force a navigation to refresh the browse screen breadcrumb
context.getApplication().getNavigationHandler().handleNavigation(context, null, OUTCOME_BROWSE);
}
else if (LOCATION_DASHBOARD.equals(location))
{
List<IBreadcrumbHandler> elements = new ArrayList<IBreadcrumbHandler>(1);
elements.add(new IBreadcrumbHandler()
{
public String navigationOutcome(UIBreadcrumb breadcrumb)
{
setLocation( (List)breadcrumb.getValue() );
return OUTCOME_MYALFRESCO;
};
public String toString()
{
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_MYALFRESCO);
};
});
setLocation(elements);
// we need to force a navigation to refresh the browse screen breadcrumb
context.getApplication().getNavigationHandler().handleNavigation(context, null, OUTCOME_MYALFRESCO);
}
}
catch (InvalidNodeRefException refErr)
{
@@ -770,10 +782,10 @@ public class NavigationBean
private static Logger s_logger = Logger.getLogger(NavigationBean.class);
/** constant values used by the toolbar location modelist control */
private static final String LOCATION_COMPANY = "company";
private static final String LOCATION_HOME = "home";
private static final String LOCATION_GUEST = "guest";
private static final String LOCATION_DASHBOARD = "dashboard";
static final String LOCATION_COMPANY = "companyhome";
static final String LOCATION_HOME = "userhome";
static final String LOCATION_GUEST = "guesthome";
static final String LOCATION_MYALFRESCO = "myalfresco";
private static final String MSG_MYALFRESCO = "my_alfresco";

View File

@@ -42,7 +42,7 @@ import org.dom4j.io.XMLWriter;
*
* @author Kevin Roast
*/
final class PageConfig
public final class PageConfig
{
private static Log logger = LogFactory.getLog(DashboardManager.class);
@@ -55,7 +55,7 @@ final class PageConfig
private static final String ATTR_REFID = "idref";
private List<Page> pages = new ArrayList<Page>(4);
private int currentPageIndex = 0;
private Page currentPage = null;
/**
@@ -86,13 +86,30 @@ final class PageConfig
*/
public Page getCurrentPage()
{
if (currentPageIndex < pages.size())
if (this.currentPage == null)
{
return pages.get(currentPageIndex);
if (this.pages.size() != 0)
{
this.currentPage = pages.get(0);
}
else
}
return this.currentPage;
}
/**
* Set the current Page for the cnfig
*
* @param pageId ID of the page to set as current
*/
public void setCurrentPage(String pageId)
{
return null;
for (Page page : pages)
{
if (page.getId().equals(pageId))
{
this.currentPage = page;
break;
}
}
}

View File

@@ -40,6 +40,7 @@ public class ClientConfigElement extends ConfigElementAdapter
private String editLinkType = "http";
private String homeSpacePermission = null;
private boolean ajaxEnabled = false;
private String initialLocation = null;
/**
* Default Constructor
@@ -145,6 +146,17 @@ public class ClientConfigElement extends ConfigElementAdapter
combinedElement.setFromEmailAddress(newElement.getFromEmailAddress());
}
if (newElement.isAjaxEnabled() != combinedElement.isAjaxEnabled())
{
combinedElement.setAjaxEnabled(newElement.isAjaxEnabled());
}
if (newElement.getInitialLocation() != null &&
newElement.getInitialLocation().equals(combinedElement.getInitialLocation()) == false)
{
combinedElement.setInitialLocation(newElement.getInitialLocation());
}
return combinedElement;
}
@@ -348,4 +360,20 @@ public class ClientConfigElement extends ConfigElementAdapter
{
this.ajaxEnabled = ajaxEnabled;
}
/**
* @return Returns the default initial location for the user.
*/
public String getInitialLocation()
{
return this.initialLocation;
}
/**
* @param initialLocation The initial location to set.
*/
/*package*/ void setInitialLocation(String initialLocation)
{
this.initialLocation = initialLocation;
}
}

View File

@@ -40,6 +40,7 @@ public class ClientElementReader implements ConfigElementReader
public static final String ELEMENT_FROMEMAILADDRESS = "from-email-address";
public static final String ELEMENT_SHELFVISIBLE = "shelf-visible";
public static final String ELEMENT_AJAX_ENABLED = "ajax-enabled";
public static final String ELEMENT_INITIALLOCATION = "initial-location";
/**
* @see org.alfresco.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
@@ -144,6 +145,13 @@ public class ClientElementReader implements ConfigElementReader
{
configElement.setAjaxEnabled(Boolean.parseBoolean(ajaxEnabled.getTextTrim()));
}
// get the initial location
Element initialLocation = element.element(ELEMENT_INITIALLOCATION);
if (initialLocation != null)
{
configElement.setInitialLocation(initialLocation.getTextTrim());
}
}
return configElement;

View File

@@ -148,5 +148,6 @@ public class DashboardsConfigElement extends ConfigElementAdapter
public String Description;
public String DescriptionId;
public String JSPPage;
public String ConfigJSPPage;
}
}

View File

@@ -46,6 +46,7 @@ public class DashboardsElementReader implements ConfigElementReader
public static final String ATTR_LABELID = "label-id";
public static final String ATTR_DESCRIPTIONID = "description-id";
public static final String ATTR_JSP = "jsp";
public static final String ATTR_CONFIGJSP = "config-jsp";
public static final String ATTR_ALLOWNARROW = "allow-narrow";
/**
@@ -165,6 +166,7 @@ public class DashboardsElementReader implements ConfigElementReader
def.AllowNarrow = Boolean.parseBoolean(allowNarrow);
}
def.JSPPage = getMandatoryDashletAttributeValue(config, ATTR_JSP);
def.ConfigJSPPage = config.attributeValue(ATTR_CONFIGJSP);
String label = config.attributeValue(ATTR_LABEL);
String labelId = config.attributeValue(ATTR_LABELID);
if ((label == null || label.length() == 0) && (labelId == null || labelId.length() == 0))

View File

@@ -28,10 +28,10 @@
<a:modeList itemSpacing="3" iconColumnWidth="0" horizontal="true"
itemStyleClass="topToolbar" itemLinkStyleClass="topToolbarLink" selectedStyleClass="topToolbar" selectedLinkStyleClass="topToolbarLink"
value="#{NavigationBean.toolbarLocation}" actionListener="#{NavigationBean.toolbarLocationChanged}">
<a:listItem value="company" label="#{msg.company_home}" rendered="#{NavigationBean.companyHomeVisible}" />
<a:listItem value="home" label="#{msg.my_home}" />
<a:listItem value="guest" label="#{msg.guest_home}" rendered="#{NavigationBean.isGuest == false && NavigationBean.guestHomeVisible}" />
<a:listItem value="dashboard" label="#{msg.my_alfresco}" />
<a:listItem value="companyhome" label="#{msg.company_home}" rendered="#{NavigationBean.companyHomeVisible}" />
<a:listItem value="userhome" label="#{msg.my_home}" />
<a:listItem value="guesthome" label="#{msg.guest_home}" rendered="#{NavigationBean.isGuest == false && NavigationBean.guestHomeVisible}" />
<a:listItem value="myalfresco" label="#{msg.my_alfresco}" />
</a:modeList>
</td>
<td><img src="<%=request.getContextPath()%>/images/parts/titlebar_end.gif" width=8 height=30></td>