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.
A previous post describes how to pass paramters to a Visualforce page, and fetch the passed parameter values in your Apex Class(controller). Click here to read the post.
In this article we will see how to fetch the paramter value directly in your Visualforce page instead of getting it from the Apex Class(controller).
{!$CurrentPage.parameters.paramtername}
This global variable provides the capability.
Let's see a small visualforce example to see how it works.
In this article we will see how to fetch the paramter value directly in your Visualforce page instead of getting it from the Apex Class(controller).
{!$CurrentPage.parameters.paramtername}
This global variable provides the capability.
Let's see a small visualforce example to see how it works.
<apex:page>
The value of the paramter name passed to this page is :{!$CurrentPage.parameters.name}
</apex:page>
Save the above Visualforce page with the name "testpage".
Now, go to the URL bar and type the following address
http://yourinstance.salesforce.com/apex/testpage?name=Edwin
Your Visualforce page will display the output "
The value of the paramter name passed to this page is : Edwin
You can use the apex:param component when you want to pass paramters dynamically between visualforce pages, and the above method works as usual.
This is a step by step guide which takes you through getting started with using styles and CSS in your Visualforce Pages.