HERE IS MY JSP PAGE:
<%@ page language="java" import="org.apache.struts.util.MessageResources,
java.util.*,
utilita.*,
entita.NodoTassonomia,
net.sf.navigator.menu.*,
view.*" %>
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/struts-menu-el.tld" prefix="menu" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/displaytag.tld" prefix="display" %>
<jsp:useBean id="formIndice" scope="request" class="form.FormIndice"/>
<%
String lin = request.getParameter("linguaSelezionata");
String utente = request.getParameter("idUser");
%>
<logic:notEmpty name="formIndice" property="lingua" >
<bean:define id="ling" name="formIndice" property="lingua"
type="java.lang.String" />
<% lin=ling; %>
</logic:notEmpty>
<%
MessageResources messages =
MessageResources.getMessageResources("risorse.ApplicationResources");
String catalogoTradotto =
messages.getMessage("dettagli.catalogo_" + lin);
String prospettoTradotto =
messages.getMessage("dettagli.prospetto_" + lin);
String strumentiTradotto =
messages.getMessage("dettagli.strumenti_" + lin);
String voceMenuEsporta =
messages.getMessage("dettagli.voceMenuEsporta_" + lin);
String voceMenuProspetto =
messages.getMessage("dettagli.voceMenuProspetto_" + lin);
String voceLoad = messages.getMessage("dettagli.load_"
+ lin);
String vaiEsportaTavola =
"javascript:inFinestra('apriPopupEsportaTavola','" + lin +
"','esportaTavola', publicTavola, publicDescr,'550','395','" + utente +
"');";
String tooltipEsporta =
messages.getMessage("dettagli.tooltipEsporta_" + lin);
String tooltipProspetto =
messages.getMessage("dettagli.tooltipProspetto_" + lin);
String linkToIntestazione =
"./ActionIndice.do?evento=loadIntestazione&linguaSelezionata=" + lin +
"&idUser=" + utente;
String linkToMenu =
"./ActionIndice.do?evento=loadRigaMenu&linguaSelezionata=" + lin +
"&idUser=" + utente + "&tipoTavola=";
String linkToInferiore =
"./ActionIndice.do?evento=loadInferiore&linguaSelezionata=" + lin +
"&idUser=" + utente;
String tooltipMenuTradotto = messages.getMessage("dettagli.aprimenu_" +
lin);
String tooltipMenuAperto = messages.getMessage("dettagli.aprimenu_" +
lin);
String tooltipMenuChiuso = messages.getMessage("dettagli.aprimenu_" +
lin);
%>
<html:html>
<head>
<title>Web Dissemination - Banca d'Italia</title>
<%@ include file="nocache.include"%>
<%@ include file="directives.include"%>
<link href="stile/indice.css" rel="stylesheet" type="text/css">
<link href="stile/menuExpandable.css" rel="stylesheet"
type="text/css">
<script src="js/indice.js"></script>
<script type="text/javascript"
src="js/menuExpandable.js"></script>
</head>
<body text="#000666" vlink="#006699" alink="#D78728" topmargin="0"
leftmargin="10" link="#006699" bgproperties="fixed" bgcolor="#FFFFFF"
marginwidth="10" marginheight="0" id="idBody">
<div id="idMain" style="display: block;">
<html:form action="ActionIndice.do" name="formIndice"
type="form.FormIndice">
<html:hidden name="formIndice" property="evento"/>
<html:hidden name="formIndice" property="lingua"/>
<html:hidden name="formIndice" property="idUser"/>
<html:hidden name="formIndice" property="tipoTavola"/>
<html:hidden name="formIndice" property="descrTavola"/>
<script>
loadFrames("<%=linkToIntestazione%>","<%=linkToMenu%>",
"<%=linkToInferiore%>");
</script>
<div id="menubar" onMouseOver="mostraMenu();" onMouseOut="hideMenu();">
<% String MenuProspetto="window.status='"+voceMenuProspetto+"';
return true;"; %>
<% String linkProspetto =
"javascript:rotella('./ActionIndice.do?evento=apriAttesa&linguaSelezionata="+lin+"&idUser="+utente+"&tipoTavola=',publicTavola);";
%>
<div> "<%=linkProspetto% " onMouseOver="<%=MenuProspetto%>"
onMouseOut="window.status='WD'; return true;" title="<%=tooltipProspetto%>"
><%=voceMenuProspetto%> </div>
<% String MenuEsporta="window.status='"+voceMenuEsporta+"'; return
true;"; %>
<div> "<%=vaiEsportaTavola% " onMouseOver="<%=MenuEsporta%>"
onMouseOut="window.status='WD'; return true;" title="<%=tooltipEsporta%>"
><%=voceMenuEsporta%> </div>
</div>
<br />
<% if(WdGen.valorizzato(catalogoTradotto)){ %>
<%=catalogoTradotto %><BR><BR>
<% } %>
<%
String ling = WdComuni.lingua3(lin);
Vector v = ( Vector ) application.getAttribute("TASS_" + ling);
MenuRepository repository = new MenuRepository();
MenuRepository defaultRepository = (MenuRepository)
application.getAttribute(MenuRepository.MENU_REPOSITORY_KEY);
repository.setDisplayers(defaultRepository.getDisplayers());
String onClick=null, onMouseOver=null, linkTavola=null;
onMouseOver="window.status='"+strumentiTradotto+"'; return true;";
//Aggiunge nel repository tutti i topMenus
Iterator i = v.iterator();
while (i.hasNext()) {
NodoTassonomia n = (NodoTassonomia)i.next();
WDMenuComponent mc = new WDMenuComponent();
if(n.getNodoPadre() == null){
mc.setName(n.getDescrizione());
mc.setTitle(n.getDescrizione());
if (n.getRaggruppamento().equals(Boolean.FALSE)) {
linkTavola =
"./ActionIndice.do?evento=apriAttesa&linguaSelezionata="+lin+"&idUser="+utente+"&tipoTavola="+n.getCodiceTavola();
onClick="publicTavola='"+n.getCodiceTavola()+"\';
publicDescr='"+n.getDescrizione().replace('\'',' ')+"';
muovi(this,event,'SI','"+n.getCodiceTavola()+"'); return false;";
mc.setOnclickImage(onClick);
mc.setOnmouseoverImage(onMouseOver);
mc.setOnmouseoutImage("window.status='WD'; return true;");
mc.setOnmouseover("parent.window.status='"+prospettoTradotto+"'; return
true");
mc.setAltImage(strumentiTradotto);
mc.setToolTip(prospettoTradotto);
} else {
mc.setOnmouseover("parent.window.status='"+tooltipMenuTradotto+"'; return
true");
mc.setToolTip(tooltipMenuTradotto);
linkTavola="";
}
mc.setOnmouseout("window.status='WD';");
mc.setLocation(linkTavola);
mc.setCodiceNodo(n.getCodiceNodo());
repository.addMenu(mc);
}
}
/*
mettere sempre un location, eventualmente nullo,
*/
//linkTavola =
"./ActionIndice.do?evento=apriAttesa&linguaSelezionata="+lin+"&idUser="+utente+"&tipoTavola="+n.getCodiceTavola();
//Appende i nodi figli ai padri
Iterator j = v.iterator();
while(j.hasNext()){
NodoTassonomia n = (NodoTassonomia)j.next();
WDMenuComponent mc = new WDMenuComponent();
if(n.getNodoPadre() != null){
mc.setName(n.getDescrizione());
mc.setTitle(n.getDescrizione());
repository.addMenu(mc);
mc.setParent(repository.getMenu(n.getNodoPadre().getDescrizione()));
if (n.getRaggruppamento().equals(Boolean.FALSE)) {
linkTavola =
"./ActionIndice.do?evento=apriAttesa&linguaSelezionata="+lin+"&idUser="+utente+"&tipoTavola="+n.getCodiceTavola();
onClick="publicTavola='"+n.getCodiceTavola()+"\';
publicDescr='"+n.getDescrizione().replace('\'',' ')+"';
muovi(this,event,'SI','"+n.getCodiceTavola()+"'); return false;";
mc.setOnclickImage(onClick);
mc.setOnmouseoverImage(onMouseOver);
mc.setOnmouseoutImage("window.status='WD'; return true;");
mc.setOnmouseover("parent.window.status='"+prospettoTradotto+"'; return
true");
mc.setAltImage(strumentiTradotto);
mc.setToolTip(prospettoTradotto);
} else {
mc.setOnmouseover("parent.window.status='"+tooltipMenuTradotto+"'; return
true");
mc.setToolTip(tooltipMenuTradotto);
linkTavola="";
}
mc.setOnmouseout("window.status='WD';");
mc.setLocation(linkTavola);
mc.setCodiceNodo(n.getCodiceNodo());
}
}
pageContext.setAttribute("repository", repository);
//Impostazione apertura iniziale dell'albero
MessageResources costanti =
MessageResources.getMessageResources("risorse.costanti");
String aperturaIniziale =
costanti.getMessage("tassonomia.aperturaIniziale");
pageContext.setAttribute("aperturaInizialeTassonomia", new
Integer(aperturaIniziale));
// Ogniqualvolta accediamo alla homepage scriviamo una riga sul
file di LOG
String funz = "HOMEPAGE";
String campoOggetto = "";
String campoParametro = "";
String idPaddato = utente;
String adesso = WdComuni.dataOggi("dd/MM/yyyy HH:mm:ss");
WdComuni.scriviLogApp(application, ling, "4937WD", funz,
campoOggetto, campoParametro, idPaddato, adesso, "-");
%>
<menu:useMenuDisplayer name="displayer" repository="repository"
config="risorse.MenuDisplayer">
<c:forEach var="menu" items="${pageScope.repository.topMenus}">
<menu:displayMenu name="${menu.name}"/>
</c:forEach>
</menu:useMenuDisplayer>
</html:form>
<p> </p>
<p> </p>
<p> </p>
<html:errors />
</div>
</body>
</html:html>
HERE IS JAVASCRIPT FILE:
/*
* menuExpandable2.js - implements an expandable menu based on a HTML list
* Author: Dave Lindquist ([email protected])
*/
if (!document.getElementById) {
document.getElementById = function() { return null; }
}
var menuCookie = "menusToExpand";
var itemCookie = "itemToHighlight";
var tooltip;
function initializeMenu(menuId, actuatorId) {
var menu = document.getElementById(menuId);
var actuator = document.getElementById(actuatorId);
if (menu == null || actuator == null) return;
//if (window.opera) return; // I'm too tired
actuator.parentNode.style.backgroundImage = "url(immagini/plus.gif)";
actuator.onclick = function() {
var display = menu.style.display;
this.parentNode.style.backgroundImage =
(display == "block") ? "url(immagini/plus.gif)" :
"url(immagini/minus.gif)";
menu.style.display = (display == "block") ? "none" : "block";
// Begin custom code for remembering expanded menus with cookies
var menusToExpand = getCookie(menuCookie);
if (menu.style.display == "block") {
// set a cookie to keep the menu expanded
if (menusToExpand == null) {
setCookie(menuCookie,menuId);
//alert("APERTO");
tooltip = "chiudi";
} else if (menusToExpand.indexOf(menuId) == -1) {
setCookie(menuCookie,menusToExpand+","+menuId);
//alert("APERTO");
tooltip = "chiudi";
}
} else {
// remove it from the expanded cookie list
if (menusToExpand.indexOf(menuId) != -1) {
// check for comma after menu
if (menusToExpand.indexOf(menuId+",") != -1) {
menusToExpand = menusToExpand.replace(menuId+",","");
//alert("CHIUSO");
tooltip = "apri";
} else {
menusToExpand = menusToExpand.replace(menuId,"");
//alert("CHIUSO");
tooltip = "apri";
}
if (menusToExpand == "") {
deleteCookie(menuCookie);
} else {
setCookie(menuCookie,menusToExpand);
}
}
}
// End custom code
return false;
}
}
// This function loops through all the <ul>'s in the document and
// initializes the menus for them if they have menu classes
function initializeMenus() {
var uls = document.getElementsByTagName("ul");
for (i = 0; i < uls.length; i++) {
if (uls[i].className == "menuList") {
decorateMenu(uls[i]);
}
}
// user must have cookies enabled for this to work
expandMenus();
}
function decorateMenu(menu) {
var links = menu.getElementsByTagName("a");
var lists = document.getElementsByTagName("ul");
var actuators = new Array();
var nonActuators = new Array();
// build an array of actuators
for (i=0; i < links.length; i++) {
if (links[i].className == "actuator") {
actuators[actuators.length] = links[i];
} else {
nonActuators[nonActuators.length] = links[i];
}
}
var menus = new Array();
// build an array of menus
for (i=0; i < lists.length; i++) {
if (lists[i].className == "menu" || lists[i].className == "submenu")
{
menus[menus.length] = lists[i];
}
}
// initialize actuators and menus (number should be the same)
for (i=0; i < actuators.length; i++) {
initializeMenu(menus[i].id, actuators[i].id);
}
// Begin custom code to remember last item clicked (with cookies)
// add an onclick event to set a cookie on the non-actuators
for (i=0; i < nonActuators.length; i++) {
// retain any existing onclick handlers from menu-config.xml
if (nonActuators[i].onclick) {
nonActuators[i].onclick=function() {
setCookie(itemCookie,this.href);
if (eval(this.getAttribute("onclick")) == false) {
return false;
}
};
} else {
nonActuators[i].onclick=function() {
setCookie(itemCookie,this.href);
};
}
}
}
function openMenu(menuId) {
var menu = document.getElementById(menuId);
var actuatorId = menuId.substring(0, menuId.indexOf("Menu")) +
"Actuator";
var actuator = document.getElementById(actuatorId);
if (menu != null) {
var display = menu.style.display;
menu.parentNode.style.backgroundImage = "url(immagini/minus.gif)";
menu.style.display = (display == "block") ? "none" : "block";
}
}
function expandMenus() {
var menusToExpand = getCookie(menuCookie);
if (menusToExpand != null) {
// if more than one menu has been menusToExpanded,
// create an array of menusToExpanded menus
if (menusToExpand.indexOf(",") != -1) {
menuArray = menusToExpand.split(",");
for (var i=0; i < menuArray.length; i++) {
openMenu(menuArray[i]);
}
} else {
openMenu(menusToExpand);
}
}
var itemToHighlight = getCookie(itemCookie);
var links = document.getElementsByTagName("a");
// add an onclick event to set a cookie on the non-actuators
for (i=0; i < links.length; i++) {
if (links[i].href == itemToHighlight) {
links[i].className += " highlight";
}
}
}
// =========================================================================
// Cookie functions
// =========================================================================
/* This function is used to set cookies */
function setCookie(name,value,expires,path,domain,secure) {
document.cookie = name + "=" + escape (value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
}
/* This function is used to get cookies */
function getCookie(name) {
var prefix = name + "="
var start = document.cookie.indexOf(prefix)
if (start==-1) {
return null;
}
var end = document.cookie.indexOf(";", start+prefix.length)
if (end==-1) {
end=document.cookie.length;
}
var value=document.cookie.substring(start+prefix.length, end)
return unescape(value);
}
/* This function is used to delete cookies */
function deleteCookie(name,path,domain) {
if (getCookie(name)) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
/* You can call initializeMenus() manually from your JSP if this doesn't
work.
* Just put the following code after the last menu tag.
* <script type="text/javascript">
* initializeMenus();
* </script>
*/
window.onload = initializeMenus;
HERE IS A SCREENSHOT OF THE PAGE WITH MENU:
http://www.postimage.org/image.php?v=Pq7d5LJ
My problem is to set the tooltip (apri/chiudi sottomenu) to OPEN if the menu
is closed and CLOSE if the menu is opened.
Thank you for help me!
> I will post code as soon as I can.
> I set the tooltip in a java code in my jsp page (in the jsp there is the
> code that generates the menu).
> I get the values from a .proprties file.
>
> here is a portion of the java code in my jsp:
> ..........
> Iterator<Nodo> i = lista.iterator();
> while (i.hasNext()) {
> Nodo n = i.next();
> MenuComponent mc = new MenuComponent();
> if(n.getNodoPadre() == null && n.getRaggr().equals(Boolean.TRUE)){
> mc.setName(n.getDesRaggr());
> mc.setTitle(n.getDesRaggr());
> mc.setToolTip("message2");
> repository.addMenu(mc);
> } else {
> mc.setName(n.getDesRaggr());
> mc.setTitle(n.getDesRaggr());
> mc.setToolTip("message2");
> repository.addMenu(mc);
> }
> }
> ..........
>
> my problem is to get the tooltip value in a dynamic way, "open" if menu is
> closed "close" if the menu is opened. passing values from javascript
> (menuExpandable.js) to the code above.
>
> Thank you so!
>
>
> Matt Raible-3 wrote:
> >
> > Are you setting the tooltip in menu-config.xml or some other way?
> > Currently, I don't understand your problem well enough to help you
> > solve it. Posting code and screenshots usually helps a lot.
> >
> > Matt
> >
> > On Jan 21, 2009, at 1:56 PM, stevieray81 wrote:
> >
> >>
> >> I can't post it at the moment.
> >> I'm using ListMenuDisplayer with menuExpandable.js and I had to set
> >> the
> >> tooltip in a java code in a jsp page.
> >> Thank you
> >>
> >>
> >> Matt Raible-3 wrote:
> >>>
> >>> Can you post you project to a URL I can look at? What displayer/menu
> >>> are you using?
> >>>
> >>> Matt
> >>>
> >>> On Jan 21, 2009, at 11:43 AM, stevieray81 <[email protected]>
> >>> wrote:
> >>>
> >>>>
> >>>> Thank you.
> >>>> baut I see that tooltip is setted in the code in jsp page, how can I
> >>>> get
> >>>> informations from javascript to my java code?
> >>>> sorry, I don't understand.
> >>>>
> >>>>
> >>>> Matt Raible-3 wrote:
> >>>>>
> >>>>> You should be able to use JavaScript to do this. It's all HTML, CSS
> >>>>> and JavaScript in the end.
> >>>>>
> >>>>> Matt
> >>>>>
> >>>>> On Jan 21, 2009, at 11:25 AM, stevieray81 wrote:
> >>>>>
> >>>>>>
> >>>>>> Hello,
> >>>>>> I'm working on an existing prject.
> >>>>>> There's a javascript file that perform open and close menu actions
> >>>>>> (struts-menu).
> >>>>>> I have to change menu tooltip in "CLOSE" if the menu is opened and
> >>>>>> "OPEN" if
> >>>>>> the menu is closed.
> >>>>>> The code that creates menu and set the tooltips is included in a
> >>>>>> scriptlet
> >>>>>> in a jsp page.
> >>>>>> How can I retrieve the information on menu status (open or close)
> >>>>>> and use it
> >>>>>> to set the tooltip in my java code?
> >>>>>>
> >>>>>> Thank you very much.
> >>>>>>
> >>>>>> p.s.
> >>>>>> sorry but english is not my first language
> >>>>>> --
> >>>>>> View this message in context:
> >>>>>> http://www.nabble.com/struts-menu-tooltip-tp21589154p21589154.html
> >>>>>> Sent from the struts-menu-user mailing list archive at Nabble.com.
> >>>>>>
> >>>>>>
> >>>>>> ---
> >>>>>> ---
> >>>>>> ---
> >>>>>> ---
> >>>>>> ------------------------------------------------------------------
> >>>>>> This SF.net email is sponsored by:
> >>>>>> SourcForge Community
> >>>>>> SourceForge wants to tell your story.
> >>>>>> http://p.sf.net/sfu/sf-spreadtheword
> >>>>>> _______________________________________________
> >>>>>> struts-menu-user mailing list
> >>>>>> [email protected]
> >>>>>> https://lists.sourceforge.net/lists/listinfo/struts-menu-user
> >>>>>
> >>>>>
> >>>>> ---
> >>>>> ---
> >>>>> ---
> >>>>>
> ---------------------------------------------------------------------
> >>>>> This SF.net email is sponsored by:
> >>>>> SourcForge Community
> >>>>> SourceForge wants to tell your story.
> >>>>> http://p.sf.net/sfu/sf-spreadtheword
> >>>>> _______________________________________________
> >>>>> struts-menu-user mailing list
> >>>>> [email protected]
> >>>>> https://lists.sourceforge.net/lists/listinfo/struts-menu-user
> >>>>>
> >>>>>
> >>>>
> >>>> --
> >>>> View this message in context:
> >>>> http://www.nabble.com/struts-menu-tooltip-tp21589154p21589540.html
> >>>> Sent from the struts-menu-user mailing list archive at Nabble.com.
> >>>>
> >>>>
> >>>> ---
> >>>> ---
> >>>> ---
> >>>> ---------------------------------------------------------------------
> >>>> This SF.net email is sponsored by:
> >>>> SourcForge Community
> >>>> SourceForge wants to tell your story.
> >>>> http://p.sf.net/sfu/sf-spreadtheword
> >>>> _______________________________________________
> >>>> struts-menu-user mailing list
> >>>> [email protected]
> >>>> https://lists.sourceforge.net/lists/listinfo/struts-menu-user
> >>>
> >>>
> ------------------------------------------------------------------------------
> >>> This SF.net email is sponsored by:
> >>> SourcForge Community
> >>> SourceForge wants to tell your story.
> >>> http://p.sf.net/sfu/sf-spreadtheword
> >>> _______________________________________________
> >>> struts-menu-user mailing list
> >>> [email protected]
> >>> https://lists.sourceforge.net/lists/listinfo/struts-menu-user
> >>>
> >>>
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/struts-menu-tooltip-tp21589154p21591991.html
> >> Sent from the struts-menu-user mailing list archive at Nabble.com.
> >>
> >>
> >>
> ------------------------------------------------------------------------------
> >> This SF.net email is sponsored by:
> >> SourcForge Community
> >> SourceForge wants to tell your story.
> >> http://p.sf.net/sfu/sf-spreadtheword
> >> _______________________________________________
> >> struts-menu-user mailing list
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/struts-menu-user
> >
> >
> >
> ------------------------------------------------------------------------------
> > This SF.net email is sponsored by:
> > SourcForge Community
> > SourceForge wants to tell your story.
> > http://p.sf.net/sfu/sf-spreadtheword
> > _______________________________________________
> > struts-menu-user mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/struts-menu-user
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/struts-menu-tooltip-tp21589154p21593618.html
> Sent from the struts-menu-user mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> _______________________________________________
> struts-menu-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/struts-menu-user
>
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
struts-menu-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/struts-menu-user
--
View this message in context:
http://www.nabble.com/struts-menu-tooltip-tp21589154p21605252.html
Sent from the struts-menu-user mailing list archive at Nabble.com.
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
struts-menu-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/struts-menu-user