2019独角兽企业重金招聘Python工程师标准>>>

------------------------ResizePanel-----------

import org.apache.wicket.markup.html.WebPage;

import org.apache.wicket.request.mapper.parameter.PageParameters;

import org.odlabs.wiquery.resizable.ResizePanel;

public class ResizePage extends WebPage {
    private static final long serialVersionUID = 1L;

public ResizePage(final PageParameters parameters) {
        super(parameters);

add(new ResizePanel("panel"));

}

}

-------------------------ResizePanel.html-------------------------------

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
    <head>
        <meta charset="utf-8" />
        <title>Apache Wicket Quickstart ResizePage</title>
        <link href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:regular,bold' rel='stylesheet' type='text/css' />
        <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="Stylesheet" />
    </head>
    <body>
        <div wicket:id="panel">
        </div>
    </body>
</html>

----------------------------------ResizePanel-------------------------------------------------
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.odlabs.wiquery.ui.resizable.ResizableStopAjaxBehavior;

/**
 *
 * @author Ernesto Reinaldo Barreiro (reiern70@gmail.com)
 *
 */
public class ResizePanel extends Panel {

private static final long serialVersionUID = 1L;

private String index = "";
    
    private Label label;

/**
     *
     * @param id
     */
    public ResizePanel(String id) {
        super(id);
        
        WebMarkupContainer container = new WebMarkupContainer("resize");
        add(container);
        container.add(new ResizableStopAjaxBehavior() {
            
            private static final long serialVersionUID = 1L;

@Override
            protected void resizeTop(AjaxRequestTarget target, Component source,
                    double resizeHeight, double resizeWidth) {
                index = "resizeHeight="+resizeHeight+", resizeWidth=" + resizeWidth;
                target.add(label);
            }
        });
        
        label = new Label("label", new AbstractReadOnlyModel<String>() {

private static final long serialVersionUID = 1L;

@Override
            public String getObject() {
                return "Selected index is: " + index;
            }

});
        
        label.setOutputMarkupId(true);
        add(label);
    }
}

----------------------------ResizePanel.html-----------------------------------------

<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
    <body>
<wicket:panel>
    <div wicket:id="resize" style="width: 200px; height: 200px; border: 1px solid red;">

</div>

<div wicket:id="label"></div>
    
</wicket:panel>
    </body>
</html>

-------------------------------------ResizableStopAjaxBehavior-----------------------------------------------

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;

/**
 *  Convenience ResizableStopAjaxBehavior with AJAX functionality already plugged in.
 *  
 * @author reiern70
 *
 */
public abstract class ResizableStopAjaxBehavior extends ResizableBehavior {

private static final long serialVersionUID = 1L;

/**
     * Constructor.
     */
    public ResizableStopAjaxBehavior() {
        setStopEvent(new AjaxResizeStopCallback() {
            
                        private static final long serialVersionUID = 1L;

@Override
            protected void resizeTop(AjaxRequestTarget target,
                    Component source, double resizeHeight, double resizeWidth) {
                
                ResizableStopAjaxBehavior.this.resizeTop(target, source, resizeHeight, resizeWidth);                
            }
        });
    }

-----------------------------------------------IComplexOption---------------------------------------------------

public interface IComplexOption extends Serializable
{
    /**
     * Method retrieving the javascript representation of this complex option
     *
     * @return the javascript
     */
    public CharSequence getJavascriptOption();
}

------------------------------------AbstractAjaxEventCallback-------------------------------------------------

import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.attributes.CallbackParameter;
import org.odlabs.wiquery.core.options.IComplexOption;
import org.odlabs.wiquery.core.util.MarkupIdVisitor;

public abstract class AbstractAjaxEventCallback implements IComplexOption
{
    private static final long serialVersionUID = 1L;

private String event;

private WiQueryAbstractAjaxBehavior behavior;

public AbstractAjaxEventCallback(String event)
    {
        this.event = event;
    }

public String getEvent()
    {
        return event;
    }

public WiQueryAbstractAjaxBehavior getBehavior()
    {
        return behavior;
    }

public void setBehavior(WiQueryAbstractAjaxBehavior behavior)
    {
        this.behavior = behavior;
    }

@Override
    public CharSequence getJavascriptOption()
    {
        List<CallbackParameter> extraParameters = getExtraParameters();
        return behavior.getCallbackFunction(extraParameters
            .toArray(new CallbackParameter[extraParameters.size()]));
    }

protected Component findComponentById(String id)
    {
        if (id == null)
            return null;

MarkupIdVisitor visitor = new MarkupIdVisitor(id);
        getBehavior().getBehaviorComponent().getPage().visitChildren(visitor);
        return visitor.getFoundComponent();
    }

protected List<CallbackParameter> getExtraParameters()
    {
        List<CallbackParameter> ret = new ArrayList<CallbackParameter>();
        ret.add(CallbackParameter.context("event"));
        ret.add(CallbackParameter.context("ui"));
        ret.add(CallbackParameter.resolved("eventName", "'" + event + "'"));
        return ret;
    }

public abstract void call(AjaxRequestTarget target, Component source);
}

/**
     * Called when component is resized.
     *
     * @param target
     * @param source
     * @param resizeHeight
     * @param resizeWidth
     */
    protected abstract void resizeTop(AjaxRequestTarget target, Component source,
            double resizeHeight, double resizeWidth);

}

