-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ImageEditor Component, Version 1.0.0
- Loading branch information
Showing
13 changed files
with
1,347 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/target/ | ||
.project | ||
.classpath | ||
.settings/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,82 @@ | ||
# primefaces-imageeditor | ||
Image Editor Component for Primefaces | ||
ImageEditor Component for PrimeFaces | ||
==================================== | ||
|
||
About | ||
----- | ||
|
||
This package provides a JSF (Java Server Faces) component *ImageEditor* as addition to the | ||
commonly used [PrimeFaces](http://www.primefaces.org) widget library. | ||
|
||
**Author**: Christian Simon | ||
**Copyright**: illucIT Software GmbH | ||
**Website**: [illucit.com](http://www.illucit.com) | ||
**License**: Apache License 2.0 (see LICENSE file) | ||
|
||
Compatibility: | ||
-------------- | ||
|
||
*ImageEditor* is written for and tested with **PrimeFaces 5.2** and **JSF 2.2**. | ||
Due to changes in the PrimeFaces API for streamed data, the library is not compatible with earlies PrimeFaces versions without modifications. | ||
|
||
Setup | ||
----- | ||
|
||
The *ImageEditor* component can either be downloaded directly on Github or included via Maven. | ||
|
||
If you want to use Maven to add the library to your web project, you first need to add the public illucIT Maven Repository, as the library is not published on Maven Central, yet. | ||
|
||
<repositories> | ||
<repository> | ||
<id>illucit</id> | ||
<name>illucIT Maven Repository</name> | ||
<url>http://repository.illucit.com</url> | ||
<releases> | ||
<enabled>true</enabled> | ||
</releases> | ||
</repository> | ||
</repositories> | ||
|
||
Then just add the Maven artifact to your dependencies: | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.illucit</groupId> | ||
<artifactId>primefaces-imageeditor</artifactId> | ||
<version>${version.imageeditor}</version> | ||
</dependency> | ||
<dependencies> | ||
|
||
Usage in JSF | ||
------------ | ||
|
||
The library provides a taglib including the `imageEditor` component. | ||
In order to use the component, first declare a namespace for the taglib in your JSF source file (where your also would include the namespace for PrimeFaces): | ||
|
||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" | ||
... | ||
xmlns:p="http://primefaces.org/ui" | ||
xmlns:ie="http://www.illucit.com/jsf/imageeditor"> | ||
|
||
Then you can use the `imageEditor` tag in your facelet file. | ||
|
||
<ie:imageEditor id="exampleImageEditor" widgetVar="imageEd" | ||
value="#{imageEditorBean.image}" initialColor="ffff00" | ||
initialShape="ellipse" | ||
fileUploadListener="#{imageEditorBean.onImageSaved}" | ||
labelSave="Save" labelDownload="Download" | ||
onsuccess="alert('Successfully saved!');"> | ||
<f:param name="fileName" value="#{imageEditorBean.fileName}" /> | ||
</ie:imageEditor> | ||
|
||
The following parameters are required for the `imageEditor` component to work correctly: | ||
* `value`: Expression of a method returing a `StreamedContent` object containing the image data. | ||
Every parameter child element of type `<f:param />` will be attached to the image request. | ||
Note: As the image is requested by a normal GET request, no view scope can be used for this as the view id will not be transmitted. | ||
* `fileUploadListener`: Bean method accepting an `ImageEditedEvent` object. | ||
The method is called when the save button is pressed. The given object contains the binary image data. | ||
|
||
|
||
Disclaimer: | ||
----------- | ||
|
||
ImageEditor is free software and comes with NO WARRANTY! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?xml version="1.0"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.illucit</groupId> | ||
<artifactId>illucit-parent</artifactId> | ||
<version>2</version> | ||
</parent> | ||
<artifactId>primefaces-imageeditor</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>Primefaces ImageEditor Component</name> | ||
<description>Component for Primefaces which provides an image editor for painting into images</description> | ||
|
||
<url>http://www.illucit.com</url> | ||
<licenses> | ||
<license> | ||
<name>Apache License, Version 2.0</name> | ||
<distribution>repo</distribution> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url> | ||
</license> | ||
</licenses> | ||
|
||
<scm> | ||
<connection>scm:git:${scm.connection}</connection> | ||
<developerConnection>scm:git:${scm.connection}</developerConnection> | ||
<url>${scm.url}</url> | ||
</scm> | ||
|
||
<developers> | ||
<developer> | ||
<id>csimon</id> | ||
<name>Christian Simon</name> | ||
<email>simon@illucit.com</email> | ||
<url>https://github.com/metaxmx</url> | ||
</developer> | ||
<developer> | ||
<id>dwieth</id> | ||
<name>Daniel Wieth</name> | ||
<email>wieth@illucit.com</email> | ||
<url>https://github.com/danielwieth</url> | ||
</developer> | ||
</developers> | ||
|
||
<properties> | ||
<!-- Release Info --> | ||
<scm.connection>git@github.com:illucIT/primefaces-imageeditor.git</scm.connection> | ||
<scm.url>https://github.com/illucIT/primefaces-imageeditor</scm.url> | ||
|
||
<!-- Primefaces version --> | ||
<version.primefaces>5.2</version.primefaces> | ||
|
||
<!-- JSF dependency versions --> | ||
<version.faces>2.2.0</version.faces> | ||
<version.el>2.2</version.el> | ||
|
||
<!-- Fabric.js Version --> | ||
<version.fabricjs>1.4.12</version.fabricjs> | ||
|
||
<!-- maven-compiler-plugin --> | ||
<maven.compiler.target>1.7</maven.compiler.target> | ||
<maven.compiler.source>1.7</maven.compiler.source> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.primefaces</groupId> | ||
<artifactId>primefaces</artifactId> | ||
<version>${version.primefaces}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.webjars</groupId> | ||
<artifactId>fabric.js</artifactId> | ||
<version>${version.fabricjs}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish</groupId> | ||
<artifactId>javax.faces</artifactId> | ||
<version>${version.faces}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.el</groupId> | ||
<artifactId>el-api</artifactId> | ||
<version>${version.el}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>${project.artifactId}</finalName> | ||
</build> | ||
|
||
<repositories> | ||
<repository> | ||
<id>illucit</id> | ||
<name>illucIT Maven Repository</name> | ||
<url>http://repository.illucit.com</url> | ||
<releases> | ||
<enabled>true</enabled> | ||
</releases> | ||
</repository> | ||
</repositories> | ||
|
||
</project> |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/illucit/faces/component/imageeditor/ImageEditedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.illucit.faces.component.imageeditor; | ||
|
||
import javax.faces.component.UIComponent; | ||
|
||
import org.primefaces.event.FileUploadEvent; | ||
import org.primefaces.model.UploadedFile; | ||
|
||
/** | ||
* Event to indicate that the image was stored by {@link ImageEditor} action. | ||
* | ||
* @author Christian Simon | ||
* | ||
*/ | ||
public class ImageEditedEvent extends FileUploadEvent { | ||
|
||
private static final long serialVersionUID = -2624800646668578507L; | ||
|
||
/** | ||
* Create event. | ||
* | ||
* @param component | ||
* component that fired the event | ||
* @param file | ||
* uploaded file data | ||
*/ | ||
public ImageEditedEvent(UIComponent component, UploadedFile file) { | ||
super(component, file); | ||
} | ||
|
||
} |
Oops, something went wrong.