How to prevent Richfaces popupPanel from being moved in JavaScript?

Im using rich:PopupPanel components to display some content and I want them to be able to being maximized and restored by user. I've already implemented resizing and positioning of the component, but the problem is how to prevent popupPanel from being moved while it's maximized and allow it when its restored.

This is my code for button that is responsible for maximizing and restoring the popupPanel

<!-- language: lang-js -->
<a4j:commandLink id="maximizeRestoreButton" execute="@none"
    render="@none" value="Maximize"
    oncomplete="
        var comp = #{rich:component(cc.attrs.popupId)};

        if (comp.isMaximized) {
            var rv = comp.restoreValues;                    

            comp.moveTo(rv.top, rv.left);
            comp.resize(rv.width - comp.width(), rv.height - comp.height());
            comp.isMaximized = false;
        } else {
            var rv = new Object();
            rv.top = comp.getTop();
            rv.left = comp.getLeft();
            rv.width = comp.width();
            rv.height = comp.height();

            comp.moveTo(0,0);
            comp.resize(window.innerWidth - comp.width(), window.innerHeight - comp.height()); 

            comp.isMaximized = true;
            comp.restoreValues = rv;
        }

        return false;" />

Answers


I will suggest you to use a popupPanel tags for perventing popup panel to move and resize instead of external js function. set movable=false and resizable = false in rich popupPanel tag. For E.g

<rich:popupPanel resizable="false" movable="false" ...>
.....
</rich:popupPanel>

Need Your Help

Add File to Post Data to Page

file post httpwebrequest

I have Windows application, and I want to post data to an Url to get information from a webservice.

Choose domain controller by IP address C#

c# asp.net active-directory user-accounts

Below is simple code for creating a user in AD. The code is DC un-specific. It doesn't care which DC it creates it on, it'll use the windows default that the server is connected to.