function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bohemianguy100bohemianguy100 

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.

Avidev9Avidev9

Well I guess you will need the name parameter for setting a variable using apex param

 

<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 name="whoId" value="{!part.contactId}" assignTo="{!whoid}" />
                        <apex:param name="whoname" value="{!part.contactName}" assignTo="{!whoname}" />
                    </apex:inputCheckbox>
bohemianguy100bohemianguy100

Thanks for replying to my post.  I did try adding the name attributes to the parameters component, but the debug is simply returning an empty string.  Interestingly, before adding the name attribute, I was getting back a null for the properites, but now it is an empty string.  I've also tried with ActionFunction and that does not work because ActionFunction cannot be inside an iterable component. 

Avidev9Avidev9

**bleep**!!!

My mistake, I assumed that your markup is correct.

You didnt actually enclosed the param in action support

 

 

<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 name="whoId" value="{!part.contactId}" assignTo="{!whoid}" />
                            <apex:param name="whoname" value="{!part.contactName}" assignTo="{!whoname}" />
</apex:actionSupport> </apex:inputCheckbox>
bohemianguy100bohemianguy100

Hi Avidev9,

 

That was my mistake, my apologies.  I had been making multiple changes to the markup and when I copied it into the post, I hadn't enclosed the params correctly within the actionsupport tag.  I did adjust that correctly and still the properites in my controller are empty when I debug the values.  Not null, but simply empty. Both string properies come back in the debug empty.