• Franco
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 6
    Replies
I'm trying to create a page where a list of all accounts are presented to the user so he/she can select accounts to be displayed on the bottom part of the page.  I'm trying to display inputcheckboxes next to each account to to capture the user's request.   For some reason, I can't get the initial list of accounts to display.

My code is below -

Code:
<apex:page Controller="AccountSelectController">
  <apex:form >  
   <apex:pageBlock title="Available Accounts">
      <apex:pageBlockTable title="Accounts" id="PickAccts" value="{!MyAcct}" var="aAcct" >
        <apex:column>
          <apex:inputCheckBox value="{!aAcct.selected}" Id="selectLine"/>
        </apex:column>
        <apex:column headerValue="Account Id" value="{!aAcct.theacct.Id}" />
        <apex:column headerValue="Account Name" value="{!aAcct.theacct.Name}" />
      </apex:PageblockTable>
    <apex:commandButton action="{!gensAcct}" value="Select" rerender="MyPanel" status="status"/> <br />
    <apex:pageMessages ></apex:pageMessages>
  </apex:pageBlock>

<apex:actionStatus startText="Updating..." id="status"/>

<apex:outputpanel title="Results" id="MyPanel">
  <apex:outputpanel title="Wrapper" id="Wrapper" rendered="{!NOT(ISNULL(SAcct))}">
    <apex:pageBlock >
      <apex:pageBlockTable title="Accounts" id="PickAccts" value="{!SAcct}" var="aAcct" >
        <apex:column headerValue="Account Id" value="{!aAcct.theacct.Id}" />
        <apex:column headerValue="Account Name" value="{!aAcct.theacct.Name}" />
      </apex:PageblockTable>
    </apex:Pageblock>
  </apex:outputpanel>
</apex:outputpanel>

  </apex:form>
</apex:page>

Controller -
Code:
public class AccountSelectController {

    public PageReference genSAcct() {
        SAcct = getSAcct();
        return null;
    }
    
    public class cAcct{
        public Account theacct {get; set;}
        public Boolean selected{get; set;}
       
        public cAcct(Account a,Boolean s){
            theacct = a;
            selected = s;
        }
    }
    
    //A collection of the class/wrapper objects cAcct
    
    //The fist list includes all Accounts
    public List<cAcct> MyAcct {get; set;}
    
    //The second list only inclues Accouts selected
    public List<cAcct> SAcct {get; set;}

   //This method uses a SOQL query to return a list of all Accounts
    public List<cAcct> getMyAcct(){
          if(MyAcct == null){
              MyAcct = new List<cAcct>();
              for(Account acct : [Select Name FROM Account Limit 10  ]){
                    /* As each opportunity is processed I create a new cOpportunity object and add it to MyList */
                    cAcct myadd = new cAcct(acct,FALSE);
                    MyAcct.add(myadd);
              }
          }
        return MyAcct;
    }
    
    //This method uses looks at the full account list and adds only those with "selected" = true
    public List<cAcct> getSAcct(){
      if (MyAcct != null) {  
          if (SAcct == null) {
              SAcct = new List<cAcct>();
              for(cAcct cacct : MyAcct){
                  /* As each Accout is processed, check if the selected value is true. */
                  if (cacct.selected == TRUE) {
                      SAcct.add(cacct);
                  }
              }
          }
          return SAcct;
      } else {
          SAcct = null;
          return SAcct;
      }
    }
}

 

 

  • January 19, 2009
  • Like
  • 0
1) Is there a way to improve the format of the number in this output?  See the example below.  This is just a test case to show the formatting.  I could be wrong but, I believe my output choices are limited since I'm using a wrapper object.
 
2) I'm having problems with the rendered attribute.  But, maybe this is the expected behavior. It seems to work when I use it in a datatable but, it does not seem to work in a pageblock. 
 
The page:
Code:
<apex:page controller="FormatController"> 
<apex:form >
  <apex:pageBlock title="Do It">
      <apex:commandButton action="{!DoIt}" value="Go" rerender="Opps" status="status"/> <br />
      <apex:pageMessages ></apex:pageMessages>
  </apex:pageBlock>
  <apex:pageBlock title="Opps" id="Opps" rendered="{!NOT(ISNULL(Opportunities))}">
  <apex:dataTable value="{!Opportunities}" var="Opp" width="100%" >     
     <apex:column >
      <apex:facet name="header">Account</apex:facet>
      {!Opp.Account.Name}
     </apex:column>
      <apex:column >
      <apex:facet name="header">Name</apex:facet>
      {!Opp.Name}
     </apex:column>
     <apex:column >
      <apex:facet name="header">Amount</apex:facet>
      {!Opp.Amount}
     </apex:column>
   </apex:dataTable> 
   </apex:Pageblock>
