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
kkaalkkaal 

Send a value from a button or link to controller

I need to do a table where I allow in-place editing.

 

What I am trying to do is to iterate through my table data and for each line create either a output line ( id="readLine") or a edit line (id="editLine"). They are switched by a status variable in the controller which keeps the id of the line to be edited. 

 

 

<apex:pageBlock title="myList"> <apex:form > <apex:panelGrid columns="1" style="width: 100%" id="panelGrid"> <apex:repeat value="{!Relationships}" var="relation"> <apex:panelGroup id="readLine" rendered="{!or(selectedId != relation.Id,selectedId==null)}"> <tr> <td><apex:outputText value="{!relation.Id}" style="padding:4px" /></td> <td><apex:outputText value="{!relation.Analysis_Period__c}" style="padding:4px" /></td> <td><apex:outputText value="{!relation.Relationship_Code__c}" style="padding:4px" /></td>

.... more fields ... <td><apex:commandLink value="Edit" action="{!edit}" onClick="setEditorToLine('{!relation.Id}')" id="editlink"/></td> </tr> </apex:panelGroup> <apex:panelGroup id="editLine" rendered="{!selectedId == relation.Id}"> <tr> <td><apex:inputField value="{!relation.Id}" style="padding:4px" /></td> <td><apex:inputField value="{!relation.Analysis_Perios__c}" style="padding:4px" /></td> <td><apex:inputField value="{!relation.Relationship_Code__c}" style="padding:4px" /></td>

... more fields ... <td><apex:commandLink value="Save" action="{!edit}" /></td> </tr> </apex:panelGroup> </apex:repeat> </apex:panelGrid> <apex:actionFunction action="{!edit}" name="setEditorToLine" rerender="panelGrid"> <apex:param name="firstParam" assignTo="{!SelectedId}" value="" /> </apex:actionFunction> </apex:form> </apex:pageBlock>

 

 My intention: when I click the commandLink (id="editlink") it should write the relation.Id into the status variable in my controller.

 

My controller:

 

 

public with sharing class NexTestController { public PageReference edit() { return null; } private final Account account; private final List<Relationship__c> relationships; private String selectedId; public NexTestController(){ account = [select id, PersonContactId, name, site from Account where id = :ApexPages.currentPage().getParameters().get('id')]; relationships = [select Analysis_Period__c, Relationship_Code__c, Contact__r.Id, Contact__r.Name, Contact__r.LastName, Analysis_Perios__c from Relationship__c where Contact2__r.Id = :account.PersonContactId]; selectedId = ''; } public Account getAccount(){ return account; } public List<Relationship__c> getRelationships(){ return relationships; } public PageReference edit(){ return null; } public void setSelectedId(String selId){ selectedId = selId; } public String getSelectedId(){ return selectedId; } }

 

 My problem: I do not get the Id from my link into my controller. 

 

Any  idea what is wrong?

 

Thanks 

 

 

 

SPDSPD

while using param you dont need to use getter and setter methods for a property....instead you just need to declare the property as below:

 

 

public String myProperty { get; set;}

 

 

and also be sure to use name attribute of param

kkaalkkaal

I just replaced my own getter and setter with the 

public String variable {get; set}

 

But it does not work. My explicid getter and setter did work. Did I overlook something?