• Settings
    • Locale
    • Change the locale of the datepicker, schedule and client side validation messages.

      Language
      English
      English
      English
      French
      German
      German
      German
      Italian
      Korean
      Spanish
      Catalan
      Dutch
      Portuguese
      Portuguese
      Arabic
      Arabic
      Bulgarian
      Bangla
      Bosnian
      Czech
      Greek
      Estonian
      Persian
      Finnish
      Danish
      Hindi
      Indonesian
      Icelandic
      Croatian
      Japanese
      Hungarian
      Hebrew
      Georgian
      Central Kurdish
      Khmer
      Kyrgyz
      Kazakh
      Lithuanian
      Latvian
      Malay
      Norwegian
      Polish
      Romanian
      Russian
      Slovak
      Slovenian
      Serbian
      Serbian
      Swedish
      Thai
      Turkish
      Ukrainian
      Uzbek
      Vietnamese
      Chinese
      Chinese
  • Resources

ImageAreaSelect

ImageAreaSelect is a widget for selecting a rectangular area of an image. It allows web developers to easily implement image cropping functionality, as well as other user interface features, such as photo notes (like those on Flickr).

ImageAreaSelect Tag Documentation

ImageAreaSelect allows selecting a rectangular area on an image.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
widgetVar String false generated ('widget_' + componentClientId) Name of the client side widget.
aspectRatio String false Aspect ratio of the selection (e.g. '1:1').
autoHide Boolean false Whether to auto-hide the selection.
fadeSpeed Integer false Fade speed in ms.
for String true Search expression for the target image to attach the area selector to.
handles Boolean false Whether to show resize handles.
hide Boolean false Whether to hide the selection on click outside.
imageHeight Integer false Image height for coordinate mapping.
imageWidth Integer false Image width for coordinate mapping.
keyboardSupport Boolean false Whether keyboard support is enabled.
maxHeight Integer false Maximum selection height.
maxWidth Integer false Maximum selection width.
minHeight Integer false Minimum selection height.
minWidth Integer false Minimum selection width.
movable Boolean false Whether the selection is movable.
parentSelector String false Parent selector for the widget.
persistent Boolean false Whether the selection is persistent.
resizable Boolean false Whether the selection is resizable.
show Boolean false Whether to show the selection on init.
zIndex Integer false z-index of the selection overlay.

ImageRotateAndResize Tag Documentation

ImageRotateAndResize allows rotating and resizing an image.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
widgetVar String false generated ('widget_' + componentClientId) Name of the client side widget.
for String true Search expression for the target image.
Tag Documentation Widget Source
Basic Selection

The basic configuration enables persistent and resizable selection of an area. The selectEnd event reports the selection.

Customized Selection

The widget is highly configurable. Here the selection is not persistent, hides automatically after the selection is done, has no handles and can neither be moved nor resized.

ImageAreaSelect with ImageRotateAndResize

ImageAreaSelect and ImageRotateAndResize can be combined. The image is completely redrawn after a resize or rotate action, so the ImageAreaSelect stops working until its reload() is called. Without a server side listener for the event, p:callback reloads the widget; here the resize event is caught with p:callback.

Usage


<div class="card">
    <h5>Basic Selection</h5>
    <p>The basic configuration enables persistent and resizable selection of an area. The <i>selectEnd</i> event reports the selection.</p>
    <h:form id="formBasicSelection">
        <p:growl id="growl" showDetail="true" sticky="true"/>
        <p:graphicImage id="myImage" value="/resources/images/testImage1.png"/>
        <pe:imageAreaSelect id="areaSelect" for="myImage" handles="true">
            <p:ajax event="selectEnd" listener="#{imageController.selectEndListener}" update="growl"/>
        </pe:imageAreaSelect>
    </h:form>
</div>

<div class="card">
    <h5>Customized Selection</h5>
    <p>The widget is highly configurable. Here the selection is not persistent, hides automatically after the selection is done,
        has no handles and can neither be moved nor resized.</p>
    <h:form id="formCustomizedSelection">
        <p:growl id="growl" showDetail="true" sticky="true"/>
        <p:graphicImage id="myImage" value="/resources/images/testImage1.png"/>
        <pe:imageAreaSelect id="areaSelect"
                            for="myImage"
                            autoHide="true"
                            handles="false"
                            movable="false"
                            persistent="false"
                            resizable="false">
            <p:ajax event="selectEnd" listener="#{imageController.selectEndListener}" update="growl"/>
        </pe:imageAreaSelect>
    </h:form>
</div>

<div class="card">
    <h5>ImageAreaSelect with ImageRotateAndResize</h5>
    <p>ImageAreaSelect and ImageRotateAndResize can be combined. The image is completely redrawn after a resize or rotate action, so
        the ImageAreaSelect stops working until its <code>reload()</code> is called. Without a server side listener for
        the event, <code>p:callback</code> reloads the widget; here the <i>resize</i> event is caught with <code>p:callback</code>.</p>
    <h:form id="formCombined">
        <p:outputPanel id="example">
            <p:commandLink update="example">
                <f:setPropertyActionListener target="#{imageController.imageUrl}" value="/resources/images/testImage1.png"/>
                <p:graphicImage value="/resources/images/testImage1.png" width="150" height="100"/>
            </p:commandLink>
            <p:commandLink update="example">
                <f:setPropertyActionListener target="#{imageController.imageUrl}" value="/resources/images/testImage2.png"/>
                <p:graphicImage value="/resources/images/testImage2.png" width="150" height="100"/>
            </p:commandLink>
            <p:commandLink update="example">
                <f:setPropertyActionListener target="#{imageController.imageUrl}" value="/resources/images/testImage3.png"/>
                <p:graphicImage value="/resources/images/testImage3.png" width="150" height="100"/>
            </p:commandLink>

            <p:growl id="growl" showDetail="true" sticky="true"/>

            <div id="imageWrapper" style="width:600px; max-width:100%; height:400px; margin:auto; overflow:scroll; position:relative;">
                <p:graphicImage id="myImage" value="#{imageController.imageUrl}"/>
            </div>

            <pe:imageAreaSelect id="areaSelect"
                                for="myImage"
                                widgetVar="areaSelectWidget"
                                autoHide="true"
                                handles="false"
                                movable="false"
                                persistent="false"
                                resizable="false"
                                parentSelector="#imageWrapper">
                <p:ajax event="selectEnd" listener="#{imageController.selectEndListener}" update="growl"/>
            </pe:imageAreaSelect>

            <pe:imageRotateAndResize id="rotateAndResize" for="myImage" widgetVar="rotateAndResizeWidget">
                <p:ajax event="rotate" listener="#{imageController.rotateListener}"
                        update="growl" oncomplete="PF('areaSelectWidget').reload();"/>
                <p:callback event="resize" execute="PF('areaSelectWidget').reload();"/>
            </pe:imageRotateAndResize>

            <p:commandButton icon="pi pi-replay" value="Rotate Left"
                             onclick="PF('rotateAndResizeWidget').rotateLeft(90);return false;"/>
            <p:commandButton icon="pi pi-refresh" value="Rotate Right"
                             onclick="PF('rotateAndResizeWidget').rotateRight(90);return false;"/>
            <p:commandButton icon="pi pi-search-plus" value="Scale +"
                             onclick="PF('rotateAndResizeWidget').scale(1.05);return false;"/>
            <p:commandButton icon="pi pi-search-minus" value="Scale -"
                             onclick="PF('rotateAndResizeWidget').scale(0.95);return false;"/>
        </p:outputPanel>
    </h:form>
</div>