</apex:form>

</apex:page>

 The controller:
Code:
public class FormatController {

    private List<Opportunity> Opportunities {get; set;}
    public List<Opportunity> getOpportunities (){
        return Opportunities;
    }

    public PageReference DoIt (){
          if(Opportunities == null){
              Opportunities = [Select Name, Amount, Account.Name FROM Opportunity Limit 10  ];
          }
        return null;
    }
}

 

  • January 16, 2009
  • Like
  • 0
Maybe this isn't a "renderAs question" but, it seems like a possible solution.  Does anyone have any other suggestions?
 
 
From what I understand, the only option for renderAs is currently PDF.  As in:
 
<apex:page standardController="Account" renderAs="pdf">
 
What if I wanted to render the page as XML?  Does anyone have advice on how I could use visualforce to render an XML page? (My hope is to render the page so that it can be read as a feed, rss.)
 
As in:
 
<apex:page standardController="Account" renderAs="xml">
 
Franco
I have written a trigger that uses Messaging.sendEmail.  Before trying to deploy the trigger, I'm writing the testmethod.  I don't see any examples of how I can test this capability.  Does anyone have any suggestions?
 
Franco
  • January 17, 2008
  • Like
  • 0
Does anyone have an example of how they query related list items in a trigger?  I've got a custom object that is similar to an opportunity and opportunity line item.  Assume we need a trigger whenever a new opportunity is created.  When the trigger runs, I want to send an email that a new opportunity was created and include all the line items that were created with the opportunity.  (you don't need to show me how to use the email api, I think I understand that.)
 
a) Would you trigger on "new" opportunity? (can we be sure that all the line items are all created when the trigger on the opportunity runs) parent/child relationship
b) Do you use SOQL to query the line items?  What would that query look like? 
c) How would I loop through the line items in the trigger?
 
Thanks in advance for any help you can provide!
 
Franco
  • January 13, 2008
  • Like
  • 0
I'm new to Apex - so sorry for asking a simple question.  I see where I can add a trigger to regular objects.  Where do you add a trigger to a custom object?  (I'm talking about using the UI directly rather than going through eclipse.)
 
Thanks.

Franco
  • January 13, 2008
  • Like
  • 0

This is a really cool module! There's a tiny bug in version 0.10, however: The module doesn't check to see if $limit exists before trying the pattern match.

Use of uninitialized value in pattern match (m//) at /usr/lib/perl5/site_perl/5.8.8/WWW/Salesforce/Simple.pm line 35.

 

Here's a patch:

diff -c WWW/Salesforce/Simple.pm.orig WWW/Salesforce/Simple.pm *** WWW/Salesforce/Simple.pm.orig 2009-09-09 13:31:58.000000000 -0700 --- WWW/Salesforce/Simple.pm 2009-09-09 13:30:06.000000000 -0700 *************** *** 33,39 **** } $limit = 2000 ! unless $limit =~ m/^\d+$/ and $limit > 0 and $limit < 2001; my @rows = (); #to be returned --- 33,39 ---- } $limit = 2000 ! unless defined $limit && $limit =~ m/^\d+$/ and $limit > 0 and $limit < 2001; my @rows = (); #to be returned

 

  • September 09, 2009
  • Like
  • 0
I'm trying to create a page where a list of all accounts are presented to the user so he/she can select accounts to be displayed on the bottom part of the page.  I'm trying to display inputcheckboxes next to each account to to capture the user's request.   For some reason, I can't get the initial list of accounts to display.

My code is below -

Code:
<apex:page Controller="AccountSelectController">
  <apex:form >  
   <apex:pageBlock title="Available Accounts">
      <apex:pageBlockTable title="Accounts" id="PickAccts" value="{!MyAcct}" var="aAcct" >
        <apex:column>
          <apex:inputCheckBox value="{!aAcct.selected}" Id="selectLine"/>
        </apex:column>
        <apex:column headerValue="Account Id" value="{!aAcct.theacct.Id}" />
        <apex:column headerValue="Account Name" value="{!aAcct.theacct.Name}" />
      </apex:PageblockTable>
    <apex:commandButton action="{!gensAcct}" value="Select" rerender="MyPanel" status="status"/> <br />
    <apex:pageMessages ></apex:pageMessages>
  </apex:pageBlock>

<apex:actionStatus startText="Updating..." id="status"/>

<apex:outputpanel title="Results" id="MyPanel">
  <apex:outputpanel title="Wrapper" id="Wrapper" rendered="{!NOT(ISNULL(SAcct))}">
    <apex:pageBlock >
      <apex:pageBlockTable title="Accounts" id="PickAccts" value="{!SAcct}" var="aAcct" >
        <apex:column headerValue="Account Id" value="{!aAcct.theacct.Id}" />
        <apex:column headerValue="Account Name" value="{!aAcct.theacct.Name}" />
      </apex:PageblockTable>
    </apex:Pageblock>
  </apex:outputpanel>
