我使用 JSF 2、primefaces 5.3,并尝试使用旋转和调整图像大小,如 Jpg、png 或任何其他图像格式。但出现这个错误。
这是我的代码。
<p:panelGrid columns="4" styleClass="noBorders" rendered="#{fileViewer.viewImageViewer}" >
<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="#{fileViewer.selectEndListener}" update="growl"/>
</pe:imageAreaSelect>
<pe:imageRotateAndResize id="rotateAndResize" for="myImage" widgetVar="rotateAndResizeWidget">
<p:ajax event="rotate" listener="#{fileViewer.rotateListener}"
update="growl" oncomplete="PF('areaSelectWidget').reload();"/>
<pe:javascript event="resize" execute="PF('areaSelectWidget').reload();"/>
</pe:imageRotateAndResize>
<p:commandButton type="button" icon="ui-icon-arrowreturnthick-1-w"
value="Rotate" onclick="PF('rotateAndResizeWidget').rotateLeft(90);
return false;"/>
<p:commandButton type="button" icon="ui-icon-arrowreturnthick-1-e"
value="Rotate" onclick="PF('rotateAndResizeWidget').rotateRight(90);
return false;"/>
<p:commandButton type="button" icon="ui-icon-zoomin"
value="+" onclick="PF('rotateAndResizeWidget').scale(1.05);
return false;"/>
<p:commandButton type="button" icon="ui-icon-zoomout"
value="-" onclick="PF('rotateAndResizeWidget').scale(0.95);
return false;"/>
</p:panelGrid>
public void rotateListener(final RotateEvent e) {
final FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Image rotated", + e.getDegree() + " Degree:");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
public void resizeListener(final ResizeEvent e) {
final FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Image resized", "Width:" + e.getWidth() + ", Height: " + e.getHeight());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
public void selectEndListener(final ImageAreaSelectEvent e) {
final FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Area selected",
"X1: " + e.getX1()
+ ", X2: " + e.getX2()
+ ", Y1: " + e.getY1()
+ ", Y2: " + e.getY2()
+ ", Image width: " + e.getImgWidth()
+ ", Image height: " + e.getImgHeight());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
How can I solve it?
难道您没有包含 PrimeFaces Extensions? AFAIR 您需要 4.0.0,它应该与 PF 5.3 兼容。
否则我不认为异常来自这个片段。