-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
8Questions
-
5Replies
i'm trying to know the list is empty for that i used 1)list.size()>0 2) list.isempty(); 3)list!=null even though its not taking empty values are taking how to solve this can any one help in that
when i insert contact child record of account it will take that one only but its asking remaining child records i mean opportunity,case records also how to solve this problem.
vf page:
<apex:page controller="Account_insert_con">
<apex:form >
<apex:pageBlock id="pb" title="Account list" >
<apex:pageBlockButtons location="top">
<apex:commandButton value="save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlocksection title="account data" id="pbs">
<apex:inputField value="{!wraps.acc.name}"/>
<apex:inputfield value="{!wraps.acc.type}"/>
<apex:inputfield value="{!wraps.acc.phone}"/>
<apex:inputField value="{!wraps.acc.industry}"/>
</apex:pageBlocksection>
<apex:pageBlockSection columns="1" title="contact list" >
<apex:pageBlockTable value="{!contacts}" var="c" id="pbt">
<apex:column headerValue="firstname">
<apex:inputtext value="{!c.firstname}"/>
</apex:column>
<apex:column headerValue="lastname">
<apex:inputText value="{!c.lastname}"/>
</apex:column>
<apex:column headerValue="phone">
<apex:inputText value="{!c.phone}"/>
</apex:column>
<apex:column headerValue="Leadsource">
<apex:inputText value="{!c.leadsource}"/>
</apex:column>
<apex:column headerValue="AddRow" >
<apex:commandButton value="add" action="{!multichild}" id="pbs"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageblocksection columns="1">
<apex:pageblocktable value="{!opp}" var="o">
<apex:column headerValue="name">
<apex:inputText value="{!o.name}"/>
</apex:column>
<apex:column headerValue="stagename">
<apex:inputText value="{!o.stagename}"/>
</apex:column>
<apex:column headerValue="ClosedDate">
<apex:inputText value="{!o.CloseDate}"/>
</apex:column>
<apex:column headerValue="AddRow">
<apex:commandbutton value="add" action="{!optyadd}" id="pbs"/>
</apex:column>
</apex:pageblocktable>
</apex:pageblocksection>
<apex:pageblocksection columns="1">
<apex:pageBlockTable value="{!cases}" var="c">
<apex:column headerValue="Origin">
<apex:inputText value="{!c.origin}"/>
</apex:column>
<apex:column headerValue="status">
<apex:inputText value="{!c.status}"/>
</apex:column>
<apex:column headerValue="AddRow">
<apex:commandButton value="caseadd" action="{!caseadd}" id="pbs"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageblocksection>
</apex:pageBlock>
</apex:form>
</apex:page>
apex code:
public class Account_insert_con {
public Account_insert_wrapper wraps{set;get;}
public List<contact> contacts{set;get;}
public List<opportunity> opp{set;get;}
public List<case> cases{set;get;}
public Account_insert_con(){
wraps=new Account_insert_wrapper();
wraps.acc=new Account();
wraps.con=new contact();
opp=new List<opportunity>();
cases=new list<case>();
wraps.opps=new opportunity();
contacts=new List<contact>();
contacts.add(wraps.con);
opp.add(wraps.opps);
wraps.cs=new case();
cases.add(wraps.cs);
multichild();
optyadd();
caseadd();
}
public void multichild(){
wraps.con=new contact();
contacts.add(wraps.con);
}
public void optyadd(){
wraps.opps=new opportunity();
opp.add(wraps.opps);
}
public void caseadd(){
wraps.cs=new case();
cases.add(wraps.cs);
}
public PageReference save (){
insert wraps.acc;
System.debug('====>'+contacts);
System.debug('====>'+opp);
System.debug('====>'+cases);
List<contact> cons=new List<contact>();
if(contacts.size() != 0){
System.debug('in contacts');
for(contact c:contacts){
c.Accountid=wraps.acc.id;
cons.add(c);
}
insert cons;
}
List<opportunity> opportunities=new List<opportunity>();
if(opp != null && opp.size() > 0)
{
System.debug('in opportunities');
for(opportunity o:opp){
o.AccountId=wraps.acc.id;
opportunities.add(o);
}
insert opportunities;
}
List<case> cc =new List<case>();
if(cases != null && cases.size() > 0) {
System.debug('in cases');
for(case co: cases){
co.AccountId=wraps.acc.id;
cc.add(co);
}
insert cc;
}
PageReference p=new PageReference('/'+wraps.acc.id);
return p;
}
}
wrapper class:--
public class Account_insert_wrapper {
public Account acc{set;get;}
public contact con{set;get;}
public opportunity opps{set;get;}
public case cs{set;get;}
}
vf page:
<apex:page controller="Account_insert_con">
<apex:form >
<apex:pageBlock id="pb" title="Account list" >
<apex:pageBlockButtons location="top">
<apex:commandButton value="save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlocksection title="account data" id="pbs">
<apex:inputField value="{!wraps.acc.name}"/>
<apex:inputfield value="{!wraps.acc.type}"/>
<apex:inputfield value="{!wraps.acc.phone}"/>
<apex:inputField value="{!wraps.acc.industry}"/>
</apex:pageBlocksection>
<apex:pageBlockSection columns="1" title="contact list" >
<apex:pageBlockTable value="{!contacts}" var="c" id="pbt">
<apex:column headerValue="firstname">
<apex:inputtext value="{!c.firstname}"/>
</apex:column>
<apex:column headerValue="lastname">
<apex:inputText value="{!c.lastname}"/>
</apex:column>
<apex:column headerValue="phone">
<apex:inputText value="{!c.phone}"/>
</apex:column>
<apex:column headerValue="Leadsource">
<apex:inputText value="{!c.leadsource}"/>
</apex:column>
<apex:column headerValue="AddRow" >
<apex:commandButton value="add" action="{!multichild}" id="pbs"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageblocksection columns="1">
<apex:pageblocktable value="{!opp}" var="o">
<apex:column headerValue="name">
<apex:inputText value="{!o.name}"/>
</apex:column>
<apex:column headerValue="stagename">
<apex:inputText value="{!o.stagename}"/>
</apex:column>
<apex:column headerValue="ClosedDate">
<apex:inputText value="{!o.CloseDate}"/>
</apex:column>
<apex:column headerValue="AddRow">
<apex:commandbutton value="add" action="{!optyadd}" id="pbs"/>
</apex:column>
</apex:pageblocktable>
</apex:pageblocksection>
<apex:pageblocksection columns="1">
<apex:pageBlockTable value="{!cases}" var="c">
<apex:column headerValue="Origin">
<apex:inputText value="{!c.origin}"/>
</apex:column>
<apex:column headerValue="status">
<apex:inputText value="{!c.status}"/>
</apex:column>
<apex:column headerValue="AddRow">
<apex:commandButton value="caseadd" action="{!caseadd}" id="pbs"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageblocksection>
</apex:pageBlock>
</apex:form>
</apex:page>
apex code:
public class Account_insert_con {
public Account_insert_wrapper wraps{set;get;}
public List<contact> contacts{set;get;}
public List<opportunity> opp{set;get;}
public List<case> cases{set;get;}
public Account_insert_con(){
wraps=new Account_insert_wrapper();
wraps.acc=new Account();
wraps.con=new contact();
opp=new List<opportunity>();
cases=new list<case>();
wraps.opps=new opportunity();
contacts=new List<contact>();
contacts.add(wraps.con);
opp.add(wraps.opps);
wraps.cs=new case();
cases.add(wraps.cs);
multichild();
optyadd();
caseadd();
}
public void multichild(){
wraps.con=new contact();
contacts.add(wraps.con);
}
public void optyadd(){
wraps.opps=new opportunity();
opp.add(wraps.opps);
}
public void caseadd(){
wraps.cs=new case();
cases.add(wraps.cs);
}
public PageReference save (){
insert wraps.acc;
System.debug('====>'+contacts);
System.debug('====>'+opp);
System.debug('====>'+cases);
List<contact> cons=new List<contact>();
if(contacts.size() != 0){
System.debug('in contacts');
for(contact c:contacts){
c.Accountid=wraps.acc.id;
cons.add(c);
}
insert cons;
}
List<opportunity> opportunities=new List<opportunity>();
if(opp != null && opp.size() > 0)
{
System.debug('in opportunities');
for(opportunity o:opp){
o.AccountId=wraps.acc.id;
opportunities.add(o);
}
insert opportunities;
}
List<case> cc =new List<case>();
if(cases != null && cases.size() > 0) {
System.debug('in cases');
for(case co: cases){
co.AccountId=wraps.acc.id;
cc.add(co);
}
insert cc;
}
PageReference p=new PageReference('/'+wraps.acc.id);
return p;
}
}
wrapper class:--
public class Account_insert_wrapper {
public Account acc{set;get;}
public contact con{set;get;}
public opportunity opps{set;get;}
public case cs{set;get;}
}
-
- Anji P 9
- December 03, 2017
- Like
- 0
- Continue reading or reply
I'm trying to create task and attachment for Account object but here problem is when i'm trying to add second attachment for that its overriding i mean its taking first body value what i gave in first attachment can any one help me how to solve it
Vf page:
--------------------------
<apex:page controller="Account_Tasks">
<apex:form>
<apex:pageBlock id="pb">
<apex:pageBlockButtons location="top">
<apex:commandButton value="Save" action="{!save}" rerender="pb"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Account Details">
<apex:inputField value="{!acc.Name}"/>
<apex:inputField value="{!acc.Industry}"/>
<apex:inputField value="{!acc.Phone}"/>
<apex:inputField value="{!acc.ownership}"/>
<apex:inputField value="{!acc.rating}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Task Details" columns="1" id="pbs">
<apex:pageBlockTable value="{!tsks}" var="t">
<apex:column headerValue="Priority">
<apex:inputField value="{!t.Priority}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:inputField value="{!t.status}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:inputField value="{!t.Tasksubtype}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:inputField value="{!t.calltype}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:inputField value="{!t.createdDate}"/>
</apex:column>
<apex:column >
<apex:commandButton value="ADD" action="{!AddTask}" rerender="pbs"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection columns="1" id="pbs1">
<apex:pageBlockTable value="{!attch}" var="att">
<apex:column headerValue="File Name">
<apex:inputField value="{!att.name}"/>
</apex:column>
<apex:column headerValue="Body">
<apex:inputtext value="{!str}"/>
</apex:column>
<apex:column>
<apex:commandButton value="Add Attachment" action="{!AddAttachmnt}" rerender="pbs1"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex code:
----------------------------
public class Account_Tasks {
public account acc{set;get;}
public task tsk{set;get;}
public string str{set;get;}
public list<attachment> attch{set;get;}
public list<task>tsks{set;get;}
public Account_Tasks(){
attch=new List<attachment>();
tsks=new list<task>();
acc=new account();
tsk=new Task();
AddTask();
AddAttachmnt();
}
public void AddTask(){
tsk=new task();
tsks.add(tsk);
}
public void AddAttachmnt(){
str=null;
attachment a=new attachment();
attch.add(a);
}
public PageReference save(){
insert acc;
list<task> tasks=new list<task>();
for(task t:tsks){
t.whatid=acc.id;
tasks.add(t);
}
insert tasks;
list<attachment> attaches=new list<attachment>();
for(attachment at:attch){
at.ParentId=acc.Id;
at.Name=acc.Name+'.pdf';
at.Body=blob.toPdf(str);
attaches.add(at);
}
insert attaches;
Pagereference p=new Pagereference('/'+acc.id);
return p;
}
}
--------------------------
<apex:page controller="Account_Tasks">
<apex:form>
<apex:pageBlock id="pb">
<apex:pageBlockButtons location="top">
<apex:commandButton value="Save" action="{!save}" rerender="pb"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Account Details">
<apex:inputField value="{!acc.Name}"/>
<apex:inputField value="{!acc.Industry}"/>
<apex:inputField value="{!acc.Phone}"/>
<apex:inputField value="{!acc.ownership}"/>
<apex:inputField value="{!acc.rating}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Task Details" columns="1" id="pbs">
<apex:pageBlockTable value="{!tsks}" var="t">
<apex:column headerValue="Priority">
<apex:inputField value="{!t.Priority}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:inputField value="{!t.status}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:inputField value="{!t.Tasksubtype}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:inputField value="{!t.calltype}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:inputField value="{!t.createdDate}"/>
</apex:column>
<apex:column >
<apex:commandButton value="ADD" action="{!AddTask}" rerender="pbs"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection columns="1" id="pbs1">
<apex:pageBlockTable value="{!attch}" var="att">
<apex:column headerValue="File Name">
<apex:inputField value="{!att.name}"/>
</apex:column>
<apex:column headerValue="Body">
<apex:inputtext value="{!str}"/>
</apex:column>
<apex:column>
<apex:commandButton value="Add Attachment" action="{!AddAttachmnt}" rerender="pbs1"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex code:
----------------------------
public class Account_Tasks {
public account acc{set;get;}
public task tsk{set;get;}
public string str{set;get;}
public list<attachment> attch{set;get;}
public list<task>tsks{set;get;}
public Account_Tasks(){
attch=new List<attachment>();
tsks=new list<task>();
acc=new account();
tsk=new Task();
AddTask();
AddAttachmnt();
}
public void AddTask(){
tsk=new task();
tsks.add(tsk);
}
public void AddAttachmnt(){
str=null;
attachment a=new attachment();
attch.add(a);
}
public PageReference save(){
insert acc;
list<task> tasks=new list<task>();
for(task t:tsks){
t.whatid=acc.id;
tasks.add(t);
}
insert tasks;
list<attachment> attaches=new list<attachment>();
for(attachment at:attch){
at.ParentId=acc.Id;
at.Name=acc.Name+'.pdf';
at.Body=blob.toPdf(str);
attaches.add(at);
}
insert attaches;
Pagereference p=new Pagereference('/'+acc.id);
return p;
}
}
-
- Anji P 9
- December 01, 2017
- Like
- 0
- Continue reading or reply
-
- Anji P 9
- November 29, 2017
- Like
- 0
- Continue reading or reply
{!controller.pagenumber} of {!controller.resultsize} i'm getting o/p like 1 of 47 but i want 1-10 of 47
apex code:--
public class Pagination_Example {
public Apexpages.StandardSetController controller {set;get;}
public List<Opportunity> getOptyList(){
List<Opportunity> opty=(List<Opportunity>)controller.getRecords();
return opty;
}
public Pagination_Example (){
List<opportunity> opps=[select id,name,stagename,amount from opportunity];
controller=new apexpages.standardsetcontroller(opps);
controller.setpagesize(10);
}
}
vf page:--
<apex:page controller="Pagination_Example">
<apex:form >
<apex:pageblock id="pb">
<apex:pageblockbuttons location="top">
<apex:commandButton value="Previous" action="{!controller.previous}" rendered="{!controller.hasprevious}"/>
<apex:commandButton value="First" action="{!controller.first}" rendered="{!controller.hasprevious}"/>
<apex:commandButton value="Next" action="{!controller.Next}" rendered="{!controller.hasnext}"/>
<apex:commandButton value="Last" action="{!controller.last}" rendered="{!controller.hasnext}"/>
</apex:pageblockbuttons>
<apex:pageBlockTable value="{!optylist}" var="a">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.stagename}"/>
<apex:column value="{!a.amount}"/>
</apex:pageBlockTable>
<apex:facet name="footer"> <h1>
{!controller.pagenumber} of {!controller.resultsize}
</h1>
</apex:facet>
</apex:pageblock>
</apex:form>
</apex:page>
public class Pagination_Example {
public Apexpages.StandardSetController controller {set;get;}
public List<Opportunity> getOptyList(){
List<Opportunity> opty=(List<Opportunity>)controller.getRecords();
return opty;
}
public Pagination_Example (){
List<opportunity> opps=[select id,name,stagename,amount from opportunity];
controller=new apexpages.standardsetcontroller(opps);
controller.setpagesize(10);
}
}
vf page:--
<apex:page controller="Pagination_Example">
<apex:form >
<apex:pageblock id="pb">
<apex:pageblockbuttons location="top">
<apex:commandButton value="Previous" action="{!controller.previous}" rendered="{!controller.hasprevious}"/>
<apex:commandButton value="First" action="{!controller.first}" rendered="{!controller.hasprevious}"/>
<apex:commandButton value="Next" action="{!controller.Next}" rendered="{!controller.hasnext}"/>
<apex:commandButton value="Last" action="{!controller.last}" rendered="{!controller.hasnext}"/>
</apex:pageblockbuttons>
<apex:pageBlockTable value="{!optylist}" var="a">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.stagename}"/>
<apex:column value="{!a.amount}"/>
</apex:pageBlockTable>
<apex:facet name="footer"> <h1>
{!controller.pagenumber} of {!controller.resultsize}
</h1>
</apex:facet>
</apex:pageblock>
</apex:form>
</apex:page>
-
- Anji P 9
- November 19, 2017
- Like
- 0
- Continue reading or reply
- Anji P 9
- November 29, 2017
- Like
- 0
- Continue reading or reply
{!controller.pagenumber} of {!controller.resultsize} i'm getting o/p like 1 of 47 but i want 1-10 of 47
apex code:--
public class Pagination_Example {
public Apexpages.StandardSetController controller {set;get;}
public List<Opportunity> getOptyList(){
List<Opportunity> opty=(List<Opportunity>)controller.getRecords();
return opty;
}
public Pagination_Example (){
List<opportunity> opps=[select id,name,stagename,amount from opportunity];
controller=new apexpages.standardsetcontroller(opps);
controller.setpagesize(10);
}
}
vf page:--
<apex:page controller="Pagination_Example">
<apex:form >
<apex:pageblock id="pb">
<apex:pageblockbuttons location="top">
<apex:commandButton value="Previous" action="{!controller.previous}" rendered="{!controller.hasprevious}"/>
<apex:commandButton value="First" action="{!controller.first}" rendered="{!controller.hasprevious}"/>
<apex:commandButton value="Next" action="{!controller.Next}" rendered="{!controller.hasnext}"/>
<apex:commandButton value="Last" action="{!controller.last}" rendered="{!controller.hasnext}"/>
</apex:pageblockbuttons>
<apex:pageBlockTable value="{!optylist}" var="a">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.stagename}"/>
<apex:column value="{!a.amount}"/>
</apex:pageBlockTable>
<apex:facet name="footer"> <h1>
{!controller.pagenumber} of {!controller.resultsize}
</h1>
</apex:facet>
</apex:pageblock>
</apex:form>
</apex:page>
public class Pagination_Example {
public Apexpages.StandardSetController controller {set;get;}
public List<Opportunity> getOptyList(){
List<Opportunity> opty=(List<Opportunity>)controller.getRecords();
return opty;
}
public Pagination_Example (){
List<opportunity> opps=[select id,name,stagename,amount from opportunity];
controller=new apexpages.standardsetcontroller(opps);
controller.setpagesize(10);
}
}
vf page:--
<apex:page controller="Pagination_Example">
<apex:form >
<apex:pageblock id="pb">
<apex:pageblockbuttons location="top">
<apex:commandButton value="Previous" action="{!controller.previous}" rendered="{!controller.hasprevious}"/>
<apex:commandButton value="First" action="{!controller.first}" rendered="{!controller.hasprevious}"/>
<apex:commandButton value="Next" action="{!controller.Next}" rendered="{!controller.hasnext}"/>
<apex:commandButton value="Last" action="{!controller.last}" rendered="{!controller.hasnext}"/>
</apex:pageblockbuttons>
<apex:pageBlockTable value="{!optylist}" var="a">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.stagename}"/>
<apex:column value="{!a.amount}"/>
</apex:pageBlockTable>
<apex:facet name="footer"> <h1>
{!controller.pagenumber} of {!controller.resultsize}
</h1>
</apex:facet>
</apex:pageblock>
</apex:form>
</apex:page>
- Anji P 9
- November 19, 2017
- Like
- 0
- Continue reading or reply