-------------------------------ResizableBehavior--------------------------------------------

import java.util.List;

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.attributes.CallbackParameter;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.request.IRequestParameters;
import org.apache.wicket.request.cycle.RequestCycle;
import org.odlabs.wiquery.core.behavior.AbstractAjaxEventCallback;
import org.odlabs.wiquery.core.behavior.WiQueryAbstractAjaxBehavior;
import org.odlabs.wiquery.core.javascript.JsQuery;
import org.odlabs.wiquery.core.javascript.JsStatement;
import org.odlabs.wiquery.core.options.ArrayItemOptions;
import org.odlabs.wiquery.core.options.ICollectionItemOptions;
import org.odlabs.wiquery.core.options.IComplexOption;
import org.odlabs.wiquery.core.options.IntegerItemOptions;
import org.odlabs.wiquery.core.options.LiteralOption;
import org.odlabs.wiquery.ui.core.JsScopeUiEvent;
import org.odlabs.wiquery.ui.resizable.ResizableAnimeDuration.DurationEnum;

/**
 * $Id$
 * <p>
 * Sets the attached component resizable.
 * </p>
 *
 * @author Lionel Armanet
 * @since 1.0
 */
public class ResizableBehavior extends WiQueryAbstractAjaxBehavior
{
    // Constants
    /** Constant of serialization */
    private static final long serialVersionUID = 4155106232676863150L;

/**
     * Properties on the ui parameter (use it into callback functions) : a jQuery object
     * containing the helper element
     */
    public static final String UI_HELPER = "ui.helper";

/**
     * Properties on the ui parameter (use it into callback functions) : {top, left}
     * before resizing started
     */
    public static final String UI_ORIGIGNALPOSITION = "ui.originalPosition";

/**
     * Properties on the ui parameter (use it into callback functions) : {width, height}
     * before resizing started
     */
    public static final String UI_ORIGINALSIZE = "ui.originalSize";

/**
     * Properties on the ui parameter (use it into callback functions) : {top, left}
     * current position
     */
    public static final String UI_POSITION = "ui.position ";

/**
     * Properties on the ui parameter (use it into callback functions) : {width, height}
     * current size
     */
    public static final String UI_SIZE = "ui.size";

public abstract static class AjaxResizeCallback extends AbstractAjaxEventCallback
    {
        private static final long serialVersionUID = 1L;

public AjaxResizeCallback()
        {
            super("resize");
        }

@Override
        protected List<CallbackParameter> getExtraParameters()
        {
            List<CallbackParameter> ret = super.getExtraParameters();
            ret.add(CallbackParameter.resolved("resizeHeight", ResizableBehavior.UI_SIZE
                + ".height"));
            ret.add(CallbackParameter.resolved("resizeWidth", ResizableBehavior.UI_SIZE + ".width"));
            return ret;
        }

@Override
        public final void call(AjaxRequestTarget target, Component source)
        {
            IRequestParameters req = RequestCycle.get().getRequest().getRequestParameters();

double resizeHeight = req.getParameterValue("resizeHeight").toDouble(-1);
            double resizeWidth = req.getParameterValue("resizeWidth").toDouble(-1);
            resize(target, source, resizeHeight, resizeWidth);
        }

protected abstract void resize(AjaxRequestTarget target, Component source,
                double resizeHeight, double resizeWidth);
    }
    
