VF Page Basics 1
Without CSS
- <apex:page sidebar="false" showHeader="false">
- <apex:form >
- <br/><br/>
- <div >
- <apex:outputtext value="Welcome to IBM INDIA" > </apex:outputtext>
- </div>
- <br/>
- <table>
- <tr>
- <td >
- <apex:outputtext value="IBM Registration Form" />
- </td>
- </tr>
- <tr>
- <td>
- <apex:outputtext value="IBM Employee ID"></apex:outputtext>
- </td>
- <td>
- <input type="text"/>
- </td>
- </tr>
- <tr>
- <td>
- <apex:outputtext value="IBM Password"></apex:outputtext>
- </td>
- <td>
- <input type="text"/>
- </td>
- </tr>
- <tr>
- <td >
- <apex:commandButton value="login"/>
- </td>
- </tr>
- </table>
- </apex:form>
- </apex:page>
Inline CSS
- <apex:page sidebar="false" showHeader="false">
- <apex:form >
- <br/><br/>
- <div align="center">
- <apex:outputtext value="Welcome to IBM INDIA" style="font-size:20px;color:green;font-weight:bold;"> </apex:outputtext>
- </div>
- <br/>
- <table border="1" align="center">
- <tr>
- <td colspan="2" align="center">
- <apex:outputtext value="IBM Registration Form" style="font-size:15px;color:blue;"/>
- </td>
- </tr>
- <tr>
- <td>
- <apex:outputtext value="IBM Employee ID"></apex:outputtext>
- </td>
- <td>
- <input type="text"/>
- </td>
- </tr>
- <tr>
- <td>
- <apex:outputtext value="IBM Password"></apex:outputtext>
- </td>
- <td>
- <input type="text"/>
- </td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- <apex:commandButton value="login"/>
- </td>
- </tr>
- </table>
- </apex:form>
- </apex:page>
External CSS
Add testingcss.css to static resources :
- .font1{
- font-size:20px;
- color:green;
- font-weight:bold;
- }
- .font2{
- font-size:15px;
- color:blue;
- }
Page:
- <apex:page sidebar="false" showHeader="false">
- <apex:stylesheet value="{!$Resource.testingcss}"/>
- <apex:form >
- <br/><br/>
- <div align="center">
- <apex:image value="{!$Resource.google}" style="height:60px;width:100px;"/>
- </div>
- <div align="center">
- <apex:outputtext value="Welcome to IBM INDIA" styleclass="font1"> </apex:outputtext>
- </div>
- <br/>
- <table border="1" align="center">
- <tr>
- <td colspan="2" align="center">
- <apex:outputtext value="IBM Registration Form" styleclass="font2"/>
- </td>
- </tr>
- <tr>
- <td>
- <apex:outputtext value="IBM Employee ID"></apex:outputtext>
- </td>
- <td>
- <input type="text"/>
- </td>
- </tr>
- <tr>
- <td>
- <apex:outputtext value="IBM Password"></apex:outputtext>
- </td>
- <td>
- <input type="text"/>
- </td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- <apex:commandButton value="login"/>
- </td>
- </tr>
- </table>
- </apex:form>
- </apex:page>
Internal Java Script
- <apex:page id="p1" showHeader="false">
- <script>
- function sumconfirm(){
- if( confirm("Are you sure to do sum?"))
- {
- sum()
- }
- }
- function sum(){
- var a = document.getElementById('p1:f1:n1').value;
- var b = document.getElementById('n2').value;
- var tot = eval(a) + eval(b);
- alert(tot);
- }
- function multiply(){
- var a = document.getElementById('p1:f1:n1').value;
- var b = document.getElementById('n2').value;
- var mul = eval(a) * eval(b);
- alert(mul);
- }
- </script>
- <apex:form id="f1">
- <table align="center" border="1">
- <tr>
- <td colspan="2" align="center" style="background-color:yellow;">
- <apex:outputtext value="Arithmetic Calculator" style="color:blue;font-size:15px;font-weight:bold;"></apex:outputtext>
- </td>
- </tr>
- <tr>
- <td>
- <apex:outputtext value="Enter First Value"></apex:outputtext>
- </td>
- <td>
- <apex:inputtext id="n1"/>
- </td>
- </tr>
- <tr>
- <td>
- <apex:outputtext value="Enter Second Value"></apex:outputtext>
- </td>
- <td>
- <input type="text" id="n2"/>
- </td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- <input type="button" value="Sum" onclick="sumconfirm();"/>
- <input type="button" value="Multiply" onclick="multiply();"/>
- </td>
- </tr>
- </table>
- </apex:form>
- </apex:page>
External Java Script
Add extjs.txt to static resources :
- function sum(){
- var a = document.getElementById('p1:f1:n1').value;
- var b = document.getElementById('n2').value;
- var tot = eval(a) + eval(b);
- alert(tot);
- }
- function multiply(){
- var a = document.getElementById('p1:f1:n1').value;
- var b = document.getElementById('n2').value;
- var mul = eval(a) * eval(b);
- alert(mul);
- }
Page:
- <apex:page id="p1">
- <apex:includeScript value="{!$Resource.extjs}"/>
- <apex:form id="f1">
- <table align="center" border="1">
- <tr>
- <td colspan="2" align="center" style="background-color:yellow;">
- <apex:outputtext value="Arithmetic Calculator" style="color:blue;font-size:15px;font-weight:bold;"></apex:outputtext>
- </td>
- </tr>
- <tr>
- <td>
- <apex:outputtext value="Enter First Value"></apex:outputtext>
- </td>
- <td>
- <apex:inputtext id="n1"/>
- </td>
- </tr>
- <tr>
- <td>
- <apex:outputtext value="Enter Second Value"></apex:outputtext>
- </td>
- <td>
- <input type="text" id="n2"/>
- </td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- <input type="button" value="Sum" onclick="sum();"/>
- <input type="button" value="Multiply" onclick="multiply();"/>
- </td>
- </tr>
- </table>
- </apex:form>
- </apex:page>
List view of Data
- <apex:page showHeader="false" standardController="Account" recordSetVar="mRec">
- <apex:form >
- <apex:pageBlock id="allAccounts">
- <apex:pageBlockSection >
- <apex:dataList value="{!mRec}" var="c" type="1" rendered="true"> // type is to define the type of list
- {!c.Name}
- </apex:dataList>
- </apex:pageBlockSection>
- <apex:commandButton action="{!First}" value="First"/>
- <apex:commandButton action="{!Next}" value="Next"/>
- <apex:commandButton action="{!Previous}" value="Previous"/>
- <apex:commandButton action="{!Last}" value="Last"/>
- </apex:pageBlock>
- </apex:form>
- </apex:page>
Standard pagination buttons with page block table
<apex:page showHeader="false" standardController="account" recordSetVar="records">
<apex:form >
<apex:pageBlock >
<apex:pageblocktable value="{!records}" var="A">
<apex:column value="{!A.Name}"/>
<apex:column headerValue="Account Phone" value="{!A.Phone}"/>
</apex:pageblocktable>
</apex:pageBlock>
<apex:commandButton action="{!First}" value="First"/>
<apex:commandButton action="{!Next}" value="Next"/>
<apex:commandButton action="{!Previous}" value="Previous"/>
<apex:commandButton action="{!Last}" value="Last"/>
</apex:form>
</apex:page>
Comments
Post a Comment