The static menu is removed from Action class. The left menu is retrieved from the action context now.
<%@ page import="org.splat.simer.Action"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
- <s:set var="menuname" value="leftMenuSettings.menuName" />
+ <%@page import="com.opensymphony.xwork2.ActionContext"%>
+<s:set var="menuname" value="leftMenuSettings.menuName" />
<s:set var="namespace" value="leftMenuSettings.menuNamespace" />
<!-- Display of the menu tab
-->
<div id=menuitem-box>
<%
- Menu menu = Action.getStaticMenu();
+ Action anAction = (Action)ActionContext.getContext().getActionInvocation().getAction();
+ Menu menu = anAction.getLeftMenuSettings().getMenu();
boolean submenu = false;
for (Iterator<MenuItem> listem = menu.asList().iterator(); listem.hasNext(); ) {
MenuItem item = listem.next();
*/
private ApplicationSettings _applicationSettings;
- /**
- * Will be removed!!! It's temporary solution for menuitem.jsp
- */
- private static Menu staticMenu;
-
/**
* Comparator for sorting document types with localized names.
*/
Menu menu = (Menu) _session.get("menu." + leftMenuProperty);
getLeftMenuSettings().setMenu(menu);
- setStaticMenu(menu);
getLeftMenuSettings().setMenuName(menu.getName());
getLeftMenuSettings().setMenuNamespace(menu.getNamespace());
}
return _leftMenuSettings;
}
- /**
- * Get the staticMenu.
- *
- * @return the staticMenu
- */
- public static Menu getStaticMenu() {
- return staticMenu;
- }
-
- /**
- * Set the staticMenu.
- *
- * @param staticMenu
- * the staticMenu to set
- */
- public static void setStaticMenu(final Menu staticMenu) {
- Action.staticMenu = staticMenu;
- }
-
/**
* Set the leftMenuSettings.
*
if (_item == null) { // Switch back to the menu, keeping the last selection
getSession().put("menu.open", menu); // Activates the menu
- _item = menu.getSelection();
- if (_item == null) {
- _item = "none";
+ if (menu != null) {
+ _item = menu.getSelection();
+ if (_item == null) { // Select default menu item if nothing has been selected
+ _item = menu.getDefaultSelection();
+ menu.selects(_item);
+ }
}
} else { // Selection of another menu item
menu.selects(_item);
_selection = name;
}
}
+
+ /**
+ * Get default selection.
+ *
+ * @return the first item name or "none" if the menu is empty
+ */
+ public String getDefaultSelection() {
+ String res = Constants.NONE;
+ if ((!_indices.isEmpty()) && _indices.containsValue(0)) {
+ for (String item : _indices.keySet()) {
+ if (_indices.get(item) == 0) {
+ res = item;
+ break;
+ }
+ }
+ }
+ return res;
+ }
}
\ No newline at end of file
package org.splat.wapp;
-
public class SimpleMenu extends Menu {
-// ==============================================================================================================================
-// Constructors
-// ==============================================================================================================================
+ // ==============================================================================================================================
+ // Constructors
+ // ==============================================================================================================================
+
+ public SimpleMenu(final String name) {
+ // -------------------------------
+ super(name);
+ }
- public SimpleMenu (String name) {
-// -------------------------------
- super(name);
- }
- public SimpleMenu (String name, String scope) {
-// ---------------------------------------------
- super(name, scope);
- }
+ public SimpleMenu(final String name, final String scope) {
+ // ---------------------------------------------
+ super(name, scope);
+ }
-// ==============================================================================================================================
-// Member functions
-// ==============================================================================================================================
+ // ==============================================================================================================================
+ // Member functions
+ // ==============================================================================================================================
- public void addItem (String name, String label, String icon, String url) {
-// ------------------------------------------------------------------------
- this.addItem(name, new MenuItem(label,icon,url) );
- }
+ public void addItem(final String name, final String label,
+ final String icon, final String url) {
+ // ------------------------------------------------------------------------
+ this.addItem(name, new MenuItem(label, icon, url));
+ }
}
\ No newline at end of file
<bean id="titleBarSettings" class="org.splat.simer.TitleBarSettings"
scope="session">
</bean>
-
- <bean id="toolBarSettings"
- class="org.splat.simer.ToolBarSettings" scope="session">
+
+ <bean id="toolBarSettings" class="org.splat.simer.ToolBarSettings"
+ scope="session">
</bean>
-
- <bean id="leftMenuSettings"
- class="org.splat.simer.LeftMenuSettings" scope="session">
+
+ <bean id="leftMenuSettings" class="org.splat.simer.LeftMenuSettings"
+ scope="session">
</bean>
<bean id="slidMenu" scope="session" abstract="true">
<bean id="baseAction" class="org.splat.simer.Action"
scope="prototype" abstract="true">
- <property name="applicationSettings" ref="applicationSettings" />
+ <property name="applicationSettings" ref="applicationSettings" />
<property name="openStudy" ref="openStudy" />
<property name="openKnowledge" ref="openKnowledge" />
<property name="menuBarSettings" ref="menuBarSettings" />
</bean>
<bean id="menuAction" class="org.splat.simer.MenuAction"
- scope="prototype">
+ scope="prototype" parent="baseAction">
</bean>
<bean id="notYetImplementedAction"
<result name="admin-importuser" type="redirectAction">sadmin/select-file?nextAction=importuser</result>
<result name="admin-scontext" type="redirectAction">sadmin/scontext</result>
<result name="admin-knowelm" type="redirectAction">sadmin/knowlelm</result>
- <result name="none">/menu.jsp?menu=%{menu}</result>
+ <!-- If no menu item is selected then go to home page -->
+ <result name="none" type="tiles">page.home</result>
</action>
</package>