    /**
     * Resize stop AJAX handler.
     *
     * @author reiern70
     *
     */
    public abstract static class AjaxResizeStopCallback extends AbstractAjaxEventCallback
    {
        private static final long serialVersionUID = 1L;

public AjaxResizeStopCallback()
        {
            super("stop");
        }

@Override
        protected List<CallbackParameter> getExtraParameters()
        {
            List<CallbackParameter> ret = super.getExtraParameters();
            ret.add(CallbackParameter.resolved("resizeHeight", ResizableBehavior.UI_SIZE
                + ".height"));
            ret.add(CallbackParameter.resolved("resizeWidth", ResizableBehavior.UI_SIZE + ".width"));
            return ret;
        }

@Override
        public final void call(AjaxRequestTarget target, Component source)
        {
            IRequestParameters req = RequestCycle.get().getRequest().getRequestParameters();

double resizeHeight = req.getParameterValue("resizeHeight").toDouble(-1);
            double resizeWidth = req.getParameterValue("resizeWidth").toDouble(-1);
            resizeTop(target, source, resizeHeight, resizeWidth);
        }

protected abstract void resizeTop(AjaxRequestTarget target, Component source,
                double resizeHeight, double resizeWidth);
    }

@Override
    public void onBind()
    {
        super.onBind();
        options.setOwner(getComponent());
    }

@Override
    public void detach(Component component)
    {
        super.detach(component);
        options.detach();
    }

@Override
    public void renderHead(Component component, IHeaderResponse response)
    {
        super.renderHead(component, response);
        response.render(JavaScriptHeaderItem.forReference(ResizableJavaScriptResourceReference
            .get()));
        response.render(OnDomReadyHeaderItem.forScript(new JsQuery(this.getComponent()).$()
            .chain("resizable", this.options.getJavaScriptOptions()).render()));
    }

/*---- Options section ---*/

/**
     * Resize these elements synchronous when resizing.
     *
     * @param cssSelector
     * @return instance of the current behavior
     * @deprecated will be removed in 1.2
     */
    @Deprecated
    public ResizableBehavior setAlsoResize(String cssSelector)
    {
        this.options.putLiteral("alsoResize", cssSelector);
        return this;
    }

/**
     * @return the alsoResize option
     * @deprecated will be changed in 1.2 to return a {@link ResizableAlsoResize}
     */
    @Deprecated
    public String getAlsoResize()
    {
        return this.options.getLiteral("alsoResize");
    }

/**
     * Resize these elements synchronous when resizing.
     *
     * @param alsoResize
     * @return instance of the current behavior
     */
    public ResizableBehavior setAlsoResize(ResizableAlsoResize alsoResize)
    {
        this.options.put("alsoResize", alsoResize);
        return this;
    }

/**
     * @return the alsoResize option
     */
    public ResizableAlsoResize getAlsoResizeComplex()
    {
        if (this.options.getComplexOption("alsoResize") instanceof ResizableAlsoResize)
        {
            return (ResizableAlsoResize) this.options.getComplexOption("alsoResize");
        }

return null;
    }

/**
     * Animates to the final size after resizing.
     *
     * @param animate
     * @return instance of the current behavior
     */
    public ResizableBehavior setAnimate(boolean animate)
    {
        this.options.put("animate", animate);
        return this;
    }

/**
     * @return the animate option
     */
    public boolean isAnimate()
    {
        if (this.options.containsKey("animate"))
        {
            return this.options.getBoolean("animate");
        }

return false;
    }

/**
     * Sets the duration time for animating, in milliseconds. Other possible values:
     * 'slow', 'normal', 'fast'.
     *
     * @return instance of the current behavior
     */
    public ResizableBehavior setAnimateDuration(ResizableAnimeDuration animeDuration)
    {
        this.options.put("animateDuration", animeDuration);
        return this;
    }

/**
     * @return the animeDuration option
     */
    public ResizableAnimeDuration getAnimateDuration()
    {
        IComplexOption animeDuration = this.options.getComplexOption("animateDuration");
        if (animeDuration != null && animeDuration instanceof ResizableAnimeDuration)
        {
            return (ResizableAnimeDuration) animeDuration;
        }

return new ResizableAnimeDuration(DurationEnum.SLOW);
    }

/**
     * Sets the easing effect for animating.
     *
     * @param easing
     * @return instance of the current behavior
     */
    public ResizableBehavior setAnimateEasing(String easing)
    {
        options.putLiteral("animateEasing", easing);
        return this;
    }

/**
     * @return the animateEasing option
     */
    public String getAnimateEasing()
    {
        String animateEasing = options.getLiteral("animateEasing");
        return animateEasing == null ? "swing" : animateEasing;
    }

/**
     * If set to true, resizing is constrained by the original aspect ratio. Otherwise a
     * custom aspect ratio can be specified, such as 9 / 16, or 0.5.
     *
     * @param aspectRatio
     * @return instance of the current behavior
     */
    public ResizableBehavior setAspectRatio(ResizableAspectRatio aspectRatio)
    {
        this.options.put("aspectRatio", aspectRatio);
        return this;
    }

/**
     * @return the aspectRatio option
     */
    public ResizableAspectRatio getAspectRatio()
    {
        IComplexOption aspectRatio = this.options.getComplexOption("aspectRatio");
        if (aspectRatio != null && aspectRatio instanceof ResizableAspectRatio)
        {
            return (ResizableAspectRatio) aspectRatio;
        }

return null;
    }

/**
     * If set to true, automatically hides the handles except when the mouse hovers over
     * the element.
     *
     * @param autoHide
     * @return instance of the current behavior
     */
    public ResizableBehavior setAutoHide(boolean autoHide)
    {
        options.put("autoHide", autoHide);
        return this;
    }

/**
     * @return the autoHide option
     */
    public boolean isAutoHide()
    {
        if (this.options.containsKey("autoHide"))
        {
            return this.options.getBoolean("autoHide");
        }

return false;
    }

/**
     * Prevents resizing if you start on elements matching the selector.
     *
     * @param cancel
     * @return instance of the current behavior
     */
    public ResizableBehavior setCancel(String cancel)
    {
        options.putLiteral("cancel", cancel);
        return this;
    }

/**
     * @return the cancel option
     */
    public String getCancel()
    {
        String cancel = options.getLiteral("cancel");
        return cancel == null ? "input,option" : cancel;
    }

/**
     * Sets the constrains resizing to within the bounds of the specified element.
     * Possible values: 'parent', 'document', a DOMElement, or a Selector.
     *
     * @param containment
     * @return instance of the current behavior
     */
    public ResizableBehavior setContainment(ResizableContainment containment)
    {
        this.options.put("containment", containment);
        return this;
    }

/**
     * @return the containment option
     */
    public ResizableContainment getContainment()
    {
        IComplexOption containment = this.options.getComplexOption("containment");
        if (containment != null && containment instanceof ResizableContainment)
        {
            return (ResizableContainment) containment;
        }

return null;
    }

/**
     * Sets the tolerance, in milliseconds, for when resizing should start. If specified,
     * resizing will not start until after mouse is moved beyond duration. This can help
     * prevent unintended resizing when clicking on an element.
     *
     * @param delay
     * @return instance of the current behavior
     */
    public ResizableBehavior setDelay(int delay)
    {
        options.put("delay", delay);
        return this;
    }

/**
     * @return the distance option
     */
    public int getDelay()
    {
        if (this.options.containsKey("delay"))
        {
            return options.getInt("delay");
        }

return 0;
    }

/**
     * Sets the tolerance, in pixels, for when resizing should start. If specified,
     * resizing will not start until after mouse is moved beyond distance. This can help
     * prevent unintended resizing when clicking on an element.
     *
     * @param distance
     * @return instance of the current behavior
     */
    public ResizableBehavior setDistance(int distance)
    {
        options.put("distance", distance);
        return this;
    }

/**
     * @return the distance option
     */
    public int getDistance()
    {
        if (this.options.containsKey("distance"))
        {
            return options.getInt("distance");
        }

return 1;
    }

/**
     * Disables (true) or enables (false) the resizable. Can be set when initialising
     * (first creating) the resizable.
     *
     * @param disabled
     * @return instance of the current behavior
     */
    public ResizableBehavior setDisabled(boolean disabled)
    {
        this.options.put("disabled", disabled);
        return this;
    }

/**
     * @return the disabled option
     */
    public boolean isDisabled()
    {
        if (this.options.containsKey("disabled"))
        {
            return this.options.getBoolean("disabled");
        }

return false;
    }

/**
     * Set to true, a semi-transparent helper element is shown for resizing.
     *
     * @param ghost
     * @return instance of the current behavior
     */
    public ResizableBehavior setGhost(boolean ghost)
    {
        options.put("ghost", ghost);
        return this;
    }

/**
     * @return the ghost option
     */
    public boolean isGhost()
    {
        if (this.options.containsKey("ghost"))
        {
            return options.getBoolean("ghost");
        }

return false;
    }

/**
     * Snaps the resizing element to a grid, every x and y pixels. Array values: [x, y]
     * Array values: [x, y]
     *
     * @param x
     * @param y
     * @return instance of the current behavior
     */
    public ResizableBehavior setGrid(int x, int y)
    {
        ArrayItemOptions<IntegerItemOptions> grids = new ArrayItemOptions<IntegerItemOptions>();
        grids.add(new IntegerItemOptions(x));
        grids.add(new IntegerItemOptions(y));
        this.options.put("grid", grids);
        return this;
    }

/**
     * @return the grid option value
     */
    public ICollectionItemOptions getGrid()
    {
        return this.options.getListItemOptions("grid");
    }

/**
     * If specified as a string, should be a comma-split list of any of the following: 'n,
     * e, s, w, ne, se, sw, nw, all'. The necessary handles will be auto-generated by the
     * plugin.
     *
     * If specified as an object, the following keys are supported: { n, e, s, w, ne, se,
     * sw, nw }. The value of any specified should be a jQuery selector matching the child
     * element of the resizable to use as that handle. If the handle is not a child of the
     * resizable, you can pass in the DOMElement or a valid jQuery object directly.
     *
     * @param handles
     * @return instance of the current behavior
     */
    public ResizableBehavior setHandles(ResizableHandles handles)
    {
        this.options.put("handles", handles);
        return this;
    }

/**
     * @return the handles option
     */
    public ResizableHandles getHandles()
    {
        IComplexOption handles = this.options.getComplexOption("handles");
        if (handles != null && handles instanceof ResizableHandles)
        {
            return (ResizableHandles) handles;
        }

return new ResizableHandles(new LiteralOption("e,s,se"));
    }

/**
     * Sets the css class that will be added to a proxy element to outline the resize
     * during the drag of the resize handle. Once the resize is complete, the original
     * element is sized.
     *
     * @param helper
     * @return instance of the current behavior
     */
    public ResizableBehavior setHelper(String helper)
    {
        options.putLiteral("helper", helper);
        return this;
    }

/**
     * @return the helper option
     */
    public String getHelper()
    {
        return options.getLiteral("helper");
    }

/**
     * Sets the component's max height.
     *
     * @return instance of the current behavior
     */
    public ResizableBehavior setMaxHeight(int maxHeight)
    {
        options.put("maxHeight", maxHeight);
        return this;
    }

/**
     * Returns the component's max height.
     */
    public int getMaxHeight()
    {
        if (this.options.containsKey("maxHeight"))
        {
            return options.getInt("maxHeight");
        }

return 0;
    }

/**
     * Sets the window's max width.
     *
     * @return instance of the current behavior
     */
    public ResizableBehavior setMaxWidth(int maxWidth)
    {
        options.put("maxWidth", maxWidth);
        return this;
    }

/**
     * Returns the component's max width.
     */
    public int getMaxWidth()
    {
        if (this.options.containsKey("maxWidth"))
        {
            return options.getInt("maxWidth");
        }

return 0;
    }

/**
     * Sets the component's min height.
     *
     * @return instance of the current behavior
     */
    public ResizableBehavior setMinHeight(int minHeight)
    {
        options.put("minHeight", minHeight);
        return this;
    }

/**
     * Returns the component's min height.
     */
    public int getMinHeight()
    {
        if (this.options.containsKey("minHeight"))
        {
            return options.getInt("minHeight");
        }

return 10;
    }

/**
     * Sets the component's min width.
     *
     * @return instance of the current behavior
     */
    public ResizableBehavior setMinWidth(int minWidth)
    {
        options.put("minWidth", minWidth);
        return this;
    }

/**
     * Returns the component's max width.
     */
    public int getMinWidth()
    {
        if (this.options.containsKey("minWidth"))
        {
            return options.getInt("minWidth");
        }

return 10;
    }

/*---- Events section ---*/

/**
     * Set's the callback when the event is triggered during the resize, on the drag of
     * the resize handler.
     *
     * @param resize
     * @return instance of the current behavior
     */
    public ResizableBehavior setResizeEvent(JsScopeUiEvent resize)
    {
        this.options.put("resize", resize);
        return this;
    }

public ResizableBehavior setResizeEvent(AjaxResizeCallback callback)
    {
        setEventListener(callback);
        return this;
    }

/**
     * Set's the callback when the event is triggered at the start of a resize operation.
     *
     * @param start
     * @return instance of the current behavior
     */
    public ResizableBehavior setStartEvent(JsScopeUiEvent start)
    {
        this.options.put("start", start);
        return this;
    }

/**
     * Set's the callback when the event is triggered at the end of a resize operation.
     *
     * @param stop
     * @return instance of the current behavior
     */
    public ResizableBehavior setStopEvent(JsScopeUiEvent stop)
    {
        this.options.put("stop", stop);
        return this;
    }
    
