+ Start a Discussion
lopezclopezc 

how can I add query string parameters to a commandButton?

Hi,

 

I need to pass an ID to the action executed when pressing the commandButton, I have done how it is shown in the code beloq but it is not working. The action is called but the parameter is not set so I dont have access to the ID within the controller. Any ideas why?

 

 

<apex:component controller="MyRequestsController">
<apex:attribute name="windowsLogin" description="windows user name" type="String" required="required" assignTo="{!alias}"/>
<apex:attribute name="contactId" description="contact Id" type="ID" required="required" assignTo="{!contactId}"/>
	<apex:form >
		<h2>Previous Requests</h2>		
		<apex:pageblock id="openqueries">
		<apex:pageBlockTable value="{!currentQueryBatch}" var="query" columns="7" styleClass="query-table">
		             <apex:column headerValue="Request Number"><a href="requestTicket/RequestDetailsView?id={!query.id}"><apex:outputText value="{!query.Name}"/></a></apex:column>
		            <apex:column headerValue="Subject" value="{!query.Subject__c}"/>
		            <apex:column headerValue="Status" value="{!query.Status__c}"/>
		            <apex:column headerValue="Team" value="{!query.Team_Name__c}"/>
		            <apex:column headerValue="Date" value="{!query.CreatedDate}"/>
		            <apex:column headerValue="OwnerId" value="{!query.OwnerId}"/>
		            <apex:column headerValue="Approval Status" value="{!query.Approval_Status__c}" rendered="{!OR(openQueriesDisplayed,closedQueriesDisplayed)}"/>
		            <apex:column rendered="{!approvalQueriesDisplayed}">
                		<apex:facet name="header">Action</apex:facet>
                        	<apex:commandButton value=" Approve " action="{!approveRequest}">
                        	<apex:param name="queryId" assignTo="{!queryId}" value="{!query.Id}" />
                        	</apex:commandButton>
                        	<apex:commandButton value=" Reject " action="{!rejectRequest}">
                        	<apex:param name="queryId" assignTo="{!queryId}" value="{!query.Id}" />
                        	</apex:commandButton>
            	   </apex:column>
		</apex:pageBlockTable>
		</apex:pageblock>
	</apex:form>
</apex:component>

 

 

 

lopezclopezc

Strange, it worked when I replaced the component commandButton with the component commandLink.

 

Why is it not working with commandButton?

gv007gv007

As per my knowldge command button is a good old bug still trouble people.