CREATE BOOK CUSTOM OBEJECT
fields are.........
BookName
Price
Title
Write Apex Class
public class BookInsert
{
List<Book__c> l;
selectOption Opn;
public SelectOption getOpn() {
return new SelectOption('abc','abc');
}
public void setOpn(SelectOption opn)
{
this.Opn=opn;
}
public List<Book__c> getL()
{
return l;
}
public Double price
{
get { return price; }
set { price= value; }
}
public String title
{
get { return title; }
set { title= value; }
}
public String head
{
get { return head; }
set { head= value; }
}
public String str
{
get { return str; }
set { str= value; }
}
public PageReference doSearchBook() {
l=[select Price__c,title__c from Book__c where title__c LIKE :str+'%'];
head='search';
return null;
}
public PageReference doInsert() {
Book__c b=new Book__c(price__c=price,title__c=''+title);
insert b;
return null;
}
public PageReference doGetBook() {
l=[select Price__c,title__c from Book__c];
head='GetBook';
return null;
}
public List<SelectOption> getBks()
{
List<SelectOption> options = new List<SelectOption>(); //new list for holding all of the picklist options
// options.add(new selectOption('1', '- None -')); //add the first option of '- None -' in case the user doesn't want to select a value or in case no values are returned from query below
options.add(new SelectOption('1', '-select-'));
for (Book__c bk : [SELECT Price__c,title__c FROM Book__c])
{ //query for User records with System Admin profile
if(bk!=null&&bk.title__c!=null)
options.add(new SelectOption(''+bk.Id, ''+bk.title__c)); //for all records found - add them to the picklist options
}
return options;
}//return the picklist options
}
Create Visual force page
<apex:page controller="BookInsert">
<apex:form >
<apex:message rendered="true" />
<apex:pageBlock mode="edit" id="block">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="searchText">Book Insert</apex:outputLabel>
<apex:panelGroup >
<apex:inputText id="price" value="{!price}"/>
<apex:inputText id="title" value="{!title}"/>
<apex:commandButton value="Insert!" action="{!doInsert}" rerender="block" status="status"/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="searchText1">Click Here To Get All Books</apex:outputLabel>
<apex:panelGroup >
<apex:commandButton value="Get!" action="{!doGetBook}" rerender="block" status="status"/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="searchText2">Click Here To search All Books</apex:outputLabel>
<apex:panelGroup >
<apex:inputText id="search" value="{!str}"/>
<apex:commandButton value="Search" action="{!doSearchBook}" rerender="block" status="status"/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:actionStatus id="status" startText="requesting..."/>
<apex:pageBlockSection title="{!head}" id="results" columns="1">
<apex:pageBlockTable value="{!l}" var="i" rendered="{!NOT(ISNULL(l))}">
<apex:column value="{!i.price__c}"/>
<apex:column value="{!i.title__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
U GET LIKE
fields are.........
BookName
Price
Title
BOOK CUSTOM OBJECT |
Write Apex Class
public class BookInsert
{
List<Book__c> l;
selectOption Opn;
public SelectOption getOpn() {
return new SelectOption('abc','abc');
}
public void setOpn(SelectOption opn)
{
this.Opn=opn;
}
public List<Book__c> getL()
{
return l;
}
public Double price
{
get { return price; }
set { price= value; }
}
public String title
{
get { return title; }
set { title= value; }
}
public String head
{
get { return head; }
set { head= value; }
}
public String str
{
get { return str; }
set { str= value; }
}
public PageReference doSearchBook() {
l=[select Price__c,title__c from Book__c where title__c LIKE :str+'%'];
head='search';
return null;
}
public PageReference doInsert() {
Book__c b=new Book__c(price__c=price,title__c=''+title);
insert b;
return null;
}
public PageReference doGetBook() {
l=[select Price__c,title__c from Book__c];
head='GetBook';
return null;
}
public List<SelectOption> getBks()
{
List<SelectOption> options = new List<SelectOption>(); //new list for holding all of the picklist options
// options.add(new selectOption('1', '- None -')); //add the first option of '- None -' in case the user doesn't want to select a value or in case no values are returned from query below
options.add(new SelectOption('1', '-select-'));
for (Book__c bk : [SELECT Price__c,title__c FROM Book__c])
{ //query for User records with System Admin profile
if(bk!=null&&bk.title__c!=null)
options.add(new SelectOption(''+bk.Id, ''+bk.title__c)); //for all records found - add them to the picklist options
}
return options;
}//return the picklist options
}
Create Visual force page
<apex:page controller="BookInsert">
<apex:form >
<apex:message rendered="true" />
<apex:pageBlock mode="edit" id="block">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="searchText">Book Insert</apex:outputLabel>
<apex:panelGroup >
<apex:inputText id="price" value="{!price}"/>
<apex:inputText id="title" value="{!title}"/>
<apex:commandButton value="Insert!" action="{!doInsert}" rerender="block" status="status"/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="searchText1">Click Here To Get All Books</apex:outputLabel>
<apex:panelGroup >
<apex:commandButton value="Get!" action="{!doGetBook}" rerender="block" status="status"/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="searchText2">Click Here To search All Books</apex:outputLabel>
<apex:panelGroup >
<apex:inputText id="search" value="{!str}"/>
<apex:commandButton value="Search" action="{!doSearchBook}" rerender="block" status="status"/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:actionStatus id="status" startText="requesting..."/>
<apex:pageBlockSection title="{!head}" id="results" columns="1">
<apex:pageBlockTable value="{!l}" var="i" rendered="{!NOT(ISNULL(l))}">
<apex:column value="{!i.price__c}"/>
<apex:column value="{!i.title__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
U GET LIKE
No comments:
Post a Comment