Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 668085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:00:05+00:00 2026-05-14T00:00:05+00:00

Using Richfaces 3.3.0GA, jsf 1.2_14 and facelets. I have a richfaces ModalPanel with an

  • 0

Using Richfaces 3.3.0GA, jsf 1.2_14 and facelets.

I have a richfaces ModalPanel with an image inside as follows:

<ui:composition>
        <a4j:outputPanel id="#{prefix}_a4jImagePanel">
        <rich:modalPanel id="#{prefix}_imagePanel" autosized="true" domElementAttachment="body" rendered="#{examinationPanel.render}">
            <f:facet name="header">
                <h:outputText value="Images from examination" />
            </f:facet>
            <f:facet name="controls">
                <h:panelGroup>
                    <h:graphicImage value="/images/modal/close.png" id="#{prefix}_hideimagelink" styleClass="hidelink" />
                    <rich:componentControl for="#{prefix}_imagePanel" attachTo="#{prefix}_hideimagelink" operation="hide" event="onclick" />
                </h:panelGroup>
            </f:facet>
            <a4j:form>

                <h:panelGrid columns="1" id="picture">

                        <!-- big image here -->
                        <rich:dragSupport ondragstart="startDrag(event)" ondragend="stopDrag(event)">
                        <h:graphicImage id="#{prefix}_pic" value="#{examinationPanel.imagePath}"  onmousedown="startDrag(event)" onmouseup="stopDrag(event)" /></rich:dragSupport>

                        <rich:contextMenu event="oncontextmenu" attachTo="#{prefix}_pic" submitMode="none">
                            <rich:menuItem value="Zoom In" onclick="enlarge();" id="zin"/>
                            <rich:menuItem value="Zoom Out" onclick="decrease();" id="zout"/>
                        </rich:contextMenu>

                </h:panelGrid>
            </a4j:form>
        </rich:modalPanel>
        </a4j:outputPanel>
    <script type="text/javascript">
    //adding the event listerner for Mozilla

        if(window.addEventListener)
            document.addEventListener('DOMMouseScroll', zoomScroll, false);
        //for IE/OPERA etc
        document.onmousewheel = zoomScroll;
            var startX;
            var startY;
            function enlarge(){
                   #{rich:element(fnc:concat(prefix,'_pic'))}.width=#{rich:element(fnc:concat(prefix,'_pic'))}.width*1.25;
            }
            function decrease(){
                   #{rich:element(fnc:concat(prefix,'_pic'))}.width=#{rich:element(fnc:concat(prefix,'_pic'))}.width*0.8;
            }
            function zoomScroll(event){
                var delta = 0;

                if (!event) event = window.event;

                // normalize the delta
                if (event.wheelDelta) {

                    // IE and Opera
                    delta = event.wheelDelta / 60;

                } else if (event.detail) {

                    // W3C
                    delta = -event.detail / 2;
                }
                if(delta>0)enlarge();
                else decrease();
            }

            function startDrag(event){ 

                startX = event.clientX;
                startY = event.clientY;


                }
            function stopDrag(event){

                var diff = new ModalPanel.Sizer.Diff();
                diff.deltaHeight=0;
                diff.deltaWidth=0;
                diff.deltaX = -startX+event.clientX;
                diff.deltaY = -startY+event.clientY;

                #{rich:element(fnc:concat(prefix,'_imagePanel'))}.component.doResizeOrMove(diff);
                }
    </script>
    </ui:composition>

I want the image to be zoomable (hence the enlarge() and decrease() functions) and dragable. This code works partially. If you DND before zooming it works correctly but after that it stops working. By the way, I can’t see a preview of the dragging though. I would like to implement the same DND that the title of the modalPanel uses (that gives the impresion to move a real window, you see the window contents moving as you drag).

How can I achieve it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:00:05+00:00Added an answer on May 14, 2026 at 12:00 am

    I couldn’t get it work with richfaces modalPanel but I could get it work with primefaces dialog, which is quite similar. Here’s the solution:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html 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" xmlns:fn="http://java.sun.com/jsp/jstl/functions" xmlns:c="http://java.sun.com/jsp/jstl/core"
        xmlns:fnc="http://eyeprevent.com/fnc" xmlns:p="http://primefaces.prime.com.tr/ui">
        <head>
                <script type="text/javascript">
        //adding the event listerner for Mozilla
    
            if(window.addEventListener)
                document.addEventListener('DOMMouseScroll', zoomScroll, false);
            //for IE/OPERA etc
            document.onmousewheel = zoomScroll;
                var startX;
                var startY;
                function enlarge(){
                       #{rich:element('pic')}.width=#{rich:element('pic')}.width*1.25;
                }
                function decrease(){
                    #{rich:element('pic')}.width=#{rich:element('pic')}.width*0.8;
                }
                function zoomScroll(event){
                    var delta = 0;
    
                    if (!event) event = window.event;
    
                    // normalize the delta
                    if (event.wheelDelta) {
    
                        // IE and Opera
                        delta = event.wheelDelta / 60;
    
                    } else if (event.detail) {
    
                        // W3C
                        delta = -event.detail / 2;
                    }
                    if(delta>0)enlarge();
                    else decrease();
                }
        </script>
    
        </head><body>
        <p:resources /> 
    
            <a4j:outputPanel id="a4jImagePanel">
            <p:dialog id="imagePanel" widgetVar="dialog">
           <p:draggable dragOnly="true" underlay="none"/>  
                <a4j:form>
                    <h:panelGrid columns="1" id="picture">
    
                            <!-- big image here -->
    
                            <h:graphicImage id="pic" value="/images/eye.jpg"></h:graphicImage>
    
                            <rich:contextMenu event="oncontextmenu" attachTo="pic" submitMode="none">
                                <rich:menuItem value="Zoom In" onclick="enlarge();" id="zin"/>
                                <rich:menuItem value="Zoom Out" onclick="decrease();" id="zout"/>
    
                            </rich:contextMenu>
                    </h:panelGrid>
                </a4j:form>
            </p:dialog>
    
            </a4j:outputPanel>
    
    
        <a href="#" onclick="dialog.show()">Link</a>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using jsf 1.2, hibernate, richfaces 3.3.0GA and facelets. I have this code in my
I'm using RichFaces 3.3.1 with JSF RE 1.2 and facelets. I have a strange
Using RichFaces 3.3.3, JSF 1.2 and Facelets. For some presentation purposes I need to
I using Richfaces 3.3 and Jsf 2. I have a tab panel with a
I'm using Richfaces 3, Facelets (a pre-JSF 2 version), and Tomcat. I am working
I'm using RichFaces' a4j:support to toggle the visibility of some controls on the page.
I'm using Richfaces JSF and I want to iterate over an Map<Object,Object> . I
In JSF application we are using richfaces (Final.3.3.3). In pom.xml there is dependency on
I want to render 6 blocks on a page asynchronously using richfaces a4j support.
Enviroment: JSF 2.0, RichFaces 3.3.3, Facelets 1.1.15B1, Spring Framework 3.x, WebFlow 2.1, MyBatis 3.0.1,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.