    /**
     * Set and AJAX callback for on stop event.
     * @param callback
     * @return
     */
    public ResizableBehavior setStopEvent(AjaxResizeStopCallback callback)
    {
        setEventListener(callback);
        return this;
    }

/*---- Methods section ----*/

/**
     * Method to destroy This will return the element back to its pre-init state.
     *
     * @return the associated JsStatement
     */
    public JsStatement destroy()
    {
        return new JsQuery(getComponent()).$().chain("resizable", "'destroy'");
    }

/**
     * Method to destroy within the ajax request
     *
     * @param ajaxRequestTarget
     */
    public void destroy(AjaxRequestTarget ajaxRequestTarget)
    {
        ajaxRequestTarget.appendJavaScript(this.destroy().render().toString());
    }

/**
     * Method to disable
     *
     * @return the associated JsStatement
     */
    public JsStatement disable()
    {
        return new JsQuery(getComponent()).$().chain("resizable", "'disable'");
    }

/**
     * Method to disable within the ajax request
     *
     * @param ajaxRequestTarget
     */
    public void disable(AjaxRequestTarget ajaxRequestTarget)
    {
        ajaxRequestTarget.appendJavaScript(this.disable().render().toString());
    }

/**
     * Method to enable
     *
     * @return the associated JsStatement
     */
    public JsStatement enable()
    {
        return new JsQuery(getComponent()).$().chain("resizable", "'enable'");
    }

/**
     * Method to enable within the ajax request
     *
     * @param ajaxRequestTarget
     */
    public void enable(AjaxRequestTarget ajaxRequestTarget)
    {
        ajaxRequestTarget.appendJavaScript(this.enable().render().toString());
    }

/**
     * Method to returns the .ui-resizable element
     *
     * @return the associated JsStatement
     */
    public JsStatement widget()
    {
        return new JsQuery(getComponent()).$().chain("resizable", "'widget'");
    }

/**
     * Method to returns the .ui-resizable element within the ajax request
     *
     * @param ajaxRequestTarget
     */
    public void widget(AjaxRequestTarget ajaxRequestTarget)
    {
        ajaxRequestTarget.appendJavaScript(this.widget().render().toString());
    }
}

