You need to sign in to do that
Don't have an account?
Please help on adding new list records on click of commandlink
Hi,
I have a requirement where in on click of a command link on my visual force page, i wil have to add a new instance of office_name and state in the pageblock table which i have defined in my vf page. Basically I have the pageblock table to display the values from the select clause which i have, but when clicked on a command link another instance along with the existing one should get added
Example
I am displaying already
officename
state
On click of a command link i need another copy of officename and state to be displayed on the screen.
Controller :
public class infoController
{
public User objUser{get;set;}
public List<Office_Location__c> objOfficeLocations{get;set;}
public List<medical_license__c> objMedicalLicenses{get;set;}
public string Ids{get;set;}
public integer count{get;set;}
public void loadInfoDetails()
{
string currentUSERID=UserInfo.getUserId();//ApexPages.currentPage().getParameters().get('Id');
//Ids=UserInfo.getUserId();
//objUser=[select id, Email, FirstName, LastName, CommunityNickname, Alias, Username, Designation__c, Primary_Specialty__c,Additional_Speciality1__c, Additional_Speciality2__c,(Select Office_Name__c, State__c From Office_Location__r) From User where id = :currentUSERID ];
objUser=[Select id, Email, FirstName, LastName, CommunityNickname, Alias, Username, Designation__c, Primary_Specialty__c,Additional_Speciality1__c, Additional_Speciality2__c,
(Select Name, Office_Name__c, Mailing_Address_Line_1__c, Mailing_Address_City__c, User_ID__c, Zip__c, Phone__c, State__c, Fax__c, Delivery_Address_1__c, Mailing_Address_2__c,
Delivery_Fax__c, Delivery_Phone__c, Delivery_Zip__c, Delivery_State__c, Delivery_Address_2__c, Delivery_City__c From Office_Location__r),
(Select Name, Medical_License_Number__c,State__c, User_ID__c From Medical_Licenses__r) From User u where id = :currentUSERID];
}
}
VF page :
<apex:page controller="infoController" action="{!loadInfoDetails}" showHeader="false" sidebar="false" > <apex:form > <apex:outputLink value="{!$Site.Prefix}/secur/logout.jsp" rendered="{!NOT(ISPICKVAL($User.UserType,'Guest'))}">{!$Label.site.logout}</apex:outputLink> <apex:pageBlock > <apex:pageblock title="My Info"> <apex:pageblocksection title="Personal Details"> <apex:pageblocksectionitem > <apex:outputLabel for="txtUName">User Name</apex:outputLabel> <apex:inputText id="txtUName" value="{!objUser.Username}"/> </apex:pageblocksectionitem> <apex:pageblocksectionitem > <apex:outputLabel for="txtEmail">User Email</apex:outputLabel> <apex:inputText id="txtEmail" value="{!objUser.Email}"/> </apex:pageblocksectionitem> <apex:pageblocksectionitem > <apex:outputLabel for="txtFirstName">First Name</apex:outputLabel> <apex:inputText id="txtFirstName" value="{!objUser.FirstName}"/> </apex:pageblocksectionitem> <apex:pageblocksectionitem > <apex:outputLabel for="txtLastName">Last Name</apex:outputLabel> <apex:inputText id="txtLastName" value="{!objUser.LastName}"/> </apex:pageblocksectionitem> </apex:pageblocksection> </apex:pageBlock> <apex:pageBlock mode="edit" title="Office Locations"> <apex:pageBlockTable columns="1" value="{!objUser.Office_Location__r}" var="officeLoc"> <apex:column > <apex:outputLabel for="txtoffName">Office Name</apex:outputLabel> <apex:inputText id="txtoffName" value="{!officeLoc.Office_Name__c}"/> </apex:column> <br> </br> <apex:column > <apex:outputLabel for="txtstate">State</apex:outputLabel> <apex:inputText id="txtstate" value="{!officeLoc.State__c}"/> </apex:column> </apex:pageBlockTable> </apex:pageblock> </apex:pageBlock> </apex:form> </apex:page>
I wrote a blog post on pretty much this topic at:
http://bobbuzzard.blogspot.co.uk/2011/07/managing-list-of-new-records-in.html