Tuesday, 20 August 2013

passing parameters to controller from iterable component

passing parameters to controller from iterable component

How can I pass parameters to my controller from an iterable component? I'm
using actionSupport with an input checkbox to call an action method in my
controller. I need to pass two values back to the controller that I can
reference in my inner class and set the values on two of my properties in
the inner class.
Here is the relevant section of my VF page:
<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>
I was trying to use the <apex:param> component and the assignTo attribute.
But, that never fires.
When the user selects the checkbox, I want to pass the contactId and
contactName for that particular record in the <apex:pageBlockTable> and
set it equal to the properties whoid and whoname
I can then reference those properties in my inner class and set the values
equal to a couple of properties that I have defined in my inner class that
is used elsewhere in my VF page. Is there a way to do this?
Thanks for any help. Regards.

No comments:

Post a Comment