-------------------------------------WiQueryAbstractAjaxBehavior-----------------------------------------

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.request.IRequestParameters;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.util.string.Strings;
import org.odlabs.wiquery.core.IWiQueryPlugin;
import org.odlabs.wiquery.core.javascript.JsStatement;
import org.odlabs.wiquery.core.options.IComplexOption;
import org.odlabs.wiquery.core.options.Options;

/**
 * $Id: WiQueryAbstractAjaxBehavior.java 1143 2011-07-29 11:51:49Z hielke.hoeve@gmail.com
 * $
 * <p>
 * Link between {@link IWiQueryPlugin} and {@link AbstractDefaultAjaxBehavior}
 * </p>
 *
 * @author Julien Roche
 * @since 1.1
 * @deprecated you should really use AbstractDefaultAjaxBehavior and render the statement in your {@link #renderHead(Component, IHeaderResponse)} implementation.
 */
@SuppressWarnings("deprecation")
public abstract class WiQueryAbstractAjaxBehavior extends AbstractDefaultAjaxBehavior implements
        IWiQueryPlugin
{
    // Constants
    /** Constant of serialization */
    private static final long serialVersionUID = 6498661892490365888L;

protected Options options = new Options();

public final Options getOptions()
    {
        return options;
    }

/**
     * <p>
     * Since wicket 6.0 {@link #statement()} is no longer needed, nearly all of WiQuery
     * core's inner workings have been ported to Wicket 6.0. Use
     * {@link #renderHead(Component, IHeaderResponse)} to render your statement.
     * </p>
     * <p>
     * For backward compatibility we render the output of this function in an
     * {@link OnDomReadyHeaderItem} if it is not empty. For your convenience this abstract
     * class returns null so that nothing is rendered.
     * <p>
     */
    @Override
    public void renderHead(Component component, IHeaderResponse response)
    {
        super.renderHead(component, response);

JsStatement statement = statement();
        if (statement != null)
        {
            String statementString = statement.render().toString();
            if (!Strings.isEmpty(statementString))
            {
                response.render(OnDomReadyHeaderItem.forScript(statementString));
            }
        }
    }

/**
     * <p>
     * Since wicket 6.0 this function is no longer needed, nearly all of WiQuery core's
     * inner workings have been ported to Wicket 6.0. Use
     * {@link #renderHead(Component, IHeaderResponse)} to render your statement.
     * </p>
     * <p>
     * For backward compatibility we render the output of this function in an
     * {@link OnDomReadyHeaderItem} if it is not empty. For your convenience this abstract
     * class returns null so that nothing is rendered.
     * <p>
     * <p>
     * If you decide to use this class and to override this function then make sure you do
     * call this class' {@link #renderHead(Component, IHeaderResponse)} otherwise no
     * statement will be rendered.
     * <p>
     *
     * @return The {@link JsStatement} corresponding to this component.
     * @deprecated use {@link #renderHead(Component, IHeaderResponse)} to render your
     *             statement.
     */
    @Deprecated
    @Override
    public JsStatement statement()
    {
        return null;
    }

public Component getBehaviorComponent()
    {
        return super.getComponent();

}

public void setEventListener(AbstractAjaxEventCallback callback)
    {
        callback.setBehavior(this);
        options.put(callback.getEvent(), callback);
    }

@Override
    protected void respond(AjaxRequestTarget target)
    {
        IRequestParameters req = RequestCycle.get().getRequest().getRequestParameters();
        String eventName = req.getParameterValue("eventName").toString();
        IComplexOption callback = options.getComplexOption(eventName);
        if (callback instanceof AbstractAjaxEventCallback)
        {
            ((AbstractAjaxEventCallback) callback).call(target, getComponent());
        }
    }
}

