Collection<UserviewMenu> menus = new ArrayList<UserviewMenu>();
for (int j = 0; j < menusArray.length(); j++) {
try {
//set menu
JSONObject menuObj = (JSONObject) menusArray.get(j);
UserviewMenu menu = (UserviewMenu) pluginManager.getPlugin(menuObj.getString("className"));
// check for mobile support
boolean isMobileView = MobileUtil.isMobileView();
if (isMobileView && (menu instanceof MobileElement) && !((MobileElement)menu).isMobileSupported()) {
// mobile not supported, skip this menu
continue;
}
menu.setProperties(PropertyUtil.getPropertiesValueFromJson(menuObj.getJSONObject("properties").toString()));
menu.setRequestParameters(requestParameters);
menu.setUserview(userview);
String mId = getMenuId(menu);
menu.setProperty("menuId", mId);
if (preview) {
menu.setUrl(contextPath + "/web/console/app/" + appId + "/" + appVersion + "/userview/builderPreview/" + userview.getPropertyString("id") + "/" + mId);
} else {
menu.setKey(key);
String prefix = "/web/userview/";
if (embed) {
prefix = "/web/embed/userview/";
}
menu.setUrl(contextPath + prefix + appId + "/" + userview.getPropertyString("id") + "/" + ((key != null) ? URLEncoder.encode(key, "UTF-8") : "") + "/" + mId);
}
//set Current, if current menu id is empty, search the 1st valid menu
if ((("".equals(menuId) || menuId == null) && userview.getCurrent() == null && menu.isHomePageSupported())
|| (menuId != null && menuId.equals(mId))) {
userview.setCurrent(menu);
userview.setCurrentCategory(category);
}
//set home menu Id
if (userview.getPropertyString("homeMenuId") == null || userview.getPropertyString("homeMenuId").isEmpty() && menu.isHomePageSupported()) {
userview.setProperty("homeMenuId", mId);
}
menus.add(menu);
} catch (Exception e) {