Search
Twitter

Entries in Visualforce tutorial (4)

Wednesday
May012013

Explore the Different Messaging Options in VisualForce (Part 2)

This post begins where Part 1 left off; continuing to explore the different messaging options in VisualForce.

  • apex:message allows for field-specific errors. Let's look the code below and see how it renders:
<apex:page controller="TestMessageController">
    <apex:form >
        <apex:outputLabel value="Test String" /><apex:inputField value="{!test.Name}" id="test"/>
        <br/><apex:message for="test"/>
    </apex:page>
 
public class TestMessageController{
    public Account test {get;set;}
    public TestMessageController(){
        test = new Account();
        test.Id.addError('Correct');
        test.Name.addError('Wrong');
 
    }
}
  • The last option we have is apex:messages, which is similar to apex:message, except that it displays all errors in a list. Let's incorporate the apex:messages in the previous code and see how it renders:
<apex:page controller="TestMessageController">
    <apex:messages />
    <apex:form >
      <apex:outputLabel value="Test String" /><apex:inputField value="{!test.Name}" id="test"/>
      <br/><apex:message for="test"/>
    </apex:form>
</apex:page>
 
public class TestMessageController{
    public Account test{get;set;}
    public TestMessageController(){
        test = new Account();
        test.Id.addError('Correct');
        test.Name.addError('Wrong');
    }
}
Friday
Apr262013

Explore Different Messaging Options in VisualForce (Part 1)

VisualForce offers several options when it comes messages such as a warning of an error. Today, I'm going to explain the key differences between the messaging options in VisualForce:

  • apex: pageMessage is used to display a single custom message using the Salesforce formatting. With this one, you have the option to control and specify the "Severity" (the displaying of the message box) and the "Strength" (size of the box). Check out the below code for an example:

 <apex:page>
    <apex:pageMessage summary="This is a pageMessage" severity="error" strength="1"/>
</apex:page>
  • Another option is to use apex: pageMessages; which is used to concurrently display the custom messages entered by the developer and those generated by Salesforce. See the example in the code below and how it renders:
 <apex:page controller= "TestMessageController">
  <apex:pageMessages />
</apex:page>
 
public class TestMessageController{
    public TestMessageController(){
         ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'This is apex:pageMessages'));
         ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'This is apex:pageMessages still'));
         ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'This is apex:pageMessages info'));
         ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'This is apex:pageMessages warning'));
    }
}
Monday
Jul022012

Create a New Record for Object in Visual Force

 Use "Standard Controller"

By using the "SAVE" or "QUICKSAVE" actions, you can create a new record. The following is an example of creating a new contact:

<apex:page standardController="Contact">
<apex:form>
<apex:pageBlock title="My Content" mode="edit">
<apex:pageBlockButtons>
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Content Section" columns="2">
<apex:inputField value="{!contact.name}"/>
<apex:inputField value="{!contact.type}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Wednesday
Feb092011

A Refresher Course

So, there's a new employee in the office who needs some quick tutorials on Developer Force. In providing some direction on available resources, I was reminded it is a good thing to go back to the basics occasionally and get refreshed on the foundation of working on Force.com as well as checking out what tutorials are available when you need. We all find ourselves in that category at some point and I hadn't looked at what's available in a while. I went straight to the Salesforce.com Technical Library and searched through the workbooks, found it pretty impressive, and thought I would share the list of subject matter covered.

There are 10 tutorials alone in the core Force.com workbook, which can be viewed online or downloaded as a PDF:

  • Tutorial #1: Creating a Warehouse Application
  • Tutorial #2: Adding Relationships
  • Tutorial #3: Using Formulas and Validation Rules
  • Tutorial #4: Using Workflow and Approvals
  • Tutorial #5: Adding Business Logic with Apex
  • Tutorial #6: Adding Tests to Your Application
  • Tutorial #7: Building a Custom User Interface Using Visualforce
  • Tutorial #8: Creating a Public Webpage Using Force.com Sites
  • Tutorial #9: Creating a Store Front
  • Tutorial #10: Creating a Desktop App with Adobe Flash Builder for Force.com

 

There's a Visualforce workbook that offers a tour of its many features and a gentle introduction to using those features for building user interfaces to be hosted natively on the Force.com platform. This workbook is also available online as well as in the form of a PDF download.

 

With the talk of chatter hitting the Superbowl Ad airwaves, you better brush up! There's a Chatter Workbook that has 4 tutorials, introducing you to the major components of Salesforce Chatter and how to begin developing applications using Chatter features.

  • Tutorial #1: Orientation and Setup
  • Tutorial #2: Building on the Platform
  • Tutorial #3: Accessing Chatter From a Java Client
  • Tutorial #4: Accessing Chatter From a .NET Client

 

And with Salesforce, there's always a bonus! A more advanced topic, for sure, but it may be of interest:

  • Bonus Tutorial #1: Add Authentication to the Public Store Front

 

One other bonus is that the core workbook is now available in French, Korean, and German with more languages on the horizon.