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 6173345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:33:21+00:00 2026-05-23T23:33:21+00:00

How to position the primefaces dialog dynamically at x,y co-ordinates defined by javascript variables

  • 0

How to position the primefaces dialog dynamically at x,y co-ordinates defined by javascript variables ?

My attempt:-

I tried doing that through javascript itself but I failed to set the position through following code:

        var dialog_x=300;
        var dialog_y=500;

        var s = document.getElementById("dialogId"); 
        s.style.position = "relative";
        s.style.left = dialog_x + "px";
        s.style.top = dialog_y + "px";

Note that this dialogId is what I defined in the id attribute of dialog. As I came to know that id of parent container are also appended to this id, I also tried using the resultant id(after append) but it doesnt work.

Edit:

I figured out that dialog container(which contains the header and the content of the dialog) which I expected to be assigned the id that I defined through id attribute on dialog component is not assigned any id which was the reason why I could not access the dialog. I still cannot understand how I should go about retrieving this element when it has not been assigned any id. The id that I defined was infact assigned to the dialog content container inside of the main dialog container.

  • 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-23T23:33:22+00:00Added an answer on May 23, 2026 at 11:33 pm

    Using jQuery, you can call a javascript method that will adjust the positionning of the dialog when the dialog will show.

        <h:form prependId="false">
            <p:commandButton value="Select Location" oncomplete="TreeDialog.show()" id="selectLocationButton"></p:commandButton>
        </h:form>
        <p:dialog header="Select the location" id="treeDialog"
                widgetVar="TreeDialog"
                modal="true" onShow="adjustPositionning($('#selectLocationButton'), $('#treeDialog'))" width="450">
            <p:tree value="#{myController.root}" var="node" dynamic="true" cache="true">  
            <p:treeNode>  
                <h:outputText value="#{node.name}" />  
            </p:treeNode>  
            </p:tree>  
        </p:dialog>
    
    <script type="text/javascript">
    function adjustPositionning(sourceElement, dialog) {
        var x = sourceElement.offset().left;
        var y = sourceElement.offset().top;
        var width = sourceElement.width();
        var padding = 15;
      dialog.parent().offset({ top: y, left: x + width + padding });
    }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want my position through GPS & from that I want to go another
I'm trying to position correctly more fixed elements here but it seems that I
#mydiv { position:absolute; left:0px; top:0px; width:83px; height:83px; } <div id=mydiv></div> That's my style for
I'm trying to position my Flex app so that it's further down the page,
Is it possible to position a view defined in a XIB as a subview
I want to find position in( position within string, but I can not explicitly
Found the function which position the image(s) in the multiscaleimage... but I'm not sure
How to position jquery ui dialog box with respect to a div element inside
I want to ask that sometimes what happen that if I use PrimeFaces Rich
#backgroundPopup{ position:absolute; height:100%; width:100%; } its fine, if we give width=500px; but when we

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.