As the title of the article implies, in this post we will be seeing an example which uses radio button in a table in visualforce and allows selecting one of the records in the table.
You can see a demo of the example here - Click here (forcetreedemos)
Visualforce Page:
Apex Class: RadioButton
You can see a demo of the example here - Click here (forcetreedemos)
Visualforce Page:
<apex:page controller="RadioButton" showheader="false">
<apex:form>
<apex:pageblock id="allcons" title="Available Contacts">
<apex:pageblocktable id="allcons" value="{!AllContacts}" var="allcon">
<apex:column headervalue="Set as Primary">
<apex:actionsupport action="{!selectcon}" event="onclick" rerender="consel,allcons">
<input type="radio" />
<apex:param name="conid" value="{!allcon.Id}">
</apex:param></apex:actionsupport>
</apex:column>
<apex:column headervalue="Last Name">
<apex:outputfield value="{!allcon.LastName}">
</apex:outputfield></apex:column>
<apex:column headervalue="First Name">
<apex:outputfield value="{!allcon.FirstName}">
</apex:outputfield></apex:column>
<apex:column headervalue="Email">
<apex:outputfield value="{!allcon.Email}">
</apex:outputfield></apex:column>
<apex:column headervalue="Phone">
<apex:outputfield value="{!allcon.Phone}">
</apex:outputfield></apex:column>
</apex:pageblocktable>
</apex:pageblock>
<apex:pageblock id="consel" title="Selected Contact">
<apex:pageblocktable id="allcons" value="{!selectedContact}" var="selcon">
<apex:column headervalue="Last Name">
<apex:outputfield value="{!selcon.LastName}">
</apex:outputfield></apex:column>
<apex:column headervalue="First Name">
<apex:outputfield value="{!selcon.FirstName}">
</apex:outputfield></apex:column>
<apex:column headervalue="Email">
<apex:outputfield value="{!selcon.Email}">
</apex:outputfield></apex:column>
<apex:column headervalue="Phone">
<apex:outputfield value="{!selcon.Phone}">
</apex:outputfield></apex:column>
</apex:pageblocktable>
</apex:pageblock>
</apex:form>
</apex:page>
Apex Class: RadioButton
public class RadioButton {
List<contact> selectcon;
Public List<contact> getAllContacts()
{
List<contact> allcons = [Select Id,FirstName,LastName,Email,Phone from Contact limit 5];
return allcons;
}
Public void selectcon()
{
String selcontactid = System.currentPagereference().getParameters().get('conid');
Contact con = [Select Id,FirstName,LastName,Email,Phone from Contact where Id=:selcontactid];
selectcon = new List<contact>();
selectcon.add(con);
}
Public List<contact> getselectedContact()
{
return selectcon;
}
}
This Winter 11, there is a new chatter component which allows you to embed chatter feeds in a Visualforce page.
Here is the official release notes and further details. Click here
Here is a sample visualforce page using this component. This page displays the feeds for the current logged in user.
Here is the official release notes and further details. Click here
Here is a sample visualforce page using this component. This page displays the feeds for the current logged in user.
<apex:page >
<chatter:feed entityId="{!$User.Id}"/>
</apex:page>
Note that the "entityID" attribute determines the feeds to be displayed. This can be a UserId, a custom or standard object record ID provided chatter is enabled for that object.
You may also create a Visualforce page with this component, and then create a home page sidebar component and embed the Visualforce page in the sidebar component.