I keep getting javax.el.PropertyNotFoundException: Target Unreachable, identifier 'i' resolved to null
on my PrimeFaces application, when I click on commandButton
which is supposed to delete the image but I just can't seem to find the reason. I checked this answer but nothing there is my problem. When I remove or not click on the commandButton
the application works, and the var="i"
works perfectly for all the other DOM/PF
elements, so I'm just stuck here.
Thanks in advance.
Here's my code:
<h:form>
<div id="visor-imagenes">
<p:contentFlow value="#{imageHandler.personalImgList}"
var="i" id="contentFlow"
styleClass="contentWrapp">
<p:graphicImage value="#{fileUploadMB.image}"
styleClass="content"
onclick="clickFlow(this, event)">
<f:param name="id" value="#{i.id}"/>
<h:inputHidden value="#{i.imageDescription}"/>
<p:commandButton icon="ui-icon-trash"
action="#{imageHandler.deleteImage(i.id)}"
update="contentFlow">
</p:commandButton>
</p:graphicImage>
<div class="caption">#{i.imageName}</div>
</p:contentFlow>
</div>
</h:form>
bean:
public void deleteImage(String i) {
this.imgFacade.deleteImage(i);
}
I tried using <f:param
, <f:setPropertyActionListener
for the i
value in commandButton but non of these worked.
setting the commandButton
out of the <p:graphicImage
throws same error:
<p:contentFlow value="#{fileUploadMB.personalImgList}" var="i" id="contentFlow" styleClass="contentWrapp">
<p:commandButton icon="ui-icon-trash"
action="#{fileUploadMB.deleteImage}"
update="contentFlow">
<f:param name="id" value="#{i.id}"/>
</p:commandButton>
<p:graphicImage value="#{fileUploadMB.image}" styleClass="content" onclick="clickFlow(this, event)">
<f:param name="id" value="#{i.id}"/>
<h:inputHidden value="#{i.imageDescription}"/>
</p:graphicImage>
<div class="caption">#{i.imageName}</div>
</p:contentFlow>
also, I have done overriding to the onClick
event for the image, since default clicking redirected to image file.
<script>
function clickFlow(item, e) {
if ($(item).parent().hasClass('active')) {
e.stopImmediatePropagation();
var text = $(item).siblings("input[type=hidden]").attr('value');
$('.image-linker:first-child').attr('href', $(item).attr('src'));
$('.image-linker:first-child').attr('title', text);
$('.image-lightboxer:first-child').attr('src', $(item).attr('src'));
$('.image-linker:first-child').click();
}
}
</script>
the <h:inputHidden value="#{i.imageDescription}"
is what allows to fill the lightbox title=""
attribute dinamically.
I don't think so but, Could the onClick
event being overridden have any effect on this issue?