--------------------------------------------------------------------------------

import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.attributes.CallbackParameter;
import org.odlabs.wiquery.core.options.IComplexOption;
import org.odlabs.wiquery.core.util.MarkupIdVisitor;

public abstract class AbstractAjaxEventCallback implements IComplexOption
{
    private static final long serialVersionUID = 1L;

private String event;

private WiQueryAbstractAjaxBehavior behavior;

public AbstractAjaxEventCallback(String event)
    {
        this.event = event;
    }

public String getEvent()
    {
        return event;
    }

public WiQueryAbstractAjaxBehavior getBehavior()
    {
        return behavior;
    }

public void setBehavior(WiQueryAbstractAjaxBehavior behavior)
    {
        this.behavior = behavior;
    }

@Override
    public CharSequence getJavascriptOption()
    {
        List<CallbackParameter> extraParameters = getExtraParameters();
        return behavior.getCallbackFunction(extraParameters
            .toArray(new CallbackParameter[extraParameters.size()]));
    }

protected Component findComponentById(String id)
    {
        if (id == null)
            return null;

MarkupIdVisitor visitor = new MarkupIdVisitor(id);
        getBehavior().getBehaviorComponent().getPage().visitChildren(visitor);
        return visitor.getFoundComponent();
    }

protected List<CallbackParameter> getExtraParameters()
    {
        List<CallbackParameter> ret = new ArrayList<CallbackParameter>();
        ret.add(CallbackParameter.context("event"));
        ret.add(CallbackParameter.context("ui"));
        ret.add(CallbackParameter.resolved("eventName", "'" + event + "'"));
        return ret;
    }

public abstract void call(AjaxRequestTarget target, Component source);
}

