7 Replies Latest reply on Apr 2, 2008 5:42 PM by Sergey Smirnov

    RichContextMenu - Javascript error

    Amol Desai Newbie

      Hi there, I have following code which should help me zoom-in / zoom-out a image. I can see "Zoom-in" and "Zoom-out" menu when I right-click. However, when I click on the menu, get a havascript error: "document.getElementById(...) is null or not an object".

      Please help.



      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich">
      
      
       <script type="text/javascript">
       function enlarge(){
       alert('enlarge');
      
       document.getElementById('pic').width=document.getElementById('pic').width*1.1;
       document.getElementById('pic').height=document.getElementById('pic').height*1.1;
       }
       function decrease(){
       alert('decrease');
       document.getElementById('pic').width=document.getElementById('pic').width*0.9;
       document.getElementById('pic').height=document.getElementById('pic').height*0.9;
       }
       </script>
      
      
      
       <h:form id="form1" name="form1">
       <h:panelGrid columns="1" columnClasses="cent">
       <h:panelGroup id="picture">
       <h:graphicImage value="/images/projects.jpg" id="pic"/>
       <rich:contextMenu event="oncontextmenu" attached="true" submitMode="none">
       <rich:menuItem value="Zoom In" onclick="enlarge();" id="zin"></rich:menuItem>
       <rich:menuItem value="Zoom Out" onclick="decrease();" id="zout"></rich:menuItem>
       </rich:contextMenu>
       </h:panelGroup>
       </h:panelGrid>
       </h:form>
      
      
      
      </ui:composition>
      


      thanks for your help.
      -Amol