1 Reply Latest reply on Jun 29, 2012 11:47 PM by EJP

    Custom JSF tag not working HELP!!!!

      We have a custom tag to display the list of attachments for a a selected entity. So for example if there are entities A, B, C...each entity can have none or 1 or more attachments. When you go to the details page you see the list of attachments if any and an image against it that can be clicked to delete the attachment.

      Here is the tag:
      <at:attachmentTable value="#{Entity.attachmentList}" remove="#{Entity.removeAttachment}" />

      Here is the renderer code for the delete the attachment part of the tag:
      private void writeRemove(UIComponent component, FacesContext ctx, ResponseWriter writer, String clientId, Attachment attachment, String parentId) throws IOException {
                writer.startElement("td", component);
                writer.startElement("a", component);
                writer.writeAttribute("href", "#", null);
                writer.writeAttribute("onmousedown", "confirmationDelete(this, 'attachment');", null);
                String encoding = "if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('"+ parentId + "'),{'" + clientId + "':'" + clientId + "','attachmentId':'" + attachment.getId().toString() +"'},'');}return false";
                writer.writeAttribute("onclick",encoding, null);
                writer.writeAttribute("type", "submit", null);
                writer.startElement("img", component);
                writer.writeAttribute("src", "/acw/images/removeline.gif", null);
                writer.writeAttribute("alt", "", null);

      Here is the setProperties method for the tag:

           protected void setProperties(UIComponent component) {
                FacesContext context = FacesContext.getCurrentInstance();
                setProperty(component, "value", value);
                setProperty(component, "parameterValue", parameterValue);
                setProperty(component, "parameterName", parameterName);
                if (remove != null && UIComponentTag.isValueReference(remove)) {
                     MethodBinding method = FacesContext.getCurrentInstance().getApplication().createMethodBinding(remove, new Class[] {});
                     UICommand command = (UICommand)component;

      Here is how the tag renders as an <a> html tag:
      a href="#" onmousedown="confirmationDelete(this, 'attachment');" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('entity'),{'entity:j_id_jsp_1417973014_25':'entity:j_id_jsp_1417973014_25','attachmentId':'10326'},'');}return false" type="submit"><img src="/images/removeline.gif" alt="" /></a>

      Here is what is heppening:

      When you click on the image to delete the attachment, the control somehow nevers goes to the removeAttachement method in the backing bean. As you can see in the tag above (remove="#{Entity.removeAttachment}" ).

      I have tried everything and at this point am not able to see what is going worng. Anyone who can see the obvious that I am missing please please do point it to me. I am sort of desperate for a solution....