import javax.servlet.http.HttpServletRequest;
+import eu.svjatoslav.commons.network.Locale;
+import eu.svjatoslav.commons.network.LocaleHelper;
+
public class Navigation {
private NavigationItem rootNavigationItem;
public String getTopMenu(final HttpServletRequest request) {
+ final Locale currentLocale = LocaleHelper.detectLocale(request);
+
final NavigationItem selectedItem = getSelectedItem(request);
final StringBuffer result = new StringBuffer();
+ getGetNotNullString(item.getCssPrefix())
+ "menuItem\" href=\"" + item.getLinkUrl() + "\">");
- result.append("<div>" + item.getTitle() + "</div>");
+ result.append("<div>" + item.getTitle(currentLocale) + "</div>");
result.append("</a>");
}
public String getTitle() {
if (localeToTitle.size() != 1)
- throw new RuntimeException("there shall be exactly one title");
+ throw new RuntimeException(
+ "NavigationItem.getTitle() was called without locale parameter, but there there are multiple titles in diffirent locales available.");
return localeToTitle.values().iterator().next();
}