HOW I CREATE POPUP MENU ON MOUSE OVER

hello every bodymy question is how to create popupmenu on mouse over on table column data in studio creator. please help me thanks
[158 byte] By [RAVIGANG1981] at [2007-11-26 7:50:12]
# 1

In my own xperience, we cant create a popup menu as we drop a button component in creator, u should work into jsp code to make it work, i suggest u to copy some free examples in the web, and past it in the jsp, depending on what u want to do, i have an example that works great on image component, if ur interested post again.

Beltazor.

Beltazor at 2007-7-6 20:07:48 > top of Java-index,Development Tools,Java Tools...
# 2
Hi,I am trying to create popup menu but no joy.I would really appreciate if you could post the example you got.Thanks a lot.Cheers
kush at 2007-7-6 20:07:48 > top of Java-index,Development Tools,Java Tools...
# 3
thanks Beltazor for halping meif you able to send your example then plz send it.and also send "copy some free examples on the web",thanks againraviraj
RAVIGANG1981 at 2007-7-6 20:07:48 > top of Java-index,Development Tools,Java Tools...
# 4

ok this examples runs great on image component, in button or hyperlynk dont work finee or i can find how, paste this code in the head of the jsp code:

<script type="text/javascript"><![CDATA[

var opt=0;

/***********************************************

* AnyLink Drop Down Menu- ?Dynamic Drive (www.dynamicdrive.com)

* This notice MUST stay intact for legal use

* Visit http://www.dynamicdrive.com/ for full source code

***********************************************/

//Contents for menu 1

var menu1=new Array()

menu1[0]='<a href="./faces/info.jsp">Information<\/a>'

menu1[1]='<a href="./faces/edit.jsp">Edit<\/a>'

menu1[2]='<a href="./faces/del.jsp">Delete<\/a>'

//Contents for menu 2, and so on

var menu2=new Array()

menu2[0]='<a href="">Infor<\/a>'

menu2[1]='<a href="">Edit<\/a>'

menu2[2]='<a href="">Del<\/a>'

var menuwidth='165px' //default menu width

var menubgcolor='lightyellow' //menu bgcolor

var disappeardelay=250 //menu disappear speed onMouseout (in miliseconds)

var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all

var ns6=document.getElementById&&!document.all

if (ie4||ns6)

document.write('><div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"><\/div>')

function getposOffset(what, offsettype){

var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;

var parentEl=what.offsetParent;

while (parentEl!=null){

totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;

parentEl=parentEl.offsetParent;

}

return totaloffset;

}

function showhide(obj, e, visible, hidden, menuwidth){

if (ie4||ns6)

dropmenuobj.style.left=dropmenuobj.style.top="-500px"

if (menuwidth!=""){

dropmenuobj.widthobj=dropmenuobj.style

dropmenuobj.widthobj.width=menuwidth

}

if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")

obj.visibility=visible

else if (e.type=="click")

obj.visibility=hidden

}

function iecompattest(){

return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body

}

function clearbrowseredge(obj, whichedge){

var edgeoffset=0

if (whichedge=="rightedge"){

var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15

dropmenuobj.contentmeasure=dropmenuobj.offsetWidth

if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)

edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth

}

else{

var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset

var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18

dropmenuobj.contentmeasure=dropmenuobj.offsetHeight

if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?

edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight

if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?

edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge

}

}

return edgeoffset

}

function populatemenu(what){

if (ie4||ns6)

dropmenuobj.innerHTML=what.join("")

}

function dropdownmenu(obj, e, menucontents, menuwidth){

if (window.event) event.cancelBubble=true

else if (e.stopPropagation) e.stopPropagation()

clearhidemenu()

dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv

populatemenu(menucontents)

if (ie4||ns6){

showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)

dropmenuobj.x=getposOffset(obj, "left")

dropmenuobj.y=getposOffset(obj, "top")

dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"

dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"

}

return clickreturnvalue()

}

function clickreturnvalue(){

if (ie4||ns6) return false

else return true

}

function contains_ns6(a, b) {

while (b.parentNode)

if ((b = b.parentNode) == a)

return true;

return false;

}

function dynamichide(e){

if (ie4&&!dropmenuobj.contains(e.toElement))

delayhidemenu()

else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))

delayhidemenu()

}

function hidemenu(e){

if (typeof dropmenuobj!="undefined"){

if (ie4||ns6)

dropmenuobj.style.visibility="hidden"

}

}

