• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

<html:link> problem

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
reply
    Bookmark Topic Watch Topic
  • New Topic