<!DOCTYPE html> <html xmlns:wicket="http://wicket.apache.org">  <head><script type="text/javascript" src="./wicket/resource/org.apache.wicket.resource.JQueryResourceReference/jquery/jquery-ver-1368293882375.js"></script> <script type="text/javascript" src="./wicket/resource/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/res/js/wicket-event-jquery-ver-1368293882375.js"></script> <script type="text/javascript" src="./wicket/resource/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/res/js/wicket-ajax-jquery-ver-1368293882375.js"></script> <script type="text/javascript" src="./wicket/resource/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/res/js/wicket-ajax-jquery-debug-ver-1368293882375.js"></script> <script type="text/javascript" id="wicket-ajax-debug-enable"> /*<![CDATA[*/ Wicket.Ajax.DebugWindow.enabled=true; /*]]>*/ </script> <script type="text/javascript" id="wicket-ajax-base-url"> /*<![CDATA[*/ Wicket.Ajax.baseUrl=""; /*]]>*/ </script> <link rel="stylesheet" type="text/css" href="./wicket/resource/org.odlabs.wiquery.ui.themes.WiQueryCoreThemeResourceReference/smoothness/jquery-ui-1.8.24.custom-ver-1368302487765.css" /> <script type="text/javascript" src="./wicket/resource/org.odlabs.wiquery.ui.core.CoreUIJavaScriptResourceReference/jquery.ui.core-ver-1368302487765.js"></script> <script type="text/javascript" src="./wicket/resource/org.odlabs.wiquery.ui.widget.WidgetJavaScriptResourceReference/jquery.ui.widget-ver-1368302487765.js"></script> <script type="text/javascript" src="./wicket/resource/org.odlabs.wiquery.ui.mouse.MouseJavaScriptResourceReference/jquery.ui.mouse-ver-1368302487765.js"></script> <script type="text/javascript" src="./wicket/resource/org.odlabs.wiquery.ui.resizable.ResizableJavaScriptResourceReference/jquery.ui.resizable-ver-1368302487765.js"></script>   <meta charset="utf-8" />  <title>Apache Wicket Quickstart ResizePage</title>  <link href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:regular,bold' rel='stylesheet' type='text/css' />  <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="Stylesheet"/>  <script type="text/javascript" > /*<![CDATA[*/ Wicket.Event.add(window, "domready", function(event) { $('#resize1').resizable({stop: function (event,ui) { var attrs = {"u":"./;jsessionid=1bf9t1rfdcskr1d8ooqy7ffxn6?0-1.IBehaviorListener.0-panel-resize","c":"resize1"}; var params = {'eventName': 'stop','resizeHeight': ui.size.height,'resizeWidth': ui.size.width}; attrs.ep = params; Wicket.Ajax.ajax(attrs); } });; ;}); /*]]>*/ </script> </head>  <body>  <div wicket:id="panel"><wicket:panel>  <div wicket:id="resize" style="width: 200px; height: 200px; border: 1px solid red;" id="resize1">   </div>  <div wicket:id="label" id="label2">Selected index is: </div>  </wicket:panel></div>  </body> </html> 