function delayhidemenu(){

if (ie4||ns6)

delayhide=setTimeout("hidemenu()",disappeardelay)

}

function clearhidemenu(){

if (typeof delayhide!="undefined")

clearTimeout(delayhide)

}

if (hidemenu_onclick=="yes")

document.onclick=hidemenu

]]></script>

Next, paste this in css stylesheet:

#dropmenudiv{

position:absolute;

border:1px solid black;

border-bottom-width: 0;

font:normal 12px Verdana;

line-height:18px;

z-index:100;

}

#dropmenudiv a{

width: 100%;

display: block;

text-indent: 3px;

border-bottom: 1px solid black;

padding: 1px 0;

text-decoration: none;

font-weight: bold;

}

#dropmenudiv a:hover{

/*hover background color*/

background-color: #faebeb

}

and in the image componen in event onClick paste this

dropdownmenu(this, event, menu1, '150px')

onMouseOut event paste this:

delayhidemenu()

this should works, and as u can see, u can get more examples like this in the DHTML page. I hope it helps

Plz tell me if this is what ur looking for, oor if u need help, post again

Beltazor

Beltazor at 2007-7-6 20:07:48 > top of Java-index,Development Tools,Java Tools...
# 5
thanks Beltazor butyour code not working on my brouser because when i run the program IE show an error and no popup open on mouse over.can you explain why it is not workthanksraviraj
RAVIGANG1981 at 2007-7-6 20:07:48 > top of Java-index,Development Tools,Java Tools...
# 6

Can u tell me what kind of error u find in IE, because i've used in mozilla from solaris, safari from mac, and IE and firefox from windows and it works great, maybe its a mistake when i copy & paste it here u can see the full code in the next link:

http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm

Beltazor

Beltazor at 2007-7-6 20:07:48 > top of Java-index,Development Tools,Java Tools...
# 7
I ran the code under IE and it works exactly as described for me.
starwood4 at 2007-7-6 20:07:48 > top of Java-index,Development Tools,Java Tools...
# 8
hi starwood4 can you explain how you use this code on your IDEthanksraviraj
RAVIGANG1981 at 2007-7-6 20:07:48 > top of Java-index,Development Tools,Java Tools...
# 9
thanks Beltazor for your helpraviraj
RAVIGANG1981 at 2007-7-6 20:07:48 > top of Java-index,Development Tools,Java Tools...
# 10
hello Beltazor ,I've been using a similar method for menu's which worked great on firefox but not in IE, your method is much better, excellent post. Thanks very muchGaz
b0wm0re at 2007-7-6 20:07:48 > top of Java-index,Development Tools,Java Tools...
# 11

mmmm...

I'm trying to get it work...

how can I do that?

here is what I do:

create a new page, put an image, copy and paste your code... and it says :

The markup in the document following the root element must be well formed...

here is my jsp code:

//here is where I put your code

<?xml version="1.0" encoding="UTF-8"?>

<jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:ui="http://www.sun.com/web/ui">

<jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>

<f:view>

<ui:page binding="#{prova.page1}" id="page1">

<ui:html binding="#{prova.html1}" id="html1">

<ui:head binding="#{prova.head1}" id="head1">

<ui:link binding="#{prova.link1}" id="link1" url="/resources/stylesheet.css"/>

</ui:head>

<ui:body binding="#{prova.body1}" id="body1" style="-rave-layout: grid">

<ui:form binding="#{prova.form1}" id="form1">

<ui:image binding="#{prova.image1}" id="image1" style="left: 72px; top: 72px; position: absolute" url="/resources/Corsewall point lighthouse - west Scotland , 5434.jpg"/>

</ui:form>

</ui:body>

</ui:html>

</ui:page>

</f:view>

</jsp:root>

what's wrong?

do I have to put code anywhere else?

hope you can help me!!

gio_mori at 2007-7-6 20:07:48 > top of Java-index,Development Tools,Java Tools...
# 12

ok, now it works... it was my fault!(stupid error)

one last thing: I've created a .js file with javascript code, put in a page fragment (tabs) and it works, unfortunately the popup menu is shown under the others elements in the rendered page... is there any way to say it "bring to front"?

(z-index seems not to work using page fragments and jscript)

gio_mori at 2007-7-6 20:07:48 > top of Java-index,Development Tools,Java Tools...
# 13
hi! dat was ok but i needed javascript code to link the contents of table(image as table data) with dropdown menu on mouseover
prachisahai at 2007-7-6 20:07:48 > top of Java-index,Development Tools,Java Tools...