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
koenkoen 

actionSupport in pageBlockTable doesn't work for event onRowClick

 

<apex:page standardController="Opportunity" extensions="OpportunityCampaignController" tabStyle="Opportunity">

	<apex:form >
		<apex:messages />
		
		<apex:pageBlock mode="edit" id="accountSearchBlock" title="Opportunity [{!opportunity.name}] Campaign Selector">
			<apex:pageBlockSection >
				<apex:pageBlockSectionItem >
					<apex:outputLabel for="acountSearchText">Search Account:</apex:outputLabel>
					<apex:panelGroup >
						<apex:inputText id="acountSearchText" value="{!accountSearchText}"/>
						<apex:commandButton value="Go!" action="{!doAccountSearch}" reRender="accountSearchResults, contactSearchResults, campaignSearchResults, campaignDetail" status="accountSearchStatus"/>
					</apex:panelGroup>
				</apex:pageBlockSectionItem>
			</apex:pageBlockSection>
			
			<apex:actionStatus id="accountSearchStatus" startText="Loading accounts..."/>
			<apex:pageBlockSection title="Accounts" id="accountSearchResults" columns="1">
				<apex:pageBlockTable value="{!accountSearchResults}" var="accountCur" rendered="{!NOT(ISNULL(accountSearchResults))}">
					<apex:column >
						<apex:facet name="header">Name</apex:facet>					
						<apex:outputPanel >
							<apex:actionSupport event="onclick" action="{!doSelectAccount}" reRender="contactSearchResults, campaignSearchResults, campaignDetail" status="contactSearchStatus">
								<apex:param name="accountId" value="{!accountCur.id}"/>
							</apex:actionSupport>
							{!accountCur.name}
						</apex:outputPanel>
					</apex:column>
					<apex:column value="{!accountCur.industry}"/>
					<apex:column value="{!accountCur.billingCountry}"/>
				</apex:pageBlockTable>
			</apex:pageBlockSection>
			
			<apex:actionStatus id="contactSearchStatus" startText="Loading contacts..."/>			
			<apex:pageBlockSection title="Contacts" id="contactSearchResults" columns="1">
				<apex:pageBlockTable value="{!contactSearchResults}" var="contactCur" rendered="{!NOT(ISNULL(contactSearchResults))}">
					<apex:column >
						<apex:facet name="header">Name</apex:facet>					
						<apex:outputPanel >
							<apex:actionSupport event="onclick" action="{!doSelectContact}" rerender="campaignSearchResults, campaignDetail" status="campaignSearchStatus">
								<apex:param name="contactId" value="{!contactCur.id}"/>
							</apex:actionSupport>
							{!contactCur.name}
						</apex:outputPanel>
					</apex:column>
					<apex:column value="{!contactCur.email}"/>
					<apex:column value="{!contactCur.phone}"/>
				</apex:pageBlockTable>
			</apex:pageBlockSection>
			
			<apex:actionStatus id="campaignSearchStatus" startText="Loading campaigns..."/>			
			<apex:pageBlockSection title="Campaigns" id="campaignSearchResults" columns="1">
				<apex:pageBlockTable value="{!campaignSearchResults}" var="campaignCur" rendered="{!NOT(ISNULL(campaignSearchResults))}">
					<apex:column >
						<apex:facet name="header">Name</apex:facet>					
						<apex:outputPanel >
							<apex:actionSupport event="onclick" action="{!doSelectCampaign}" rerender="campaignDetail" status="campaignDetailStatus">
								<apex:param name="campaignId" value="{!campaignCur.id}" assignTo="{!campaignId}"/>								
							</apex:actionSupport>
							{!campaignCur.name}
						</apex:outputPanel>
					</apex:column>
					<apex:column value="{!campaignCur.status}"/>
					<apex:column value="{!campaignCur.startDate}"/>
					<apex:column value="{!campaignCur.endDate}"/>
				</apex:pageBlockTable>
			</apex:pageBlockSection>
			
			<apex:pageBlockSection title="Predefined Campaigns" id="predefinedCampaignList" columns="1">
				<apex:pageBlockTable value="{!predefinedCampaignList}" var="campaignCur" rendered="{!NOT(ISNULL(predefinedCampaignList))}">
					<apex:actionSupport event="onRowClick" action="{!doSelectCampaign}" rerender="campaignDetail" status="campaignDetailStatus">
						<apex:param value="{!campaignCur.id}" assignTo="{!campaignId}"/>
					</apex:actionSupport>
					<apex:column value="{!campaignCur.name}"/>
					<apex:column value="{!campaignCur.status}"/>
					<apex:column value="{!campaignCur.startDate}"/>
					<apex:column value="{!campaignCur.endDate}"/>
				</apex:pageBlockTable>
			</apex:pageBlockSection>
		</apex:pageBlock>
			
		<apex:pageBlock title="Selected Campaign">			
			<apex:pageBlockButtons location="top">
				<apex:commandButton value="Select Campaign" action="{!doSaveOpportunityCampaign}"/>
				<apex:commandButton value="Cancel" action="{!cancel}"/>
			</apex:pageBlockButtons>

    		<apex:outputPanel id="campaignDetail">
        		<apex:actionStatus startText="Loading selected campaign detail..." id="campaignDetailStatus">
            		<apex:facet name="stop">
                		<apex:detail subject="{!campaignId}" relatedList="false" title="false" />
            		</apex:facet>
        		</apex:actionStatus>
    		</apex:outputPanel>    
		</apex:pageBlock>
		
	</apex:form>

