Trying to delete the selected item in the XPages repeat control, but does not work

373 Views Asked by At

I am trying to delete the selected item in the Xpages repeat control, but it does not work. Please help? Here is my code in the repeat control section

<xp:repeat id="repeat1" rows="30" var="eachQuestion" value="#{questions}"
                indexVar="rowIndex">
<tr>
 <td>...</td>
 <td>  <xp:link     styleClass="btn btn-danger" id="deleteLink">
    <xp:eventHandler event="onClick"
        action="#{javascript:eachQuestion.getDocument().remove(true);}"
        submit="true"
        refreshMode="partial"
        refreshId="listContainer" />
        <i class="fa fa-lg fa-trash-o" />
    </xp:link> </td>
</tr>
</xp:repeat>

Here is what I can see in the client page, generated html and JS code:

XSP.addOnLoad(function() {
XSP.attachPartial("view:_id1:repeat1:0:_id44","view:_id1:repeat1:0:deleteLink", null, "onClick", function(){}, 2, "view:_id1:listContainer");

When I click the delete link icon, nothing happened. I realized function(){} nothing in there. Is there anything wrong or I have to implement the method in the Java code to handle this deletion?

Thanks,

2

There are 2 best solutions below

1
On BEST ANSWER

You just have to change "onClick" to "onclick" in your code and it will work.

Case sensitivity does matter in Xpages. So, your code to delete a document is right but the event "onClick" doesn't gets executed at all.

1
On

You don't say what "questions" is. I assume it's a view. The code looks right to me. You certainly do NOT need Java to delete a document from a rpw in a repeat control.

I would ignore the client side stuff. That's server generated. It's supposed to be empty I think. The server knows what to do.

First check the database ACL. Make sure the user has delete access. I'd also add a Display Errors control on the page. If it's not deleting due to a validation issue it should show there. Then I'd go to OpenNTF and get the XPages Log Reader control. It's a small xpages database that let's you see errors more easily.

I'd start with those ideas.

By the way that's not a good way to do a table in a repeat control. It should be producing invalid HTML. You should use Facets. That is NOT your problem though.