Image upload is now updated and cleaned up.
This commit is contained in:
parent
5083086ff4
commit
2600500344
|
@ -1063,37 +1063,21 @@ public class RecipeDetailBean implements Serializable {
|
|||
|
||||
// ***
|
||||
|
||||
UploadedFile imageFile = null;
|
||||
|
||||
/**
|
||||
* @return the imageFile set by the image upload control
|
||||
*/
|
||||
public UploadedFile getImageFile() {
|
||||
return imageFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param imageFile the imageFile to set
|
||||
*/
|
||||
public void setImageFile(UploadedFile imageFile) {
|
||||
this.imageFile = imageFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load/replace images. Computes thumbnail.
|
||||
*
|
||||
* @param event PrimeFaces file upload event object
|
||||
*/
|
||||
public void ajaxUploadImage(FileUploadEvent event) {
|
||||
PictureController.importImage(recipe, event.getFile().getContent());
|
||||
PictureController.importImage(recipe,
|
||||
event.getFile().getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove images from recipe
|
||||
*
|
||||
* @param event Notused
|
||||
*/
|
||||
public void ajaxDeleteImage(AjaxBehaviorEvent event) {
|
||||
public void ajaxDeleteImage() {
|
||||
log.info("Deleting current recipe image");
|
||||
this.recipe.setImage(null);
|
||||
this.recipe.setThumb(null);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ import jakarta.faces.application.ViewExpiredException;
|
|||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletException;
|
||||
|
||||
import org.primefaces.application.resource.PrimeResourceHandler;
|
||||
import org.primefaces.renderkit.HeadRenderer;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
|
@ -21,8 +19,6 @@ import org.springframework.http.HttpStatus;
|
|||
"com.mousetech.gourmetj.persistence.model" })
|
||||
public class SpringPrimeFacesApplication {
|
||||
|
||||
private static final String IMAGE_IIO_PROVIDER_CONTEXT_LISTENER =
|
||||
"com.twelvemonkeys.servlet.image.IIOProviderContextListener";
|
||||
final String errorPage = "/error/error.html";
|
||||
final String error404Page = "/error/error404.html";
|
||||
final String expiredPage = "/error/viewExpired.xhtml";
|
||||
|
@ -38,13 +34,6 @@ public class SpringPrimeFacesApplication {
|
|||
@Override
|
||||
public void onStartup(ServletContext servletContext)
|
||||
throws ServletException {
|
||||
/* Note that we cannot set theme here since it was
|
||||
* already set earlier. Default value is "aristo".
|
||||
*/
|
||||
servletContext.setInitParameter(
|
||||
"joinfaces.primefaces.theme", "vela");
|
||||
servletContext.setInitParameter(
|
||||
"primefaces.THEME", "overcast");
|
||||
servletContext.setInitParameter(
|
||||
"jakarta.faces.FACELETS_SKIP_COMMENTS",
|
||||
"true");
|
||||
|
@ -53,7 +42,6 @@ public class SpringPrimeFacesApplication {
|
|||
"com.sun.el.ExpressionFactoryImpl");
|
||||
servletContext.setInitParameter(
|
||||
"primefaces.UPLOADER", "native");
|
||||
//servletContext.addListener(IMAGE_IIO_PROVIDER_CONTEXT_LISTENER);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -149,14 +149,15 @@
|
|||
rows="10" cols="45"
|
||||
value="#{recipeDetailBean.recipe.description}"
|
||||
/>
|
||||
</p:panelGrid>
|
||||
<p:panel id="picPanel">
|
||||
<img id="bigPix"
|
||||
src="/img/picture/?dt=#{recipeDetailBean.currentTime}"
|
||||
/>
|
||||
</p:panel>
|
||||
<p:panelGrid id="picButtonPanel" columns="2">
|
||||
<p:fileUpload id="ctlUpload"
|
||||
label="Upload Image"
|
||||
value="#{recipeDetailBean.imageFile}"
|
||||
listener="#{recipeDetailBean.ajaxUploadImage}"
|
||||
global="true" mode="advanced"
|
||||
multiple="false"
|
||||
|
@ -167,13 +168,10 @@
|
|||
/>
|
||||
<p:commandButton id="ctlDelImg"
|
||||
value="Delete Image"
|
||||
>
|
||||
<f:ajax
|
||||
listener="#{recipeDetailBean.ajaxDeleteImage}"
|
||||
render="picPanel"
|
||||
action="#{recipeDetailBean.ajaxDeleteImage}"
|
||||
update="picPanel"
|
||||
immediate="true"
|
||||
/>
|
||||
</p:commandButton>
|
||||
</p:panelGrid>
|
||||
</p:tab>
|
||||
<p:tab id="ingredientsTab"
|
||||
|
|
Loading…
Reference in New Issue
Block a user