</apex:page>

 When I add actionSupport within outputPanel in column, it works fine. But when I add actionSupport within pageBlockTable to response onRowClick event, both apex:param and action do not work. Only reRender object is rendered without any changes.

 

I am crazy with this problem :(

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Bhawani SharmaBhawani Sharma

Can you try this one :

 

<apex:actionSupport event="onRowClick" action="{!doSelectCampaign}" rerender="campaignDetail" status="campaignDetailStatus" immediate="true">

All Answers

Bhawani SharmaBhawani Sharma

Can you try this one :

 

<apex:actionSupport event="onRowClick" action="{!doSelectCampaign}" rerender="campaignDetail" status="campaignDetailStatus" immediate="true">
This was selected as the best answer
bob_buzzardbob_buzzard

The apex:actionSupport component is used to add Ajax support to a component based on a JavaScript event.  onRowClick isn't a javascript event - there's a list of valid events at: http://www.w3schools.com/jsref/dom_obj_event.asp

 

onRowClick is an attribute on the pageblocktable, which I would imagine adds an onlick handler to the table row.  The description does refer to the "onRowClick" event, which I agree is confusing.

Bhawani SharmaBhawani Sharma

Hi Bob,

 

I checked with the Visualforce documents and it says :

The JavaScript invoked if the onRowClick event occurs--that is, if the user clicks a row in the page block table.

 

and My thinking is if you can invoke the javascript, then it can talk to controller also may be using action function.

Let me check it . I will get back to you on this.

 

 

koenkoen

Thanks a lot for your help! It works fine now :)

 

I found that if I set immediate to true then the action associated with this component should happen immediately, without processing any validation rules associated with the fields on the page.

 

Could you please tell me why this rules do not affect actionSupport with apex:outputPanel?

bob_buzzardbob_buzzard

(Returning to this thread after quite some time)

 

As you have found, specifying immediate=true causes the validation rules and updating of viewstate.  You may find that you had an error on the page that stopped the submission to the controller, but as you were only rerendering a section of the page, it wasn't possible for the error to be displayed.  I've hit this a few times in the past.

Bhawani SharmaBhawani Sharma

To be on the safer side, you can also rerender the error message component.like:

 

<apex:pageMessages id="validationMsg" />

 

reRender="pbs,validationMsg"

 

In this case if any error comes, that will be displayed in on the page.