我有这个命令按钮
<p:commandButton onclick="confirmation1.show()"
id="delFriend" title="Delete #{userFriend.profileFullname}" icon="ui-icon ui-icon-trash" >
</p:commandButton>
这是确认对话框
<p:confirmDialog id="confirmDialog" message="Are you sure you want to delete this friend ?"
header="Deleting friend" severity="alert" widgetVar="confirmation1">
<p:commandButton id="confirm" value="Yes Sure" oncomplete="confirmation1.hide()"
action="#{messagesManagedBean.deleteFriend}">
<f:param value="#{profileId}" name="profileId" />
</p:commandButton>
<p:commandButton id="decline" value="Not Yet" onclick="confirmation1.hide()" type="button" />
</p:confirmDialog>
两者都在 ui:repeat 内,当我单击确认对话框中的“是肯定”按钮时,它会获取 ui:repeat 列表中最后一个元素的 profileId。
我尝试了 f:param 方法,然后尝试在 bean 中获取请求参数但徒劳无功。它做同样的事情。
需要帮助。谢谢
编辑
我已将页面内容更改为
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../Styles/homepage-style.css" />
<link rel="stylesheet" type="text/css" href="../Styles/profile.css" />
<title>Shadi Bandhan | We find the best match for you</title>
</h:head>
<h:body>
<div id="header">
<ui:insert name="header" >
<ui:include src="header.xhtml" />
</ui:insert>
</div>
<div id="main-content">
<p:growl autoUpdate="true" />
<div id="left-pane">
<div id="profile-info-area">
<ui:insert name="profile_info_area" >
<ui:include src="profileInfoArea.xhtml" />
</ui:insert>
</div>
<div id="home-main-area">
<div id="interests-expressions-wrapper">
<div id="interests-expressions-header">
<div id="ie-heading">
Friends
</div>
</div>
<div id="interests-expressions">
<h:form id="interestExpressionsForm">
<p:confirmDialog id="confirmDialog" message="Are you sure you want to delete this friend ?"
header="Deleting friend" severity="alert" widgetVar="confirmation1">
<p:commandButton id="confirm" value="Yes Sure" oncomplete="confirmation1.hide()"
action="#{messagesManagedBean.deleteFriend(userFriend.profileId)}">
</p:commandButton>
<p:commandButton id="decline" value="Not Yet" onclick="confirmation1.hide()" type="button" />
</p:confirmDialog>
<ui:repeat id="interestsRepeator" var="userFriend" value="#{messagesManagedBean.userFriends}">
<center><img class="h-diff" src="../images/differentiator-profile.jpg" width="437" height="1" /></center>
<div class="intExpression">
<div id="senderImg">
<img class="senderImg" src="../images/profile-pic.jpg" width="50" height="50" />
</div>
<div id="intExpression-area">
<div id="senderName">
<p:commandLink id="senderNameLink" styleClass="senderName" value="#{userFriend.profileFullname}" action="#{myProfileManagedBean.loadProfileFrontInformation(userFriend.profileId)}"></p:commandLink>
</div>
<div id="intExpression-body">
#{userFriend.profileAge} <br />
#{userFriend.profileReligion} <br />
#{userFriend.profileLocation} <br />
</div>
<div id="interest-response-area">
<p:commandButton onclick="confirmation1.show()" update=":interestExpressionsForm:confirmDialog"
id="delFriend" title="Delete #{userFriend.profileFullname}" icon="ui-icon ui-icon-trash" >
<f:param value="#{userFriend}" name="userFriend" />
</p:commandButton>
</div>
</div>
</div>
</ui:repeat>
</h:form>
</div>
</div>
</div>
</div>
<div id="right-pane">
<ui:insert name="right-pane" >
<ui:include src="right-pane.xhtml" />
</ui:insert>
</div>
</div>
<div id="footer">
<ui:insert name="footer" >
<ui:include src="footer.xhtml" />
</ui:insert>
</div>
</h:body>
</html>
在BalusC回复之后。但它不起作用,使用 update=":interestExpressionsForm:confirmDialog" 确认对话框打开然后立即关闭。