File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes <html:link> problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "<html:link> problem" Watch "<html:link> problem" New topic
Author

<html:link> problem

Deeps Mistry
Ranch Hand

Joined: Jan 31, 2009
Posts: 189
Hi,

I am using Struts1.1

What i want to do : I want to delete a customer by clicking on 'Delete' link. But before deleting the customer i want a confirmation message. If yes then delete, if no then do not delete the customer.

I have implemented the above functionality as follows:

My jsp page:
<logic:iterate id="CustInfo" name = "CustInfo">
<tr>
<td >
<%=i %>
</td>
<td >
<bean:write name ="CustInfo" property="CID"/>
</td>
<td >
<bean:write name ="CustInfo" property="CNAME"/>
</td>
<td >
<bean:write name ="CustInfo" property="ADDR"/>
</td>
<td>
<html:link action="edit.do?method=prepareEdit" paramName="CustInfo" paramProperty="CID" paramId="CID"> Edit/ </html:link>

</td>
<td>

<html:link action="delete.do?method=deleteCustomer" onclick="alertMessage();" paramName="CustInfo" paramProperty="CID" paramId="CID">Delete</html:link>

</td>
</tr>
<% i++; %>
</logic:iterate>


function alertMessage()
{
alert("Inside alert Mesage");
var answer = confirm("Do you want to delete this customer?");
var CID = document.forms[0].CID.value;
alert(CID);
if(answer)
{
action = delete.do?method=deleteCustomer?CID;
alert(Customer deleted successfully!);
}

}

If i try to remove the action property from <html:link> it is giving an error message saying any 1 of href/ action tag should be present.
But i am not getting any confirmation box and the record is getting deleted.

What am i doing wrong?

Thanks
Deeps Mistry
Ranch Hand

Joined: Jan 31, 2009
Posts: 189
Deeps Mistry wrote:Hi,

I am using Struts1.1

What i want to do : I want to delete a customer by clicking on 'Delete' link. But before deleting the customer i want a confirmation message. If yes then delete, if no then do not delete the customer.

I have implemented the above functionality as follows:

My jsp page:
<logic:iterate id="CustInfo" name = "CustInfo">
<tr>
<td >
<%=i %>
</td>
<td >
<bean:write name ="CustInfo" property="CID"/>
</td>
<td >
<bean:write name ="CustInfo" property="CNAME"/>
</td>
<td >
<bean:write name ="CustInfo" property="ADDR"/>
</td>
<td>
<html:link action="edit.do?method=prepareEdit" paramName="CustInfo" paramProperty="CID" paramId="CID"> Edit/ </html:link>

</td>
<td>

<html:link action="delete.do?method=deleteCustomer" onclick="alertMessage();" paramName="CustInfo" paramProperty="CID" paramId="CID">Delete</html:link>

</td>
</tr>
<% i++; %>
</logic:iterate>


function alertMessage()
{
alert("Inside alert Mesage");
var answer = confirm("Do you want to delete this customer?");
var CID = document.forms[0].CID.value;
alert(CID);
if(answer)
{
action = delete.do?method=deleteCustomer?CID;
alert(Customer deleted successfully!);
}

}

If i try to remove the action property from <html:link> it is giving an error message saying any 1 of href/ action tag should be present.
But i am not getting any confirmation box and the record is getting deleted.

What am i doing wrong?

Thanks



Hey
My problem got solved.

What i did is :
<html:link action="delete.do?method=deleteCustomer" onclick="return confirm('Are you SURE you want to delete this record?')" paramName="CustInfo" paramProperty="CID" paramId="CID">Delete</html:link>

Sorry to bother you all
 
GeeCON Prague 2014
 
subject: <html:link> problem