如何从可迭代组件向控制器传递参数?我正在使用带有输入复选框的actionSupport来调用控制器中的操作方法。我需要将两个值传递回控制器,我可以在内部类中引用它,并在内部类中的两个属性上设置值。
以下是我的VF页面的相关部分:
<apex:pageBlock id="participantBlock">
<apex:pageBlockButtons location="top" id="topBtnParticipant">
<apex:commandButton id="btnParticipant" value="Add Participant" action="{!addParticipant}" reRender="participantTable" />
</apex:pageBlockButtons>
<apex:pageBlockSection title="Participants" columns="1" id="participantSection">
<apex:pageBlockTable id="participantTable" value="{!participantLinesForPage}" var="part">
<apex:column style="white-space:nowrap;text-align:center;" width="4%">
<apex:commandLink rerender="participantTable" action="{!deleteParticipant}">
<apex:param name="del" value="{!part.iterate}"/>
<apex:image id="deleteImage" value="{!URLFOR($Resource.Icons, 'delete.png')}" width="16" height="16"/>
</apex:commandLink>
</apex:column>
<apex:column headerValue="Contact" width="30%">
<apex:inputHidden value="{!part.contactId}" id="targetContactId" />
<apex:inputText value="{!part.contactName}" id="targetContactName" onFocus="this.blur()" disabled="false" style="width:175px;" />
<a href="#" onclick="openContactLookupPopup('{!$Component.targetContactName}', '{!$Component.targetContactId}', 'userLookupIcon{!part.iterate}', 'accountLookupIcon{!part.iterate}'); return false" ><img onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" onfocus="this.className = 'lookupIconOn';" onblur="this.className = 'lookupIcon';" class="lookupIcon" src="/s.gif" id="contactLookupIcon{!part.iterate}" /></a>
</apex:column>
<apex:column headerValue="Add Task" width="6%" headerClass="columnAlignment" styleClass="columnAlignment">
<apex:inputCheckbox value="{!part.selected}" disabled="{!IF(part.selected == true, true, false)}" >
<apex:actionSupport event="onchange" action="{!addTaskFromParticipant}" oncomplete="this.disabled=true;" rerender="taskTable" />
<apex:param value="{!part.contactId}" assignTo="{!whoid}" />
<apex:param value="{!part.contactName}" assignTo="{!whoname}" />
</apex:inputCheckbox>
</apex:column>
<apex:column headerValue="User" width="30%">
<apex:inputHidden value="{!part.userId}" id="targetUserId" />
<apex:inputText value="{!part.userName}" id="targetUserName" onFocus="this.blur()" disabled="false" style="width:175px;" />
<a href="#" onclick="openUserLookupPopup('{!$Component.targetUserName}', '{!$Component.targetUserId}', 'contactLookupIcon{!part.iterate}', 'accountLookupIcon{!part.iterate}'); return false" ><img onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" onfocus="this.className = 'lookupIconOn';" onblur="this.className = 'lookupIcon';" class="lookupIcon" src="/s.gif" id="userLookupIcon{!part.iterate}" /></a>
</apex:column>
<apex:column headerValue="Account" width="30%">
<apex:inputHidden value="{!part.accountId}" id="targetAccountId" />
<apex:inputText value="{!part.accountName}" id="targetAccountName" onFocus="this.blur()" disabled="false" style="width:175px;" />
<a href="#" onclick="openAccountLookupPopup('{!$Component.targetAccountName}', '{!$Component.targetAccountId}', 'contactLookupIcon{!part.iterate}', 'userLookupIcon{!part.iterate}'); return false" ><img onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" onfocus="this.className = 'lookupIconOn';" onblur="this.className = 'lookupIcon';" class="lookupIcon" src="/s.gif" id="accountLookupIcon{!part.iterate}" /></a>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
我尝试使用<apex:param>
组件和assignTo
属性。但是,这永远不会激发。
当用户选中该复选框时,我想在<apex:pageBlockTable>
中传递该特定记录的contactId和contactName,并将其设置为属性whoid
和whoname
然后我可以在我的内部类中引用这些属性,并将值设置为我在我的内部类中定义的一些属性,这些属性在我的VF页面的其他地方使用。有没有办法做到这一点?
感谢您的帮助。 问候。
答案 0 :(得分:0)
更改
<apex:actionSupport event="onchange" action="{!addTaskFromParticipant}" oncomplete="this.disabled=true;" rerender="taskTable" />
<apex:param value="{!part.contactId}" assignTo="{!whoid}" />
<apex:param value="{!part.contactName}" assignTo="{!whoname}" />
要
<apex:actionSupport event="onchange" action="{!addTaskFromParticipant}" oncomplete="this.disabled=true;" rerender="taskTable" >
<apex:param value="{!part.contactId}" assignTo="{!whoid}" />
<apex:param value="{!part.contactName}" assignTo="{!whoname}" />
</apex:actionSupport>