I'm trying to get the applicationContext of my web app which is defined on jboss-web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<context-root>/Tesoreria-WEB</context-root>
<max-active-sessions>300</max-active-sessions>
</jboss-web>
Is there a way to get that String Tesoreria-WEB? I need it because my menus aren't adding that part of the url anymore after upgrading from 3.5 to 7.0, so im gonna get that context and add it before they are created. I had tried with:
System.out.println("Application name: "+ PrimeRequestContext.getCurrentInstance(FacesContext.getCurrentInstance()).getApplicationContext());
but no success, is there a way or should I add it manually? thanks!
By the way I think they stopped adding correctly the url after upgrading to 7.0 from 3.5 because of https://github.com/primefaces/primefaces/wiki/Migration-Guide breaking changes from 6.2 to 7.0 says "Button/Link/MenuItem: The url/href attribute isn't automatically prepended by contextPath anymore. Use the outcome attribute for referencing JSF views in the same application or manually prepend url/href with #{request.contextPath}. See https://github.com/primefaces/primefaces/issues/3506." But I don't understand what does that mean.
how I expect my url to be built (notice Tesoreria-WEB on the url): http://10.13.44.48:8483/Tesoreria-WEB/XHTML/boxes/boxesMassive.xhtml
how they are being built since I upgraded to 7.0 (this brings 404): http://10.13.44.48:8483/XHTML/boxes/boxesMassive.xhtml
I dynamically made my menuBar on the ManagedBean and on the xhtml I call reference it like this, that's all no menuItems no things like that all is made on the ManagedBean:
<p:menubar id="menuBar" binding="#{menuMB.menuBar}"
autoDisplay="false" styleClass="cds-menu-mainmenu"
rendered="#{plantillaGeneralMB.habilitarMenu}" />
This is how we dynamically make the menu, while debugging I found where exactly they get their url, its a bit down there I commented where in English:
this Node objects are from org.w3c.dom.Node
private List<SubMenuItem> cargarSubmenus(Node pNodeMenu,
List<String[]> lJerarquiaTemp, String[] tituloPadre) {
Node nodeSubMenu = null;
// Obtener la lista de hijos de este nodo.
NodeList childNodes = pNodeMenu.getChildNodes();
int sizeList = childNodes.getLength();
List<SubMenuItem> lSubmenus = new ArrayList<>();
SubMenuItem subMenu = null;
lJerarquiaTemp.add(tituloPadre);
for (int i = 0; i < sizeList; i++) {
// Obtener el hijo de este nodo correspondiente al indice indicado.
nodeSubMenu = childNodes.item(i);
// Verificar que efectivamente este nodo sea un Submenu
if (nodeSubMenu.getNodeName().equals("SUBMENU")) {
// Verificar que el nodo tenga atributos.
if (nodeSubMenu.hasAttributes()) {
NamedNodeMap map = nodeSubMenu.getAttributes();
// Obtener codigo.
Node codigo = map.item(0);
// Obtener titulo
String titulo = nodeSubMenu.getChildNodes().item(1)
.getTextContent();
// THIS IS THE URL **********************
String url = nodeSubMenu.getChildNodes().item(3)
.getTextContent();
// Im having to add "/Tesoreria-WEB" + url to make my urls well constructed, no idea what changed so much from 3.5 to 7.0 here if someone knows how to make it work without adding this manually its appreciated
subMenu = new SubMenuItem(codigo.getTextContent(), titulo,
"/Tesoreria-WEB"+url);
System.out.println("Application name: "+ PrimeRequestContext.getCurrentInstance(FacesContext.getCurrentInstance()).getApplicationContext());
subMenu.setlJerarquia(lJerarquiaTemp);
String[] menuInfo = { codigo.getTextContent(), titulo, url };
// Si esta nodo tiene mas hijos llamar recursivamente este
// metodo.
if (nodeSubMenu.getChildNodes().item(5) != null
&& nodeSubMenu.getChildNodes().item(5)
.getNodeName().equals("SUBMENU")) {
subMenu.setlSubmenus(cargarSubmenus(nodeSubMenu,
subMenu.getlJerarquia(), menuInfo));
}
if (nodeSubMenu.getChildNodes().item(5) != null
&& nodeSubMenu.getChildNodes().item(5)
.getNodeName().equals("TABS")) {
subMenu.setlTabs(cargarTabs(nodeSubMenu.getChildNodes()
.item(5)));
}
// Adicionar este submenu y sus hijos a la lista de submenus
// del nodo original.
lSubmenus.add(subMenu);
}
}
}
return lSubmenus;
}