rich:modalPanel: How to send parameters
rituraj_tiwari Mar 16, 2008 3:35 AM have a list of items with a Delete button next to each item. If the user hits the delete button, I would like to pop up a model dialog for confirmation before deleting the item. My problem is, I am unable to send any parameters to the modal dialog in order to display attributes of the item selected in the dialog.
Here is a snip of the code:
The modal dialog panel:
<rich:modalPanel id="deleteEmailConfirm" ... <tr> <td><h:commandButton value="Yes" onclick="confirmEmailDelete()"/></td> <td><h:commandButton value="No" onclick="cancelEmailDelete()"/></td> </tr> ...
This modal panel is invoked from the following JS function
function preDeleteEmail(email, uid)
{
var emailToDelete = new Object();
emailToDelete.email = email;
emailToDelete.uid = uid;
// show confirmation dialog
var panel = Richfaces.findModalPanel('deleteEmailConfirm');
// got to set the email in question on the panel itself since the
// DOM is not available there
panel.emailToDelete = emailToDelete;
Richfaces.showModalPanel('deleteEmailConfirm',{width:400, top:200})
}
And the confirmation and cancellation functions:
function cancelEmailDelete()
{
Richfaces.hideModalPanel('deleteEmailConfirm');
var panel = Richfaces.findModalPanel('deleteEmailConfirm').emailToDelete=undefned;
}
function confirmEmailDelete()
{
// Get the handle to the panel
var email = Richfaces.findModalPanel('deleteEmailConfirm').emailToDelete;
Seam.Component.getInstance("EditProfile").deleteEmail(email.uid,
function(result)
{
// simulate cancel
cancelEmailDelete();
// update email display
Seam.Component.getInstance("EditProfile").getEmails(getEmailsCallback);
});
}
My problem is that findModalPanel always returns undefined. I cannot think of any other way to get information about the selected item to the code in the modal panel.
Any ideas?