转载于:https://my.oschina.net/u/1047983/blog/130016

wiquery ResizePanel相关推荐

  1. wiquery ManipulatingHelper

    为什么80%的码农都做不了架构师?>>> What is that ? Utility class to bind on your JsStatement or JsQuery so ...

  2. jQuery easyUI pannel 用法记录

    主要实现了easyUI中1 panel的打开,关闭,resize. 2 通过按钮动态新建panel. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML ...

  3. JQuery拖拽通过八个点改变div大小

    (function($) {/*** 默认参数*/var defaultOpts = {stage: document, //舞台item: 'resize-item', //可缩放的类名};/*** ...

  4. Unity----Panes, panels and windows(官方教程)

    通过panel创建一个窗口,实现拖拽,限制拖拽区域,改变窗口大小 原视频链接:https://unity3d.com/cn/learn/tutorials/modules/intermediate/l ...

最新文章

  1. object-c中管理文件和目录:NSFileManager使用方法
  2. SAP MM 明明有需求,为啥MRP RUN后没有PR单据产生?
  3. PowerDesigner逆向生成
  4. 在一个TextArea中如何限制行数和字符数
  5. python编写数学公式大全_python - 用python编写数学公式 - 堆栈内存溢出
  6. java构造函数中的this_关于构造函数中使用this的问题
  7. Clojure 学习
  8. Win7中IIS7.0安装及ASP环境配置
  9. windows server 2012 dhcp 配置故障转移
  10. slack通知本地服务器_通过构建自己的Slack App学习无服务器
  11. pat04-树4. Root of AVL Tree (25)
  12. 【愚公系列】2022年02月 微信小程序-场景值
  13. html5 浏览器适配问题
  14. Linux 用户管理 修改用户的家目录 useradd usermod
  15. 基于51单片的电风扇系统
  16. uni-app 选择图片(chooseImage)
  17. OneNET麒麟座应用开发之十:空气质量数据监测站项目总结
  18. python分三行将你的学号姓名班级_python第三次作业——叶耀宗
  19. ES 查询一,基于URL 的查询
  20. CF #764 Div.3(B ~D)

热门文章

  1. 学python前端需要哪些基础知识_简析前端学习python3的基础
  2. 《与爱因斯坦月球漫步——美国记忆力冠军教你记忆一切》读书摘抄[美]乔舒亚.福尔
  3. 树莓派python开发教程_树莓派Raspberry开发从基础到进阶视频+设计资料超详细教程下载...
  4. linux设置ip批处理文件,一篇详细的修改ip的方法
  5. asp.net获取浏览器的唯一标识_vue单页面应用如何在微信浏览器里进行网页授权获取用户信息
  6. mRNA的亚细胞定位
  7. 依赖倒置原则_C#教您一步步摆脱面向过程:依赖倒置
  8. python连接sqlserver_python连接SQL Server数据库
  9. 互联网世界的“人工智能”——探秘“深度学习”的前世今生
  10. python random函数shuffle_Python|有趣的shuffle方法