diff --git a/source/java/org/alfresco/web/bean/BrowseBean.java b/source/java/org/alfresco/web/bean/BrowseBean.java index da813a369b..90a522be92 100644 --- a/source/java/org/alfresco/web/bean/BrowseBean.java +++ b/source/java/org/alfresco/web/bean/BrowseBean.java @@ -87,6 +87,10 @@ import org.apache.log4j.Priority; */ public class BrowseBean implements IContextListener { + /** Public JSF Bean name */ + public static final String BEAN_NAME = "BrowseBean"; + + // ------------------------------------------------------------------------------ // Construction diff --git a/source/java/org/alfresco/web/bean/LoginBean.java b/source/java/org/alfresco/web/bean/LoginBean.java index 2dcd137040..f6b3ccf22d 100644 --- a/source/java/org/alfresco/web/bean/LoginBean.java +++ b/source/java/org/alfresco/web/bean/LoginBean.java @@ -35,7 +35,6 @@ import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.web.app.Application; import org.alfresco.web.app.servlet.AuthenticationHelper; -import org.alfresco.web.app.servlet.FacesHelper; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.User; import org.alfresco.web.ui.common.Utils; @@ -276,17 +275,8 @@ public class LoginBean } else { - // setup the current location with the NavigationBean - String location = this.preferences.getStartLocation(); - NavigationBean navBean = (NavigationBean)FacesHelper.getManagedBean( - fc, "NavigationBean"); - if (navBean != null) - { - navBean.setToolbarLocation(location); - } - // special case to handle jump to My Alfresco page initially - if (NavigationBean.LOCATION_MYALFRESCO.equals(location)) + if (NavigationBean.LOCATION_MYALFRESCO.equals(this.preferences.getStartLocation())) { return "myalfresco"; } diff --git a/source/java/org/alfresco/web/bean/NavigationBean.java b/source/java/org/alfresco/web/bean/NavigationBean.java index d6729e13d0..9bfe99d6ae 100644 --- a/source/java/org/alfresco/web/bean/NavigationBean.java +++ b/source/java/org/alfresco/web/bean/NavigationBean.java @@ -44,7 +44,6 @@ import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.web.app.Application; import org.alfresco.web.app.context.UIContextService; -import org.alfresco.web.app.servlet.FacesHelper; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.User; @@ -66,8 +65,6 @@ public class NavigationBean /** Public JSF Bean name */ public static final String BEAN_NAME = "NavigationBean"; - private static final String OUTCOME_MYALFRESCO = "myalfresco"; - private static final String OUTCOME_BROWSE = "browse"; /** * Default constructor @@ -190,7 +187,7 @@ public class NavigationBean } /** - * @return Returns the toolbar Location. + * @return Returns the toolbar Location - initially set from the user preferences. */ public String getToolbarLocation() { @@ -198,17 +195,30 @@ public class NavigationBean { // if the toolbar location has not been set yet, try and get the // default via the user preferences object - UserPreferencesBean prefsBean = (UserPreferencesBean)FacesHelper.getManagedBean( - FacesContext.getCurrentInstance(), "UserPreferencesBean"); - if (prefsBean != null) + this.toolbarLocation = this.preferences.getStartLocation(); + + // test that the user still has access to the specified location + // the location will need to be reset if the user permissions are no longer valid + if (NavigationBean.LOCATION_COMPANY.equals(this.toolbarLocation)) { - this.toolbarLocation = prefsBean.getStartLocation(); + if (getCompanyHomeVisible() == false) + { + this.toolbarLocation = null; + } + } + else if (NavigationBean.LOCATION_GUEST.equals(this.toolbarLocation)) + { + if (getGuestHomeVisible() == false) + { + this.toolbarLocation = null; + } } - // if we still haven't found a location default to my home + // if don't have a valid start location default to My Home if (this.toolbarLocation == null) { this.toolbarLocation = LOCATION_HOME; + this.preferences.setStartLocation(this.toolbarLocation); } } @@ -560,7 +570,7 @@ public class NavigationBean if (this.location == null) { // get the initial location from the user preferences - processToolbarLocation(this.preferences.getStartLocation(), false); + processToolbarLocation(getToolbarLocation(), false); } return this.location; @@ -850,7 +860,14 @@ public class NavigationBean public static final String LOCATION_GUEST = "guesthome"; public static final String LOCATION_MYALFRESCO = "myalfresco"; - private static final String MSG_MYALFRESCO = "my_alfresco"; + /** constant value representing the display lables for toolbar locations */ + public static final String MSG_MYALFRESCO = "my_alfresco"; + public static final String MSG_MYHOME = "my_home"; + public static final String MSG_COMPANYHOME = "company_home"; + public static final String MSG_GUESTHOME = "guest_home"; + + private static final String OUTCOME_MYALFRESCO = "myalfresco"; + private static final String OUTCOME_BROWSE = "browse"; private static final String ERROR_DELETED_FOLDER = "error_deleted_folder"; diff --git a/source/java/org/alfresco/web/bean/UserPreferencesBean.java b/source/java/org/alfresco/web/bean/UserPreferencesBean.java index a37af4347a..fe99df9379 100644 --- a/source/java/org/alfresco/web/bean/UserPreferencesBean.java +++ b/source/java/org/alfresco/web/bean/UserPreferencesBean.java @@ -28,6 +28,7 @@ import org.alfresco.config.Config; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.i18n.I18NUtil; import org.alfresco.web.app.Application; +import org.alfresco.web.app.servlet.FacesHelper; import org.alfresco.web.bean.repository.PreferencesService; import org.alfresco.web.config.LanguagesConfigElement; @@ -39,10 +40,6 @@ import org.alfresco.web.config.LanguagesConfigElement; public class UserPreferencesBean { private static final String PREF_STARTLOCATION = "start-location"; - private static final String MSG_MYALFRESCO = "my_alfresco"; - private static final String MSG_MYHOME = "my_home"; - private static final String MSG_COMPANYHOME = "company_home"; - private static final String MSG_GUESTHOME = "guest_home"; private static final String PREF_CONTENTFILTERLANGUAGE = "content-filter-language"; private static final String MSG_CONTENTALLLANGUAGES = "content_all_languages"; @@ -53,33 +50,9 @@ public class UserPreferencesBean /** content language locale selection */ private String contentFilterLanguage = null; - private SelectItem[] getLanguageItems(boolean includeAllLanguages) - { - Config config = Application.getConfigService(FacesContext.getCurrentInstance()).getConfig("Languages"); - LanguagesConfigElement langConfig = (LanguagesConfigElement)config.getConfigElement( - LanguagesConfigElement.CONFIG_ELEMENT_ID); - - List languages = langConfig.getLanguages(); - List items = new ArrayList(20); - if (includeAllLanguages) - { - ResourceBundle msg = Application.getBundle(FacesContext.getCurrentInstance()); - String allLanguagesStr = msg.getString(MSG_CONTENTALLLANGUAGES); - items.add(new SelectItem(MSG_CONTENTALLLANGUAGES, allLanguagesStr)); - } - for (String locale : languages) - { - // get label associated to the locale - String label = langConfig.getLabelForLanguage(locale); - items.add(new SelectItem(locale, label)); - } - - SelectItem[] result = new SelectItem[items.size()]; - return items.toArray(result); - } /** - * @return the available languages + * @return the list of available languages */ public SelectItem[] getLanguages() { @@ -124,6 +97,9 @@ public class UserPreferencesBean Application.setLanguage(FacesContext.getCurrentInstance(), this.language); } + /** + * @return current content filter language + */ public String getContentFilterLanguage() { if (this.contentFilterLanguage == null) @@ -143,7 +119,7 @@ public class UserPreferencesBean } /** - * @param languageStr A valid locale string or {@link #MSG_CONTENTALLLANGUAGES} + * @param languageStr A valid locale string or {@link #MSG_CONTENTALLLANGUAGES} */ public void setContentFilterLanguage(String languageStr) { @@ -161,6 +137,9 @@ public class UserPreferencesBean PreferencesService.getPreferences().setValue(PREF_CONTENTFILTERLANGUAGE, language); } + /** + * @return list of items for the content filtering language selection + */ public SelectItem[] getContentFilterLanguages() { // Get the item selection list @@ -169,7 +148,39 @@ public class UserPreferencesBean return items; } + /** + * Helper to return the available language items + * + * @param includeAllLanguages True to include a marker item for "All Languages" + * @return + */ + private static SelectItem[] getLanguageItems(boolean includeAllLanguages) + { + FacesContext fc = FacesContext.getCurrentInstance(); + Config config = Application.getConfigService(fc).getConfig("Languages"); + LanguagesConfigElement langConfig = (LanguagesConfigElement)config.getConfigElement( + LanguagesConfigElement.CONFIG_ELEMENT_ID); + + List languages = langConfig.getLanguages(); + List items = new ArrayList(10); + if (includeAllLanguages) + { + String allLanguagesStr = Application.getMessage(fc, MSG_CONTENTALLLANGUAGES); + items.add(new SelectItem(MSG_CONTENTALLLANGUAGES, allLanguagesStr)); + } + for (String locale : languages) + { + // get label associated to the locale + String label = langConfig.getLabelForLanguage(locale); + items.add(new SelectItem(locale, label)); + } + + return items.toArray(new SelectItem[items.size()]); + } + /** + * @return the start location for this user (@see NavigationBean) + */ public String getStartLocation() { String location = (String)PreferencesService.getPreferences().getValue(PREF_STARTLOCATION); @@ -181,18 +192,47 @@ public class UserPreferencesBean return location; } + /** + * @param location The current start location for this user (@see NavigationBean) + */ public void setStartLocation(String location) { PreferencesService.getPreferences().setValue(PREF_STARTLOCATION, location); } + /** + * @return the list of available start locations + */ public SelectItem[] getStartLocations() { - ResourceBundle msg = Application.getBundle(FacesContext.getCurrentInstance()); - return new SelectItem[] { - new SelectItem(NavigationBean.LOCATION_MYALFRESCO, msg.getString(MSG_MYALFRESCO)), - new SelectItem(NavigationBean.LOCATION_HOME, msg.getString(MSG_MYHOME)), - new SelectItem(NavigationBean.LOCATION_COMPANY, msg.getString(MSG_COMPANYHOME)), - new SelectItem(NavigationBean.LOCATION_GUEST, msg.getString(MSG_GUESTHOME))}; + FacesContext fc = FacesContext.getCurrentInstance(); + NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, "NavigationBean"); + ResourceBundle msg = Application.getBundle(fc); + + List locations = new ArrayList(4); + + // add My Alfresco location + locations.add(new SelectItem( + NavigationBean.LOCATION_MYALFRESCO, msg.getString(NavigationBean.MSG_MYALFRESCO))); + + // add My Home location + locations.add(new SelectItem( + NavigationBean.LOCATION_HOME, msg.getString(NavigationBean.MSG_MYHOME))); + + // add Company Home location if visible + if (navigator.getCompanyHomeVisible()) + { + locations.add(new SelectItem( + NavigationBean.LOCATION_COMPANY, msg.getString(NavigationBean.MSG_COMPANYHOME))); + } + + // add Guest Home location if visible + if (navigator.getGuestHomeVisible()) + { + locations.add(new SelectItem( + NavigationBean.LOCATION_GUEST, msg.getString(NavigationBean.MSG_GUESTHOME))); + } + + return locations.toArray(new SelectItem[locations.size()]); } } diff --git a/source/java/org/alfresco/web/ui/repo/component/UINavigator.java b/source/java/org/alfresco/web/ui/repo/component/UINavigator.java index 1ab621e0b7..7822d88cd5 100644 --- a/source/java/org/alfresco/web/ui/repo/component/UINavigator.java +++ b/source/java/org/alfresco/web/ui/repo/component/UINavigator.java @@ -46,8 +46,6 @@ public class UINavigator extends SelfRenderingComponent protected String activeArea; private static final Log logger = LogFactory.getLog(UINavigator.class); - private static final String NAVIGATION_BEAN = "NavigationBean"; - private static final String BROWSE_BEAN = "BrowseBean"; private static final String AJAX_URL_START = "/ajax/invoke/" + NavigatorPluginBean.BEAN_NAME; private static final String PANEL_ACTION = "panel:"; private static final int PANEL_SELECTED = 1; @@ -130,7 +128,7 @@ public class UINavigator extends SelfRenderingComponent // a panel was selected, setup the context to make the panel // the focus NavigationBean nb = (NavigationBean)FacesHelper.getManagedBean( - context, NAVIGATION_BEAN); + context, NavigationBean.BEAN_NAME); if (nb != null) { try @@ -163,7 +161,7 @@ public class UINavigator extends SelfRenderingComponent // setup the context to make the node the current node BrowseBean bb = (BrowseBean)FacesHelper.getManagedBean( - context, BROWSE_BEAN); + context, BrowseBean.BEAN_NAME); if (bb != null) { if (logger.isDebugEnabled()) @@ -193,7 +191,7 @@ public class UINavigator extends SelfRenderingComponent ResponseWriter out = context.getResponseWriter(); NavigationBean navBean = (NavigationBean)FacesHelper.getManagedBean( - context, NAVIGATION_BEAN); + context, NavigationBean.BEAN_NAME); NavigatorPluginBean navPluginBean = (NavigatorPluginBean)FacesHelper.getManagedBean( context, NavigatorPluginBean.BEAN_NAME); @@ -204,22 +202,22 @@ public class UINavigator extends SelfRenderingComponent if (NavigationBean.LOCATION_COMPANY.equals(area)) { rootNodesForArea = navPluginBean.getCompanyHomeRootNodes(); - areaTitle = Application.getMessage(context, "company_home"); + areaTitle = Application.getMessage(context, NavigationBean.MSG_COMPANYHOME); } else if (NavigationBean.LOCATION_HOME.equals(area)) { rootNodesForArea = navPluginBean.getMyHomeRootNodes(); - areaTitle = Application.getMessage(context, "my_home"); + areaTitle = Application.getMessage(context, NavigationBean.MSG_MYHOME); } else if (NavigationBean.LOCATION_GUEST.equals(area)) { rootNodesForArea = navPluginBean.getGuestHomeRootNodes(); - areaTitle = Application.getMessage(context, "guest_home"); + areaTitle = Application.getMessage(context, NavigationBean.MSG_GUESTHOME); } else { treePanel = false; - areaTitle = Application.getMessage(context, "my_alfresco"); + areaTitle = Application.getMessage(context, NavigationBean.MSG_MYALFRESCO); } // main container div @@ -243,8 +241,7 @@ public class UINavigator extends SelfRenderingComponent // generate the active panel containing the tree out.write("
"); - UITree tree = (UITree)context.getApplication().createComponent( - UITree.COMPONENT_TYPE); + UITree tree = (UITree)context.getApplication().createComponent(UITree.COMPONENT_TYPE); tree.setId("tree"); tree.setRootNodes(rootNodesForArea); tree.setRetrieveChildrenUrl(AJAX_URL_START + ".retrieveChildren?area=" + area); @@ -260,55 +257,49 @@ public class UINavigator extends SelfRenderingComponent if (NavigationBean.LOCATION_COMPANY.equals(area) == false && navBean.getCompanyHomeVisible()) { - out.write(""); + encodeSidebarButton(context, out, sideBarStyle, NavigationBean.LOCATION_COMPANY, NavigationBean.MSG_COMPANYHOME); } if (NavigationBean.LOCATION_HOME.equals(area) == false) { - out.write(""); + encodeSidebarButton(context, out, sideBarStyle, NavigationBean.LOCATION_HOME, NavigationBean.MSG_MYHOME); } if (NavigationBean.LOCATION_GUEST.equals(area) == false && navBean.getIsGuest() == false && navBean.getGuestHomeVisible()) { - out.write(""); + encodeSidebarButton(context, out, sideBarStyle, NavigationBean.LOCATION_GUEST, NavigationBean.MSG_GUESTHOME); } if (NavigationBean.LOCATION_MYALFRESCO.equals(area) == false) { - out.write(""); + encodeSidebarButton(context, out, sideBarStyle, NavigationBean.LOCATION_MYALFRESCO, NavigationBean.MSG_MYALFRESCO); } out.write("
"); } + + /** + * Encode a Sidebar Button DIV with selectable button link + * + * @param context FacesContext + * @param out ResponseWriter + * @param sideBarStyle Inline CSS style to apply to the sidebar button + * @param location Toolbar location id + * @param labelId Label I18N message id + */ + private void encodeSidebarButton(FacesContext context, ResponseWriter out, String sideBarStyle, + String location, String labelId) + throws IOException + { + out.write(""); + } @Override public void encodeChildren(FacesContext context) throws IOException diff --git a/source/web/jsp/dashboards/container.jsp b/source/web/jsp/dashboards/container.jsp index 141c7b032a..05b75e081d 100644 --- a/source/web/jsp/dashboards/container.jsp +++ b/source/web/jsp/dashboards/container.jsp @@ -24,10 +24,17 @@ <%@ page isELIgnored="false" %> <%@ page import="org.alfresco.web.app.Application" %> <%@ page import="org.alfresco.web.ui.common.PanelGenerator" %> +<%@ page import="javax.faces.context.FacesContext" %> + <% + FacesContext fc = FacesContext.getCurrentInstance(); + + // set locale for JSF framework usage + fc.getViewRoot().setLocale(Application.getLanguage(fc)); + %> <%-- load a bundle of properties with I18N strings --%> diff --git a/source/web/jsp/dialog/document-details.jsp b/source/web/jsp/dialog/document-details.jsp index 8b44885626..48abacb3ec 100644 --- a/source/web/jsp/dialog/document-details.jsp +++ b/source/web/jsp/dialog/document-details.jsp @@ -23,10 +23,18 @@ <%@ page buffer="64kb" contentType="text/html;charset=UTF-8" %> <%@ page isELIgnored="false" %> <%@ page import="org.alfresco.web.ui.common.PanelGenerator" %> +<%@ page import="org.alfresco.web.app.Application" %> +<%@ page import="javax.faces.context.FacesContext" %> + <% + FacesContext fc = FacesContext.getCurrentInstance(); + + // set locale for JSF framework usage + fc.getViewRoot().setLocale(Application.getLanguage(fc)); + %> <%-- load a bundle of properties with I18N strings --%> diff --git a/source/web/jsp/dialog/space-details.jsp b/source/web/jsp/dialog/space-details.jsp index 62e5fbb841..d135952cfe 100644 --- a/source/web/jsp/dialog/space-details.jsp +++ b/source/web/jsp/dialog/space-details.jsp @@ -23,10 +23,18 @@ <%@ page buffer="64kb" contentType="text/html;charset=UTF-8" %> <%@ page isELIgnored="false" %> <%@ page import="org.alfresco.web.ui.common.PanelGenerator" %> +<%@ page import="org.alfresco.web.app.Application" %> +<%@ page import="javax.faces.context.FacesContext" %> + <% + FacesContext fc = FacesContext.getCurrentInstance(); + + // set locale for JSF framework usage + fc.getViewRoot().setLocale(Application.getLanguage(fc)); + %> <%-- load a bundle of properties with I18N strings --%>