• patros
  • NEWBIE
  • 105 Points
  • Member since 2009

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 28
    Replies

I've got several PageBlocks on my page (some with PageBlockSections), which are rerendered depending on the actions of various forms.  I want to replace them with something without default formatting (like datatable) but that I can also rerender. I thought this would be easy but nothing else I've tried is rerendering successfully.

 

What can I use?

 

Also, is there some way to override the basic formatting? I understand I can set a different tab-style, but for the moment I want to turn it off and use corporate stylesheets instead (we are trying to put this live on Sites).

Hi, I have created the "tabbed Opportunity" page, and now I created another page "opportunity detail".

 

So, can I reference this "opportunity detail" page in the "tabbed opportunity page"? By doing this, I can have various pages for different sections so the overall page is not so long.

 

 

<apex:page standardController="Opportunity" showHeader="true" > <style> .activeTab {background-color: #236FBD; color:white; background-image:none} .inactiveTab { background-color: lightgrey; color:black; background-image:none} body{margin: 0; padding: 0; font-size:9pt} </style> <apex:tabPanel width="100%" switchType="client" selectedTab="tabdetails" id="OppTabview" tabClass="activeTab" inactiveTabClass="inactiveTab" > <apex:sectionHeader title="{!$ObjectType.Opportunity.label}" subtitle="{!Opportunity.name}"/> <apex:tab label="Details" name="OppDetails" id="tabdetails" > <!-- how to reference the detail page here? --> $page.OpportunityDetail <!-- <apex:detail subject="{!Opportunity}" relatedList="false" title="true" --> </apex:tab> <apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct" > <apex:relatedList subject="{!opportunity}" list="OpenActivities" /> </apex:tab> </apex:tabPanel> </apex:page>

 

 

 

I've written a controller that executes Apex code when a custom button is clicked.  I used the example in this article as my base:

http://sfdc.arrowpointe.com/2009/01/08/invoke-apex-from-a-custom-button-using-a-visualforce-page/

 

It works great and does exactly what I wanted. My version of the controller is for the Contract object.  Basically, when the button is clicked, it invokes Apex code that searches for records in a custom object called Time_Entry__c  and updates the contract# to Time_Entry__c records based on a bunch of criteria.

 

The controller:

public class CtrBnController { private final Contract c; public CtrBnController(ApexPages.StandardController stdController){ this.c = (Contract)stdController.getRecord(); } public PageReference UpdateTE(){ String theId = ApexPages.currentPage().getParameters().get('id'); if(theId == Null){ return Null; } Contract c = [select ID, AccountID, StartDate, EndDate, Contract_App__c from Contract where ID = :theID]; { for(Time_Entry__c t : [select Contract__c, Date__c from Time_Entry__c where Contract__c = Null and Case__r.AccountID = :c.AccountID and Case__r.Contract_App__c != Null and Case__r.Contract_App__c = :c.Contract_App__c]){ if(t.Date__c >= c.StartDate && t.Date__c <= c.EndDate) { t.Contract__c = c.ID; try{ Update t; } catch(DMLException D){ t.Reason__c = 'ERROR Hrs <> Work Type'; Update t; } } } } PageReference pageRef = new PageReference ('/' + theID); pageRef.setRedirect(true); return pageRef; } }

 

The problem is the test method:

static testmethod void TestCtrBn(){ Contract c = [select ID from Contract where CustomerSignedTitle = 'CtrBnController']; ApexPages.StandardController sc = new ApexPages.StandardController(c); CtrBnController controller = new CtrBnController(sc); controller.UpdateTE(); Integer t = [Select count() from Time_entry__c where Contract__c = :c.ID]; system.AssertEquals(3, t); }

 

Based on the way I've set up the test data, UpdateTE should update 3 Time Entries, so t should equal 3, but when I run the test method I get "Assertion Failed:  Expected: 3 Actual: 0"  Also, the Code Coverage results shows that none of the code in UpdateTE is being executed after

 

String theId = ApexPages.currentPage().getParameters().get('id'); if(theId == Null) { return Null; }

 

So it looks to me like the test method cannot see the Contract record.  As I said, the controller actually does work correctly from the platform when tested. 

 

Anyone see what I'm doing wrong?

 

I need a basic understanding of how to write test code for a controller extension with a VF page, and I'm just not getting it from p.72-74 of the Pages Developer guide.

I've written a VF page and extension to override the Lead Convert button.  The extension creates a contact and account as normal, but can create more than one opp based on a custom field's values.

 

[Here's the contoller extension] public class LeadExtension { private final ApexPages.StandardController jsLeadController; public LeadExtension(ApexPages.StandardController stdController) { jsLeadController = stdController; } public PageReference autoRun() { // //Code here to create contact and account, then create one or more opps as needed, then return to //the standard "conversion successful" page // } } [Here's the VF page, named LeadConversion] <apex:page standardController="Lead" extensions="LeadExtension" action="{!autoRun}"> </apex:page>

 

* Do I first set up a lead record with test values as I would do in a typical unit test?

* How do I invoke the VF page to kick off the autorun extension?  Do I just execute the code below?  (The VF page is named LeadConversion.)  Do I need to pass the Lead ID somehow?

 

//Create a reference to the VF page PageReference pageRef = Page.LeadConversion; Test.setCurrentPageReference(pageRef);

 

 Thanks

David

 

 

 

I noticed this entry on the Spring '10 Preview website: http://developer.force.com/releases/release/Spring10/Authenticated+Website+User

 

Sounds intriguing - I assume this means we can allow public, non-portal site users to create user accounts and authenticate.

 

I kicked around a Spring 10 pre-release org and see the profile type there, but I cant do much with it.

 

Anyone have details around this new user type? Also, what's the pricing structure going to be? The portal pricing structure has been the main reason why we haven't been able to move ahead with creating authenticated Force.com sites. Hope this changes things... 

  • January 18, 2010
  • Like
  • 0

Salesforce won't let me create an Outbound Message on a custom object that has two master-detail relationship fields. It seems to be okay with custom objects with only one master-detail relationship field.

 

Anyone else experienced this? Is it a known issue or do I need to dig deeper?

  • October 29, 2009
  • Like
  • 0

I can't seem to pass the sfdc.extractionSOQL property as a parameter on the command line when running the data loader. Other parameters work fine. Is sfdc.extractionSOQL not passable, or is my syntax just off? See my attempts below

 

This works (excluding sfdc.extractionSOQL):

_jvm\bin\java.exe -cp DataLoader.jar;"c:\integration\sqljdbc.jar" -Dsalesforce.config.dir=conf com.salesforce.lexiloader.process.ProcessRunner process.name=SalesforceContactToDB

 

This doesn't (tried to put quotes around it):

_jvm\bin\java.exe -cp DataLoader.jar;"c:\integration\sqljdbc.jar" -Dsalesforce.config.dir=conf com.salesforce.lexiloader.process.ProcessRunner process.name=SalesforceContactToDB sfdc.extractionSOQL="SELECT ID, FIRSTNAME, LASTNAME, EMAIL, PHONE, TESTVALUE__C FROM CONTACT WHERE TESTVALUE__C = 1"

 

Nor this (no quotes):

_jvm\bin\java.exe -cp DataLoader.jar;"c:\integration\sqljdbc.jar" -Dsalesforce.config.dir=conf com.salesforce.lexiloader.process.ProcessRunner process.name=SalesforceContactToDB sfdc.extractionSOQL=SELECT ID, FIRSTNAME, LASTNAME, EMAIL, PHONE, TESTVALUE__C FROM CONTACT WHERE TESTVALUE__C = 1

 

 

 Nor this (escape spaces):

_jvm\bin\java.exe -cp DataLoader.jar;"c:\integration\sqljdbc.jar" -Dsalesforce.config.dir=conf com.salesforce.lexiloader.process.ProcessRunner process.name=SalesforceContactToDB sfdc.extractionSOQL=SELECT\ ID,\ FIRSTNAME,\ LASTNAME,\ EMAIL,\ PHONE,\ TESTVALUE__C\ FROM\ CONTACT\ WHERE\ TESTVALUE__C\ \=\ 1

 

 

Thanks!

Message Edited by patros on 09-18-2009 02:08 PM
Message Edited by patros on 09-18-2009 02:09 PM
  • September 18, 2009
  • Like
  • 0

I have a Visualforce component that renders a data table and enables paging for it. The data itself and the fields to display are passed as variables to the component's body so the table layout can be customized (hoping to get re-use out of this).

 

Functionally, everything is working. However, the customized component body is always a "step behind" when paging through the data (ex. look at page 1 then click "next" - page increments, previous button is displayed, but data doesn't update).

 

You can see a live demo of this issue here. In this case, contact records are being retrieved (we have some custom objects to help abstract this for use with any object and any fields on the object).

 

Interestingly, if I take all the markup in the <c:WebTable> component on the Directory page and explicitly put it in the WebTable component (and overwrite the <componentBody> tags), it works fine.

 

All the code is provided below.

 

Thanks!

tom

 

 

WebTable Component (WebTable)

 

 

<apex:component controller="WebTableComponent">
<apex:attribute name="identifier" assignTo="{!identifier}" type="String" description="Unique key used to identify web table for configuration." />

<apex:outputPanel id="webTablePanel">
<apex:outputText value="Page {0}">
<apex:param value="{!currentPage}" />
</apex:outputText>
<apex:componentBody >
<apex:variable var="dataObjects" value="{!dataObjects}" />
<apex:variable var="fields" value="{!fields}" />
</apex:componentBody>
<apex:form >
<apex:commandLink immediate="true" rendered="{!hasPrevious}" action="{!movePrevious}" value="previous" rerender="webTablePanel" />
<apex:outputText value=" | " rendered="{!AND(hasPrevious,hasNext)}" />
<apex:commandLink immediate="true" rendered="{!hasNext}" action="{!moveNext}" value="next" rerender="webTablePanel" />
</apex:form>
</apex:outputPanel>

</apex:component>

 

 

WebTable Component Controller (WebTableComponent)

 

 

public with sharing class WebTableComponent {

public String identifier { get; set; }

public Web_View__c view {
get {
if(view == null) {
view = [select
Id,
Name,
Object_Type__c,
Filter__c,
Order__c,
(select Field_Name__c from Web_View_Fields__r order by Sequence__c asc)
from Web_View__c
where Name = :identifier
];
}
return view;
}
private set;
}

public List<Web_View_Field__c> fields {
get {
return view.Web_View_Fields__r;
}
}

public String query {
get {
String out = 'select Id, ' + fieldNames + ' from ' + view.Object_Type__c;
if(view.Filter__c != null && view.Filter__c.trim() != '') out += ' where ' + view.Filter__c + ' ';
if(view.Order__c != null && view.Order__c.trim() != '') out += ' order by ' + view.Order__c + ' ';
System.debug(out);
return out;
}
}

public ApexPages.StandardSetController setController {
get {
if(setController == null) {
setController = new ApexPages.StandardSetController(Database.getQueryLocator(query));
setController.setPageSize(5);
}
return setController;
}
private set;
}

public String fieldNames {
get {
String out = '';
for(Web_View_Field__c f : fields) {
out += f.Field_Name__c + ',';
}
return out.substring(0, out.length() - 1); // gets rid of the extra comma put in above
}
}

public List<sObject> dataObjects {
get {
return setController.getRecords();
}
}

public Integer currentPage {
get {
return setController.getPageNumber();
}
}

public Integer totalPages {
get {
return setController.getResultSize();
}
}

public Boolean hasPrevious {
get {
return setController.getHasPrevious();
}
}

public Boolean hasNext {
get {
return setController.getHasNext();
}
}

public PageReference moveNext() {
setController.next();
return null;
}

public PageReference movePrevious() {
setController.previous();
return null;
}

public WebTableComponent() {}

}

 

 

Visualforce Page (/Directory)

 

 

<apex:page standardStylesheets="false" showHeader="false" sidebar="false">
<apex:composition template="Container">
<apex:define name="body">
<h1>Directory</h1>
<c:WebTable identifier="My Table" id="MyTable">
<table class="table">
<tr>
<apex:repeat value="{!fields}" var="f">
<th>
<apex:outputText value="{!f.Field_Name__c}" />
</th>
</apex:repeat>
<th>Details</th>
</tr>
<apex:repeat value="{!dataObjects}" var="d">
<tr>
<apex:repeat value="{!fields}" var="f">
<td>
<c:WebTableCell dataObject="{!d}" field="{!f}">
<apex:outputlink rendered="{!field.Field_Name__c == 'Email'}" value="mailto:{!fieldValue}">{!fieldValue}</apex:outputlink>
<apex:outputText rendered="{!NOT(AND(field.Field_Name__c == 'Email'))}" value="{!fieldValue}" />
</c:WebTableCell>
</td>
</apex:repeat>
</tr>
</apex:repeat>
</table>
</c:WebTable>
</apex:define>
</apex:composition>
</apex:page>

 

 

 

 

 

  • August 21, 2009
  • Like
  • 0

I'm trying to find a complete list of functions for the $Action global merge field. This page in the VF reference alludes to some of them, but I'd really like to have a complete list.

 

For example, Jon Mountjoy pointed out the use of $Action.Document.Download in a blog post I wrote, which makes loading documents as images in a VF page simple. I'd like to find out if there are other easier ways to do things vs. hacking around.

 

Thanks!

I'm setting up a few custom tab splash pages to introduce and explain custom objects in an app. I created these splash pages as Visualforce pages and linked them up through the Home > Custom Links section and applied them to the respective tabs.

 

The Visualforce page displays as the splash page, but the "don't show this message again" and "continue" buttons do not appear at the bottom. These buttons do display if I use a URL or s-control type custom link.

 

Are those buttons not currently supported on Visualforce splash pages, or does something need to be configured to enable them?

I have some questions/issues with how Visualforce renders the final HTML to the browser. My apologies if any of these have already been discussed. Please let me know if any of these are my problem or a bug. Here goes:

  1. I get duplicate DOCTYPE definitions when I use apex:include. It appears that the included page renders a new DOCTYPE reference at its position in the page.
  2. The <body> tag is not supplied when sidebar="false" and showHeader="false" in the apex:page attributes.
  3. I understand the purpose behind rendering <span> tags for all components, but it would be really nice to optionally restrict this. The added tags throw off the DOM and make things generally ugly. For example, if I want to inject a jQuery control (or the like), there's a risk that the control won't work due to the added tags, and I have no control over their display.

Is it possible to alias URLs for pages in a Force.com site?

 

For example, if a site has a product catalog, it would be nice to change the URL for a product category listing from:

 

https://www.mysite.com/product_category_list?category=a0d80000001eh5e

 

to:

 

https://www.mysite.com/catalog/categories/music

 

 

Any way to do this today? I think this is crucial for search engine optimization and marketing campaigns.

I wrote a basic component that renders data in an HTML tag, which you can pass as an attribute on the component. Ultimately, this will we be much more sophisticated, but I can't even get this working when I put two of the same component on one Visualforce page. The first component renders, but the second appears to be ignored. We're working on a lightweight CMS for Visualforce, so it would not be unrealistic to have multiple instances of the same component rendered multiple "content blocks" into one final page.

 

 

COMPONENT:

 

<apex:component controller="CTRL_COMP_cms_content">
<apex:attribute assignTo="{!wrap}" name="wrap" description="The HTML tag to wrap this component with." type="String" required="false" />

<apex:attribute assignTo="{!text}" name="text" description="The text to put in the tag." type="String" required="false" />

<apex:outputText value="{!output}" escape="false" />
</apex:component>

 

CONTROLLER:

 

public class CTRL_COMP_cms_content {

 

public String wrap {
get {
if(wrap == null) wrap = '';
return wrap;
}
set;
}

public String text {
get {
if(text == null) text = '';
return text;
}
set;
}

public String output {
get {
if(wrap == '') return text;

return '<' + wrap + '>' + text + '</' + wrap + '>';
}
}

public CTRL_COMP_cms_content() {}

}

 

PAGE WITH COMPONENTS:

 

<apex:page id="the-page">
<c:cms_content id="text1" text="First Text" wrap="div"></c:cms_content>
<c:cms_content id="text2" text="Second Text" wrap="div"></c:cms_content>
</apex:page>

 

FINAL RENDERED HTML OUTPUT:

 

<span id="the-page:text1"><div>First Text</div></span>

<span id="the-page:text2"></span>

 

The final HTML output includes the results from the first component and renders the <span> for the second component, but the contents of the second component are never rendered.

 

Help!

 

 

 

Morning all,

 

I'm running into numerous circular references when attempting to deploy from one dev org to another using the Force.com Ant migration tools. Typical example:

 

 


classes/TransactionExtension.cls(TransactionExtension):An error occurred on your page.
... more failed lines ...
pages/TransactionEdit.page(TransactionEdit):Apex class 'TransactionExtension' does not exist

... more failed lines ...

 

Repeat these errors with every other Page/Class pairing and that's what I'm dealing with.

 

Interestingly, I can deploy small sets of code successfully. It seems like when trying to deploy everything at once is the killer. But, I'm really trying to avoid piecemeal deployment.

 

My questions are:

  1. Am I missing something obvious to get this working?
  2. Is there a better set of logs to dig in and find the source of this issue?
  3. Is this a sequencing issue
  4. Does this seemingly-circular-reference set of errors actually point to another error, which causes everything to fall apart? If so, see question #2

 

  • March 30, 2009
  • Like
  • 0

I'm working on a VF page that will determine the object type of an ID passed to it. The ID is a salesforce id which could be any object type (Account, Contact, etc).

 

I can't seem to get from here to there through Apex. I've check the describe calls but I can't find something that let's me create an object based on an ID and determine its type...

 

My only other option looks like the last resort of looping through ALL object types and trying a select query against each type.

 

Any ideas on this?

 

Below is the pseudocode of what I don't want to do. If I go this route, I'm going to hit the 100-SOQL-call limit very quickly. Feels like there must be a better way.

 

String objectID = getParameter('id');

String objectTypeName = '';

foreach(sObjectType type in types) {

sObject testObject = Database.query('SELECT Id FROM ' + type.Name + ' WHERE ID = "' + objectID + '"');

 

if(sObject.id != '') {

objectTypeName = type.Name;

break;

}

}

  • February 27, 2009
  • Like
  • 0

I am pretty sure this one is a bug but I have a very simple component that has one attribute which is a string and passes the value to a style attribute in an outputpanel in the component. If this is in a pageBlockTable and you perform a rerender on the component this value will be lost.

Below is the code to reproduce:

Page:

<apex:page controller="componentIssues">
<apex:form >

Component in a pageBlockTable:<br/>
<apex:pageBlock >
<apex:pageBlockTable value="{!opps}" var="o">
<apex:column value="{!o.Name}"/>
<apex:column >
<c:componentStyle width="400px" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>


Component by itself:<br/><br/>
<c:componentStyle width="400px"/>

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

Componenet:

<apex:component >
<apex:attribute name="width" type="String" assignTo="{!width}"description="The width the outputPanel defined as '300px' or '100%'."/>

<apex:commandButton value="Rerender" reRender="all"/>

<apex:outputPanel id="all">
width should be: {!width}
<apex:outputPanel id="myDiv" layout="block" style="width: {!width};">
<apex:outputPanel layout="block" style="background-color: #F7B64B;">Hi.</apex:outputPanel>
</apex:outputPanel>
</apex:outputPanel>
</apex:component>

Simple controller for the page:

public class componentIssues {

List<Opportunity> opps;

public List<Opportunity> getOpps() {
if(opps == null){
opps = [select Name from Opportunity limit 1];
}
return opps;
}
}

If the component is not in a data table it works fine.  Any workarounds or solutions? I think this is a bug but if not I will edit the subject.

Thanks,
Jason 

Message Edited by TehNrd on 10-12-2009 08:58 AM
  • October 09, 2009
  • Like
  • 0

Hi all,

 

I have a visulforce component with a form built into it. The component controller handles the form submission and all the fields in the form are required. The submit action saves the form and rerenders it. If all the fields are filled out and submitted the form is successfully saved a thank you message appears, otherwise the errors show up below the required fields that aren't filled out. The form works great if all the fields are filled in without any errors the first time. The problem is that if there is an error on the first submit and the errors are corrected the next submit doesn't save correctly. Here's the code:

 

 

public class LeadController extends ContentCore { public Lead newlead {get; set;} public Opportunity newop {get; set;} public String promotion_id {get; set;} public Promotion__c promotion {get; set;} public LeadController() { this.newlead = new Lead(); this.newop = new Opportunity(); this.CurrentPageName = 'Request More Information'; this.CurrentPageUrl = System.currentPageReference().getUrl(); this.newlead.LeadSource = 'Website'; String prefix = ''; if(Site.getPrefix() != null) { prefix = Site.getPrefix(); } if(this.last_page != null) { this.newlead.ReferencePage__c = System.currentPageReference().getHeaders().get('host')+prefix+this.last_page.Location__c; } else { this.newlead.ReferencePage__c = System.currentPageReference().getHeaders().get('host')+prefix+this.CurrentPageUrl; } this.promotion_id = System.currentPageReference().getParameters().get('promotion_id'); if(this.promotion_id != null && this.promotion_id != '' ) { this.promotion = [SELECT Id, Name, Price__c, Title__c, Description__c, End_Date__c, ImageId__c, External_Link__c FROM Promotion__c WHERE Id =: this.promotion_id]; this.newlead.Promotion__c = this.promotion_id; } } public String[] getTags() { return new List<String>{'Connect'}; } public PageReference save() { if(this.newlead.Email != null) { //check if the contact exists Contact[] contacts = [SELECT Id, AccountId, Account.Name FROM Contact WHERE Email =: this.newlead.Email]; if(contacts.size() > 0) { if(contacts[0].Account.Name == this.newlead.Company) { this.newop.AccountId = contacts[0].AccountId; this.newop.Name = 'Web Opportunity'; this.newop.Type = 'Other'; this.newop.StageName = 'Prospecting'; this.newop.CloseDate = System.today().addDays(30); this.newop.Description = this.newlead.Description; if(this.promotion != null) { this.newop.Promotion__c = this.Promotion.Id; } upsert newop; return null; } } } upsert newlead; return null; } public String getPriceString() { return this.formatDouble(this.promotion.Price__c.doubleValue(), 2); } public String formatDouble(Double num, Integer decimalplaces) { Double multiplier = Math.pow(10, decimalplaces); num = num*multiplier; Long rounded = Math.roundToLong(num); num = rounded/multiplier; String formated = Decimal.valueOf(num).format(); //add zeros if needed Integer dotIndex = formated.indexOf('.'); if(dotIndex < 0) { formated += '.'; for(Integer i=0; i<decimalplaces; i++) { formated += '0'; } } else { Integer needed = decimalplaces - formated.substring(dotIndex+1).length(); for(Integer i=0; i <needed; i++) { formated += '0'; } } return formated; } } <apex:component controller="LeadController" allowDml="true"> <apex:attribute name="CurrentPageUrl" type="String" required="true" description="The url of the current page" /> <div class="article-controls"> <table width="100%" cellspacing="0" cellpadding="0"> <tr> <td style="width:40px; height:24px;"> <div style="position: relative; height: 24px; width: 40px; background-color:#c1cb97;"> <div style="position: absolute; top:0; left:0; width: 40px;"> <div style="float: left;"><apex:image value="{!$Resource.tlcorner}"/></div> <div style="float: right;"><apex:image value="{!$Resource.trcorner}"/></div> <div class="clear"></div> </div> <div style="position: absolute; bottom:0; left:0; width: 40px;"> <div style="position: static; float: left;"><apex:image value="{!$Resource.blcorner}"/></div> <div style="position: static; float: right;"><apex:image value="{!$Resource.brcorner}"/></div> <div class="clear"></div> </div> <div text="Sign up for updates" style="margin:4px 0px 4px 12px; width: 16px; height: 16px; float: left; cursor: pointer" onmouseover="roll('signup_icon','{!$Resource.signupon}');" onmouseout="roll('signup_icon','{!$Resource.signup}');" onclick="if($('#signupblock').is(':visible')) {$('#signupblock').hide();} else {$('#signupblock').show();} return false;"> <a href="#"><img src="{!$Resource.signup}" id="connect_with_us" title="CONNECT With Us" alt="CONNECT With Us" /></a> </div> <div class="clear"></div> </div> &nbsp; </td> <td>&nbsp;<!-- <div style="padding-left: 10px; color: #A8B561; font-size: 9pt;">Click to signup for<br /> regular updates</div>--></td> <td style="width: 53px; height:26px;"> <div style="position: relative; height: 26px; width: 53px; background-color:#c1cb97;"> <div style="position: absolute; top:0; left:0; width: 53px;"> <div style="float: left;"><apex:image value="{!$Resource.tlcorner}"/></div> <div style="float: right;"><apex:image value="{!$Resource.trcorner}"/></div> <div class="clear"></div> </div> <div style="position: absolute; bottom:0; left:0; width: 54px;"> <div style="position: static; float: left;"><apex:image value="{!$Resource.blcorner}"/></div> <div style="position: static; float: right;"><apex:image value="{!$Resource.brcorner}"/></div> <div class="clear"></div> </div> <table> <tr> <td style="padding-top: 3px; padding-left: 6px;"> <apex:outputLink value="{!CurrentPageUrl+'&pdf=1'}"><img src="{!$Resource.print}" id="print_icon" style="curser: pointer;" title="Print" alt="Print" /></apex:outputLink> </td> <td style="padding-top: 3px;"> <apex:outputLink value="{!CurrentPageUrl+'&pdf=1'}"><img src="{!$Resource.download}" id="download_icon" title="Download" alt="Download" /></apex:outputLink> </td> </tr> </table> <div class="clear"></div> </div> </td> </tr> </table> <div id="signupblock" style="display:none;"> <apex:outputPanel id="connect_form"> <apex:outputPanel rendered="{!ISNULL(newlead.Id)}"> <apex:form > <input type="hidden" name="sfga" value="00D3000000008XR"/> <h1 style="padding-top: 20px; font-size: 10pt;"> CONNECT With Us </h1> <table> <tr> <td>First Name</td> </tr> <tr> <td><apex:inputField value="{!newlead.FirstName}" styleClass="contact-input-text" required="true" /></td> </tr> <tr> <td>Last Name</td> </tr> <tr> <td><apex:inputField value="{!newlead.LastName}" styleClass="contact-input-text" required="true" /></td> </tr> <tr> <td>Your email address</td> </tr> <tr> <td><apex:inputField value="{!newlead.Email}" styleClass="contact-input-text" required="true" /></td> </tr> <tr> <td>Organization</td> </tr> <tr> <td><apex:inputField value="{!newlead.Company}" styleClass="contact-input-text" required="true" /></td> </tr> <tr> <td>How can we help?</td> </tr> <tr> <td><apex:inputField value="{!newlead.Description}" styleClass="contact-input-text-area" required="true" /></td> </tr> </table> <br /> <apex:commandButton action="{!save}" value="Submit" rerender="{!$Component.connect_form}" />&nbsp;&nbsp;<input type="reset" name="Clear" value="Clear" /> <br /> <br /> </apex:form> </apex:outputPanel> <apex:outputPanel rendered="{!!ISNULL(newlead.Id)}"> Thank you for your interest. <br /> We will respond within 24 hours. </apex:outputPanel> </apex:outputPanel> </div> </div> <p>&nbsp;</p> </apex:component>

 

 

 

I'm trying to find a complete list of functions for the $Action global merge field. This page in the VF reference alludes to some of them, but I'd really like to have a complete list.

 

For example, Jon Mountjoy pointed out the use of $Action.Document.Download in a blog post I wrote, which makes loading documents as images in a VF page simple. I'd like to find out if there are other easier ways to do things vs. hacking around.

 

Thanks!

I have tried writing testcase for below apex code but failed.....How can i cover this piece of code for test coverage please  help me out....

 public void getServiceInputs()
 {
    try
    {
  
CCMDAPIV3.CcmdServicePort ccmdport = new CCMDAPIV3.CcmdServicePort();
        CCMDV3inputparams inputParam=new CCMDV3inputparams();
        this.pUserName = inputParam.userName;
        this.pserviceURL = inputParam.serviceurl; 
        this.managerKey =  inputParam.managerKey;    
        String token = ccmdport.openApiConnection(inputParam.userName, inputParam.password, inputParam.managerKey, inputParam.serviceurl);
   if(token != null)
{

this.pStatus = 'Login Successfull'; 
}
else
{
this.pStatus = 'Login Failed';
}
           
            
    }
    catch(Exception ex)
    {            
        this.pStatus = 'Login Failed';
        pError = 'Error Message: '+ex;
        //ApexPages.addMessages('aa'+ex.ToString());  
        //return null;
    }
    
}

Test code:

CCMDAPIV3.CcmdServicePort ccmdport = new CCMDAPIV3.CcmdServicePort();
token = ccmdport.openApiConnection(userName, 'psword', managerKey, serviceURL);
if(token != null)
{
loginStatus = 'Login Successfull'; 
system.assert(true);
}
else
{
loginStatus = 'Login Failed';
system.assert(false);
}
 
Thanks
shaan 
  • July 22, 2009
  • Like
  • 0

I'm setting up a few custom tab splash pages to introduce and explain custom objects in an app. I created these splash pages as Visualforce pages and linked them up through the Home > Custom Links section and applied them to the respective tabs.

 

The Visualforce page displays as the splash page, but the "don't show this message again" and "continue" buttons do not appear at the bottom. These buttons do display if I use a URL or s-control type custom link.

 

Are those buttons not currently supported on Visualforce splash pages, or does something need to be configured to enable them?

Hi

 

I'm building in authentication using Customer Portal - and the Site class.  This provides methods for logging in, and registration.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_sites.htm

 

However, I can't find out how to log out. There is no log out method.  How can I do that?

 

Thanks

Jon

I've got several PageBlocks on my page (some with PageBlockSections), which are rerendered depending on the actions of various forms.  I want to replace them with something without default formatting (like datatable) but that I can also rerender. I thought this would be easy but nothing else I've tried is rerendering successfully.

 

What can I use?

 

Also, is there some way to override the basic formatting? I understand I can set a different tab-style, but for the moment I want to turn it off and use corporate stylesheets instead (we are trying to put this live on Sites).

I wrote a basic component that renders data in an HTML tag, which you can pass as an attribute on the component. Ultimately, this will we be much more sophisticated, but I can't even get this working when I put two of the same component on one Visualforce page. The first component renders, but the second appears to be ignored. We're working on a lightweight CMS for Visualforce, so it would not be unrealistic to have multiple instances of the same component rendered multiple "content blocks" into one final page.

 

 

COMPONENT:

 

<apex:component controller="CTRL_COMP_cms_content">
<apex:attribute assignTo="{!wrap}" name="wrap" description="The HTML tag to wrap this component with." type="String" required="false" />

<apex:attribute assignTo="{!text}" name="text" description="The text to put in the tag." type="String" required="false" />

<apex:outputText value="{!output}" escape="false" />
</apex:component>

 

CONTROLLER:

 

public class CTRL_COMP_cms_content {

 

public String wrap {
get {
if(wrap == null) wrap = '';
return wrap;
}
set;
}

public String text {
get {
if(text == null) text = '';
return text;
}
set;
}

public String output {
get {
if(wrap == '') return text;

return '<' + wrap + '>' + text + '</' + wrap + '>';
}
}

public CTRL_COMP_cms_content() {}

}

 

PAGE WITH COMPONENTS:

 

<apex:page id="the-page">
<c:cms_content id="text1" text="First Text" wrap="div"></c:cms_content>
<c:cms_content id="text2" text="Second Text" wrap="div"></c:cms_content>
</apex:page>

 

FINAL RENDERED HTML OUTPUT:

 

<span id="the-page:text1"><div>First Text</div></span>

<span id="the-page:text2"></span>

 

The final HTML output includes the results from the first component and renders the <span> for the second component, but the contents of the second component are never rendered.

 

Help!

 

 

 

I need to pass a field value (the id, in this case) of the object on a Standard Controller page to a VF page that uses a custom controller. I want to mimic the standard controller behavior that occurs when you click "new" in a relatedlist section - that being: the standard controller takes you to the screen to enter new data for the related list object, and the lookup field to the parent is already populated.

 

I currently have a New-button override that will launch the VF page, but I can't figure out how to pass it a parameter without building the originating page and controller from scratch.

Hello,

 

I tried to use variables (merge fields) in  a custom label (used inside a VisualForce page) like this

 

<a href="something">View</a> case {!Case.CaseNumber} submitted on {!Case.CreatedDate}.

 

That doesn't work for and I'd like to find out if that custom label content/text needs to be formatted differently or if it's just not supported.

 

I tried to search around but didn't find any example/documentation about this.

 

Thank you.

 

al

I have a Visualforce page which renderedAs pdf. The problem I am facing is the page is opening in multiple windows.

 

URL of the first window is shown as the Visualforce page url I am using and other window

is the Adobe Reader.

 

This is happening only for some of the users. I think it is a problem with the browser settings.

 

Any suggestions will be great.

 

Thanks

Arvind

Hi, I have created the "tabbed Opportunity" page, and now I created another page "opportunity detail".

 

So, can I reference this "opportunity detail" page in the "tabbed opportunity page"? By doing this, I can have various pages for different sections so the overall page is not so long.

 

 

<apex:page standardController="Opportunity" showHeader="true" > <style> .activeTab {background-color: #236FBD; color:white; background-image:none} .inactiveTab { background-color: lightgrey; color:black; background-image:none} body{margin: 0; padding: 0; font-size:9pt} </style> <apex:tabPanel width="100%" switchType="client" selectedTab="tabdetails" id="OppTabview" tabClass="activeTab" inactiveTabClass="inactiveTab" > <apex:sectionHeader title="{!$ObjectType.Opportunity.label}" subtitle="{!Opportunity.name}"/> <apex:tab label="Details" name="OppDetails" id="tabdetails" > <!-- how to reference the detail page here? --> $page.OpportunityDetail <!-- <apex:detail subject="{!Opportunity}" relatedList="false" title="true" --> </apex:tab> <apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct" > <apex:relatedList subject="{!opportunity}" list="OpenActivities" /> </apex:tab> </apex:tabPanel> </apex:page>

 

 

 

The following 2 classes are breaching governor limits.  Any ideas how I can reduce the number of rows returned at once while achieving the same result?

 

     private void RetrieveUserKPIData()
    {       
        //Retrieve the collection of USER_KPI Records
        //IMPLEMENT BATCH CREATION HERE AS REQUIRED
        for (   User_Month_KPI__c[] UserKPIs :
                                            [
                                            select  
                                                u.OwnerId,
                                                u.active_accounts_actual__c,
                                                u.APNrent_month_revenue_actual__c,
                                                u.revenue_new_accounts_actual__c,
                                                u.new_accounts_signed_actual__c,
                                                u.APN_Month__c,
                                                u.APN_Year__c,
                                                u.Month_Start_date__c,
                                                u.Month_End_date__c,
                                                u.avg_rev_per_account_actual__c,
                                                u.IPI_bookings_count__c,
                                                u.Id
                                            from    User_Month_KPI__c u
                                            where   u.APN_Year__c = :APNYear
                                            and     u.APN_Month__c = :APNMonth
                                            ] )
        {
            for (User_Month_KPI__c UserKPI : UserKPIs)
            {
                this.getCurrentSet().put(UserKPI.OwnerId,UserKPI);
                UserKPI.Month_Start_date__c = APNMonthStartDate;
                UserKPI.Month_End_date__c = APNMonthEndDate;
                
                Records++;
            }
        }
        
        CurrentSet=0;
    }


    public BulkAccountKPIs (UserKPICollectionClass pUKP)
    {
            pUKP.SetToStart();
            Map <Id,User_Month_KPI__c> KM;
            
            while ( (KM = pUKP.getCurrentSetIncrement()) !=  null)
            {
                Set<Id> UserIds = KM.keySet();
                
                for (Id Uid : UserIds)
                {
                    User_Month_KPI__c K = KM.get(Uid);
                    K.avg_rev_per_account_actual__c = 0;
                    K.Total_Number_Accounts__c = 0;
                    K.Total_Account_Revenue__c = 0;                    
                }
                
                for (Account[] accounts : [select
                                    t.Rating,
                                    t.OwnerId,
                                    t.Sales_Current_Month__c,
                                    t.CreatedDate,
                                    t.Active__c
                            from Account t
                            where t.OwnerId in :UserIds]
                            )
                {
                    for (Account account : accounts)
                    {
                        User_Month_KPI__c K = KM.get(account.OwnerId);
                        Processed++;
                        
                        K.Total_Number_Accounts__c++;                        
                        
                        if (account.Active__c == true)
                        {
                            TotalActive++;
                               TotalSalesCurrentMonth = TotalSalesCurrentMonth + account.Sales_Current_Month__c;
                            
                        }
            }
                }

                for (Id Uid : UserIds)
                {
                    User_Month_KPI__c K = KM.get(Uid);
                    if (K.Total_Number_Accounts__c != 0)
                    {
                        
                        K.avg_revenue_per_new_acc_actual__c = 0;
                        if (
                                   (K.revenue_new_accounts_actual__c > 0)
                                && (K.new_accounts_signed_actual__c >0)
                                && (K.revenue_new_accounts_actual__c != null)
                                && (K.new_accounts_signed_actual__c != null)
                            )
                         {
                            K.avg_revenue_per_new_acc_actual__c =
                                K.revenue_new_accounts_actual__c / K.new_accounts_signed_actual__c;
                         }
                         
                         K.avg_rev_per_account_actual__c = 0;
                        if (
                                    (K.APNrent_month_revenue_actual__c > 0)
                                && (K.APNrent_month_revenue_actual__c != null)
                            )
                         {
                            K.avg_rev_per_account_actual__c =
                                TotalSalesCurrentMonth / TotalActive;
                         }
                    }
                }
                
            }
    }

Hi All,

 

I would like to understand why For loop with List<> is more efficient than regular loop:

 

for (List<Account> accts : [query statement]

 

is more efficient than

 

for (Account accts : [query statement]

 

Can anyone help me to understand why??

 

Thanks.

Is there a way to implement batch printing in apex?

 

We want the users to be able to print all the quotes selected from a list by click of one button.

I was not sure how we could call the windows print functionality and send all the documents to the printer for printing.

 

 

Please let me know if you have any idea about how this can be achieved

 

Thanks,

Pooja

Hi,

 

When our app makes a callout to an external webservice over SSL, we get the following Exception:

 

System.CalloutException: IO Exception: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

 

 This doesn't happen with regular http callout. our certificate is NOT expired on the target server and everything seems to be normal. no alert or anything from the browser.

 any idea?

 

Thanks,

 

P.S We need to resolve this for security review.

 

 

 

 

 

 

Message Edited by Bms270 on 05-14-2009 07:17 PM
Message Edited by Bms270 on 05-14-2009 07:19 PM

Hi, In my visualforce page, I want to call apex method through javascript. Following is the code for the same. Code is working fine for Save1 button but not for Save button. Both the button call the same javascript method.

 

Please guide.

 

VisualForce Page

 

<apex:page controller="apexVFJavascript" tabStyle="Opportunity" >

<apex:form >
<apex:actionFunction name="customAction" action="{!customAction}" rendered="true" rerender="myStatus" >
<apex:param name="firstParam" value="" assignTo="{!first}"/>
<apex:param name="secondParam" value="" assignTo="{!second}"/>
</apex:actionFunction>
</apex:form>
<apex:form >
<apex:pageBlock >
<apex:commandButton onclick="doAction()" id="Save" title="Save" value="Save"/> <!-- not working for this button -->
<apex:outputPanel onclick="doAction()" styleClass="btn">Save</apex:outputPanel> <!-- working for this -->
</apex:pageBlock>
<script>
function doAction() {
customAction('1','2');
}
</script>
</apex:form>

<apex:outputPanel id="out">
<apex:outputText value="Hello "/>
<apex:actionStatus startText="requesting..." id="myStatus">
<apex:facet name="stop">{!first} - {!second}</apex:facet>
</apex:actionStatus>
</apex:outputPanel>
</apex:page>

 Component Class

 

public class apexVFJavascript {



private String first='one',second='two';

public void setFirst(String s) {
this.first = s;
}

public String getFirst() {
return first;
}

public void setSecond(String s) {
this.second = s;
}

public String getSecond() {
return this.second;
}

public PageReference customAction() {
Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.FATAL,'Error Message'));

System.debug(first);
System.debug(second);
return null;
}
}

 

 

 

Is it possible to sum to outputField values?

 

Something like:  

<apex:outputField value="{!Total.Amount} + {!TimeMaterials.Amount}" />

 

If you issue a SOSL search for a namespaced custom object in Apex code, you must fully specify the namespace prefix.

Omitting it, even if you are calling from within the same namespace, leads to a silent failure (an empty resultset)

The following code runs just fine, and both asserts succeed:

Code:
System.assert(0 != [find 'skipping' returning i__AALog__c (ID limit 10)][0].size());
System.assert(0 == [find 'skipping' returning    AALog__c (ID limit 10)][0].size());

 
The second statement should perform identically to the first.  If that's not possible, it should fail to compile.




  • April 09, 2008
  • Like
  • 0