+ Start a Discussion
siddarth rajsiddarth raj 

How to pass parameter on button click to the controller on a repeat block

Following is the page

apex:repeat value="{!wrapper.consignments}" var="consignment" id="delivConsignmentList">

                   <apex:pageBlockSection title="Consignment {!consignment.Position__c}" id="delivConsignment">
                     <apex:outputField value="{!consignment.Due__c}" id="delivDue" styleClass="due"/>
and so on
                    <apex:commandButton value=" DIR "  action="{!newdirForConsignment}"  id="btnRaiseDIR" />
</apex:repeat>

This comman button will not an Ajax call it will not rerender rather on button click it just open a  new window with reference to the particular consignment.

As it is repeated button for each consignment how would i identify this button being clicked from particular consignment , mean want id of the consignment on which the button is been clikced to the controller. Any ideas please

Thanks in advance to all
Balaji BondarBalaji Bondar
Hi Siddarth,

Try passing parameter using <apex:param>.Below is the sample code:
<apex:commandButton value="Button" action="{!doNothing}">
<apex:param id="param2" name="tempLineId2" value="two" assignTo="{!test}" />
</apex:commandButton> <br/>
siddarth rajsiddarth raj
Hi Balaji

Thanks for the reply

This approach only working on rerender
 
<apex:commandButton value="Button" action="{!doNothing}" reRender="empty " >
 <apex:param id="param2" name="tempLineId2" value="two" assignTo="{!test}" />
</apex:commandButton> <br/>

But in my scenario I have to open a new window with the reference to the consignment no rerender of same page.

 
James LoghryJames Loghry
Siddarth,

You will probably be better off using the onClick attribute of a html button, and then calling a Visualforce remoting function with a parameter.  See the "sayHello" example here: https://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting.htm
siddarth rajsiddarth raj

Hi james

Thanks for the Suggestion. 

Seems Remote function is something like ajax like which we could achieve throught he rerender. 

Where my scenario I wnated to open a new page not to have changes on same page.

If it is just one object on the page it would have qute easy to pass or obtain id of the object in controller..but  here it is 

A page called delivery which would have multiple consignments (repeat block) We will have a button called DIR for each consignment on this deliverypage...

In the controller call  i should able to get the id of the consignment from which this is being triggered.(clicked)

This is what our scenario... Appreciate if you have any suggestions.