</apex:outputpanel>

  </apex:form>
</apex:page>

Controller -
Code:
public class AccountSelectController {

    public PageReference genSAcct() {
        SAcct = getSAcct();
        return null;
    }
    
    public class cAcct{
        public Account theacct {get; set;}
        public Boolean selected{get; set;}
       
        public cAcct(Account a,Boolean s){
            theacct = a;
            selected = s;
        }
    }
    
    //A collection of the class/wrapper objects cAcct
    
    //The fist list includes all Accounts
    public List<cAcct> MyAcct {get; set;}
    
    //The second list only inclues Accouts selected
    public List<cAcct> SAcct {get; set;}

   //This method uses a SOQL query to return a list of all Accounts
    public List<cAcct> getMyAcct(){
          if(MyAcct == null){
              MyAcct = new List<cAcct>();
              for(Account acct : [Select Name FROM Account Limit 10  ]){
                    /* As each opportunity is processed I create a new cOpportunity object and add it to MyList */
                    cAcct myadd = new cAcct(acct,FALSE);
                    MyAcct.add(myadd);
              }
          }
        return MyAcct;
    }
    
    //This method uses looks at the full account list and adds only those with "selected" = true
    public List<cAcct> getSAcct(){
      if (MyAcct != null) {  
          if (SAcct == null) {
              SAcct = new List<cAcct>();
              for(cAcct cacct : MyAcct){
                  /* As each Accout is processed, check if the selected value is true. */
                  if (cacct.selected == TRUE) {
                      SAcct.add(cacct);
                  }
              }
          }
          return SAcct;
      } else {
          SAcct = null;
          return SAcct;
      }
    }
}

 

 

  • January 19, 2009
  • Like
  • 0
Hi there.
I am utilizing the pageBlockSection component and would like to render
it if a selectList (dynamically populated) is not empty.
Alas, it will not work.
Below is the section of my VF page that shows the pageBlockSection with the rendered attribute. I have double checked
and the variable isProductCategoryNotNone changes accordingly, but the pageBlockSection always remains invisble....
Any ideas? I use this variable earlier in my code to show another list and it works fine but wont work for the pageBlockSection.
Thanks
 

Code:
<!-- Define the Products List now... -->
<apex:pageBlockSectionItem >
<apex:outputPanel id="productLabelPanel">
<apex:outputLabel value="Products" for="productsList" rendered="{!isProductCategoryNotNone}" />
</apex:outputPanel>
<apex:outputPanel id="productListPanel">
<apex:selectList value="{!selectedProduct}" multiSelect="false" size="1" rendered="{!isProductCategoryNotNone}" id="productsList">
<!-- Add the products to the page for the selected Category -->
<apex:selectOptions value="{!allProducts}" />
<!-- Add an actionSupport to query for all Constituents for the selected product -->
<apex:actionSupport event="onchange" action="{!queryForSKUs}" status="queryStatus" rerender="SKUTable" />
</apex:selectList>
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>


<apex:pageBlockSection title="Available SKU's" columns="1" rendered="{!isProductCategoryNotNone}">
<apex:pageBlockTable columns="5" id="SKUTable" var="skuRecord" value="{!skuRecordsList}">
<apex:column>



  • January 19, 2009
  • Like
  • 0
Does anyone have an example of how they query related list items in a trigger?  I've got a custom object that is similar to an opportunity and opportunity line item.  Assume we need a trigger whenever a new opportunity is created.  When the trigger runs, I want to send an email that a new opportunity was created and include all the line items that were created with the opportunity.  (you don't need to show me how to use the email api, I think I understand that.)
 
a) Would you trigger on "new" opportunity? (can we be sure that all the line items are all created when the trigger on the opportunity runs) parent/child relationship
b) Do you use SOQL to query the line items?  What would that query look like? 
c) How would I loop through the line items in the trigger?
 
Thanks in advance for any help you can provide!
 
Franco
  • January 13, 2008
  • Like
  • 0
I'm new to Apex - so sorry for asking a simple question.  I see where I can add a trigger to regular objects.  Where do you add a trigger to a custom object?  (I'm talking about using the UI directly rather than going through eclipse.)
 
Thanks.

Franco
  • January 13, 2008
  • Like
  • 0
QueryAmp, the next generation Excel Connector, is now available on the AppExchange https://www.salesforce.com/appexchange/detail_overview.jsp?id=a0330000002excyAAA
 
View the presentation or take advantage of the 30 free trial.
 
Any questions, please let me know.
 
Thanks,
 
Bill Emerson
Developer
forceAmp.com
bemerson at forceamp.com