• gjtorikian
  • NEWBIE
  • 55 Points
  • Member since 2009

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 6
    Replies

I'm not sure to whom I should report this, but there appears to be an error in the example code on page 113 of the Winter '10 Visualforce Developer's Guide. The code covers an example for sending emails from a Visualforce page. The part where the error lies is here:

 

String addresses;if (account.Contacts != null){addresses = account.Contacts[0].Email;// There may be more contacts, so loop through the whole listfor (Integer i = 1; i < account.Contacts.size(); i++){if (account.Contacts[i].Email != null){addresses += ':' + addresses;}}}

 I copied this code straight from the pdf and my test app wouldn't send out multiple emails if there were multiple recipients. I found the error and it works now, and thus I can only assume the documentation is in error.

 

The error lies in the last line before all the '}'s. it reads -- address += ':' + address; -- but it should read -- address += ':' + account.Contacts[0].Email;  

 

I made this change and my test code works fine now. 

 

 

Hi All,

 

The question relates to the use of custom CSS with Visual Force pages.

 

Say one starts off with an HTML page that includes forms and several other HTML tags, and uses a CSS to control the layout and page look-and-feel.

 

The idea is to convert the HTML/CSS combination into a Visual Force page.

 

We add the corresponding <apex:page> tags, replace the CSS references by the proper <apex:stylesheet> component pointing to the CSS in the static resources, etc.

 

We also replace the forms, input fields, etc. by the corresponding  Visual Force components.

 

When it comes to applying the style to the now Visual Force components, we use the styleClass attribute of each of the Visual Force components. This is the cost/effective way to re-use the existing HTML/CSS design.

 

My question is whether there are any restrictions on how the CSS is defined. For instance, can the CSS include all the different types of selectors -e.g. type, ID, class, etc. ? 

 

For instance, our CSS includes type selectors for the forms as follows:

 

orm.side                                             { font-size:0.8em }
form.side fieldset                                    { margin-top:5px }
form.side fieldset legend                         { font-size:1em; font-weight:bold; padding-bottom:5px }
form.side label                                     { display:block; width:80px; height:10px; padding-top:5px }
form.side .complete                             { float:right; font-size:1.1em; font-weight:bold; display:block; width:193px; height:10px; padding-top:4px }

form.side input, form textarea, form select { float:right; clear:both; border:1px solid #A5B7E0; font-size:1em; padding:0.2em }
form.side input                                     { width:186px }
form.side textarea                                 { width:273px; overflow: auto }
form.side select                                     { width:193px }
form.side select.day                             { clear:none; width:43px }
form.side select.month                         { clear:none; width:93px }
form.side select.year                             { clear:none; width:57px }
form.side input.button                            { width:100px; background-color:#f7a229; font-weight:bold; color:#333333; border:1px solid #a1a1a1 }

form.side error                                     { display: block; clear:both; width: 185px; padding-left:86px; font-size:0.9em; color:#FF0000 }

 

Do we have to use CSS classes instead so that we can then use the styleClass attribute ?.

 

Or we also have ID selector such as:

 

#main_wrapper .inner                            { padding:10px 10px 13px 10px }

 

so do we have to supply the right ID to the Visual Force component where we use that style ?.

 

Generaly speaking, are there any guidelines for how to define a CSS that is compatible with Visual Force pages ?.

 

Thank you very much in advance,

Fernando

I need to set a query parameter in a test method.  The documentation makes only a quick reference to this, saying:

To set a query string parameter:

  • If you're writing a custom controller, use the setParameters() method with ApexPages.currentPage() to add a query parameter in a test method. For example:
    String key = 'name';
    String value = 'Caroline';
    ApexPages.currentPage().setParameters().put(key, value);
    Note
     The setParameters() method is only valid inside test methods.

However, when I put this in my test method, I get the error:

 

Save error: Method does not exist or incorrect signature: [System.PageReference].setParameters()    Testm62ConsoleController.cls    /m62 Sandbox/src/classes    line 80    Force.com save problem

 

Here is my test method:

 

 static testMethod void testConsoleController() {

		// Find a telesales user for the tests
        Profile p = [select id from profile where name='Telesales']; 
        User u = new User(alias = 'standt', email='standarduser@testorg.com', 
            emailencodingkey='UTF-8', lastname='Testing', profileid = p.Id, 
            languagelocalekey='en_US', 
            localesidkey='en_GB', 
            timezonesidkey='Europe/London',
            username='standarduser@testorg.com');


        System.runAs(u) {
         		
		//Set up the data
		List<Account> accs = new List<Account>();
		for (Integer i=0; i<50; i++) {
			Account a = new Account(
				Name = 'Test Account 1',
				BillingCountry = 'United Kingdom',
				Phone = '+44 (0)12679 121 5555',
				To_be_cleansed__c = true
			);
			accs.add(a);
		}
		insert accs;
		
		List<Contact> conts = new List<Contact>();
		List<Task> tasks = new List<Task>();
		// Create two contacts for each account
		for (Integer i=0; i<50; i++) {
			Contact c = new Contact();
			c.FirstName = 'Test';
			c.LastName = 'Contact 1';
			c.AccountId = accs[i].Id;
			c.MailingCountry = 'United Kingdom';
			c.Email = 'no@email11111.com';
			c.Phone = '+44 (0)1423 564888';
			conts.add(c);
		
			Contact c1 = new Contact();
			c1.FirstName = 'Test';
			c1.LastName = 'Contact 1';
			c1.AccountId = accs[i].Id;
			c1.MailingCountry = 'United Kingdom';
			c1.Email = 'no2@email11111.com';
			c1.Phone = '+32 (0) 2 679 12 11';
			conts.add(c1);
			
			// Add a task for each account
			Task t = new Task(WhatId=accs[i].Id, Type='Telephone call', Subject='Test subject', Status='Not started', 
            				Priority='Normal'); 
            tasks.add(t);
		}
	
		insert conts;
		insert tasks;
		
        PageReference pageRef = Page.newConsole;  // Instantiate telesales console page
        Test.setCurrentPage(pageRef);
      
        //Instantiate and construct the controller class.   
        m62ConsoleController controller = new m62ConsoleController();		
		Test.startTest();
		
		controller.selectedAcc = accs[4];
		controller.last();
		if (controller.getHasPreviousAcc()) controller.previousAcc();
		if (controller.getHasNextAcc()) controller.nextAcc();
		
		controller.getMyAccounts();
		controller.first();
		String ids = accs[6].Id;
		ApexPages.currentPage().setParameters().put('AccSel', ids);

		ids = conts[12].Id;
		ApexPages.currentPage().setParameters().put('ConSel', ids);

		controller.resetConts();
		controller.viewCont();
		controller.resetTsks();
		controller.viewTsk();
		
	}
    }

 Can anyone advise what I'm doing wrong? I've searched all over for more information but can't find any.

Thanks.

 

I'm not sure to whom I should report this, but there appears to be an error in the example code on page 113 of the Winter '10 Visualforce Developer's Guide. The code covers an example for sending emails from a Visualforce page. The part where the error lies is here:

 

String addresses;if (account.Contacts != null){addresses = account.Contacts[0].Email;// There may be more contacts, so loop through the whole listfor (Integer i = 1; i < account.Contacts.size(); i++){if (account.Contacts[i].Email != null){addresses += ':' + addresses;}}}

 I copied this code straight from the pdf and my test app wouldn't send out multiple emails if there were multiple recipients. I found the error and it works now, and thus I can only assume the documentation is in error.

 

The error lies in the last line before all the '}'s. it reads -- address += ':' + address; -- but it should read -- address += ':' + account.Contacts[0].Email;  

 

I made this change and my test code works fine now. 

 

 

Hello

 

 I have created a form that contains an action region which is being rerendered when a button inside that region is clicked. The action region basically consists of a input text box, a list of values, and 2 buttons to add or remove values from the list of values.

 

If I label the buttons with words such as 'Add' and 'Remove', the action region rerenders correctly when the buttons are clicked. If I label the 'Add' button with any number of '>' (as I did initially) the entire form submits instead of just the action region.

 

This strange behaviour is definitely caused by changing the button label alone. It is also very difficult to troubleshoot as I assumed the fault lay with my code and no debug methodolgies (including the debug logs) point to the cause of the error.

 

For the sake of completeness I'll post the entire code, although the affect area is quite small.

 

VisualForce (search for '>>' to find the troublesome label)

 

 

<apex:page showHeader="false" controller="LoginController" extensions="FrontOfficeConfigExt" title="{!$Label.site.register}" standardStylesheets="true">
<c:StyleSheet />
<script src="/soap/ajax/15.0/connection.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript" src="{!URLFOR($Resource.AutoSuggest,'actb.js')}"></script>
<script language="javascript" type="text/javascript" src="{!URLFOR($Resource.AutoSuggest,'common.js')}"></script>
<script>
function initAutoSuggest() {
var channels = {!SkillsToJs} //new Array();
//alert(channels);
actb(txtSkil,channels);
}
<!-- assign the setupPage function to the body onload event -->
var previousOnload = window.onload;
window.onload = function() {
if (previousOnload) {
previousOnload();
}

initAutoSuggest();
}
</script>
<div id="wrapper">
<div id="main" style="height:400px">
<c:SiteHeader ></c:SiteHeader>
<apex:form >
<apex:actionFunction name="selectSkill" rerender="skillBlock" status="workingstatus"/>
<apex:actionFunction name="deleteSkill" rerender="skillBlock" status="workingstatus"/>
</apex:form>

<apex:form >
<apex:messages />
<apex:pageBlock mode="edit" title="{!$Label.reg_pb_newUserTitle}">
<apex:pageBlockSection title="{!$Label.reg_pbs_contact}" columns="1">
<apex:inputField value="{!candidate.FirstName__c}"/>
<apex:inputField value="{!candidate.LastName__c}"/>
<apex:inputField value="{!candidate.Email__c}"/>
<apex:inputField value="{!candidate.StreetAddress__c}"/>
<apex:inputField value="{!candidate.Postcode__c}"/>
<apex:inputField value="{!candidate.City__c}"/>
<apex:inputField value="{!candidate.State__c}"/>

<apex:pageBlockSectionItem labelStyleClass="labelStyle" dataStyleClass="dataStyle">
<apex:outputLabel value="{!$Label.reg_text_countryLabel}" for="country" ></apex:outputLabel>
<apex:selectList id="country" value="{!candidate.Country__c}" size="1">
<apex:selectOptions value="{!comboCountriesValues}"></apex:selectOptions>
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:inputField value="{!candidate.Login__c}"/>
<apex:pageblocksectionItem >
<apex:outputLabel value="{!$ObjectType.Candidate__c.fields.Password__c.label}" for="pwd"></apex:outputLabel>
<apex:outputPanel layout="block" styleClass="requiredInput">
<apex:outputPanel layout="block" styleClass="requiredBlock"/>
<apex:inputSecret id="pwd" value="{!candidate.Password__c}" required="true"/>
</apex:outputPanel>
</apex:pageblocksectionItem>
<apex:pageblocksectionItem >
<apex:outputLabel value="{!$ObjectType.Candidate__c.fields.passwordConfirmation__c.label}" for="pwdConfirmation"></apex:outputLabel>
<apex:outputPanel layout="block" styleClass="requiredInput">
<apex:inputSecret id="pwdConfirmation" value="{!candidate.passwordConfirmation__c}" required="true"/>
<apex:outputPanel layout="block" styleClass="requiredBlock"/>
</apex:outputPanel>
</apex:pageblocksectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection title="{!$Label.reg_pbs_education}" columns="1" >
<apex:pageBlockSectionItem rendered="{!layout.ExperienceDisplay__c}">
<apex:outputLabel value="{!$Label.reg_text_experienceLabel}" for="experience" ></apex:outputLabel>
<apex:selectList id="experience" value="{!experienceID}" size="1">
<apex:selectOptions value="{!comboExperienceValues}"></apex:selectOptions>
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem rendered="{!layout.ExperienceDisplay__c}">
<apex:outputLabel value="{!$Label.reg_text_educationLabel}" for="education" ></apex:outputLabel>
<apex:selectList id="education" value="{!educationID}" size="1">
<apex:selectOptions value="{!comboEducationValues}"></apex:selectOptions>
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:inputField value="{!candidate.SalaryExpectationAmount__c}" rendered="{!layout.SalaryExpectation__c}"/>
<apex:inputField value="{!candidate.SalaryExpectationCurrency__c}" rendered="{!layout.SalaryExpectation__c}"/>
<apex:inputField value="{!candidate.Motivation__c}" rendered="{!layout.Motivation__c}"/>
</apex:pageBlockSection>

<apex:actionRegion >
<apex:pageBlockSection id="skillBlock" columns="3" title="Skills">
<apex:pageblocksectionitem dataStyle="margin-left:200px;float:left">
<apex:inputText id="txtSkills" value="{!skillSelection}"/><br/>
<script> var txtSkil= document.getElementById("{!$Component.txtSkills}");</script>
</apex:pageblocksectionitem>

<apex:outputpanel style="text-align:center">
<apex:commandButton value=">>" action="{!doSelectSkill}" rerender="skillBlock" style="padding:0px;margin:25px 0px 0px 0px" status="workingstatus">
</apex:commandButton>

<apex:commandButton value="<<" action="{!doDeleteSkill}" rerender="skillBlock" style="padding:0px;margin:3px 0px 0px 0px" status="workingstatus">
</apex:commandButton>
</apex:outputpanel>

<apex:pageblockSectionitem dataStyle="float:left;margin-right:240px">
<apex:selectList value="{!candidateSkillsSelection}" size="5" multiselect="true" required="false" id="chNameList" rendered="true">
<apex:selectOptions value="{!candidateSkillsOptions}" />
</apex:selectList>
</apex:pageblocksectionitem>
<apex:actionstatus startText="{!$Label.any_As_Working}..." id="workingstatus" startStyleClass="status" />
</apex:pageBlockSection>
</apex:actionRegion>

<apex:pageBlockSection title="{!$Label.reg_pbs_cv}" columns="1" rendered="{!layout.CVDisplay__c}">
<apex:pageBlockSectionItem >
<apex:outputLabel value="CV" for="myCV"/>
<apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="myCV"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<!-- ##################### EEO Information Countrywise ###################### -->
<apex:pageBlockSection title="{!$Label.reg_pbs_USEEO}" columns="1" rendered="{!USEEO}">
<apex:outputText escape="false" value="{!layout.EEO_Text__c}"/>
<apex:inputField value="{!candidate.GenderList__c}"/>
<apex:inputField value="{!candidate.Veteran_Status__c}"/>
<apex:inputField value="{!candidate.EthnicityList__c}"/>
<apex:inputField value="{!candidate.Handicapped__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="{!$Label.reg_pbs_UKEEO}" columns="1" rendered="{!UKEEO}">
<apex:outputText escape="false" value="{!layout.EEO_Text__c}"/>
<apex:inputField value="{!candidate.GenderList__c}"/>
<apex:inputField value="{!candidate.UK_Age_Group__c}"/>
<apex:inputField value="{!candidate.UK_Sexual_Orientation__c}"/>
<apex:inputField value="{!candidate.Disability__c}"/>
<apex:inputField value="{!candidate.UK_Ethnic_Origin__c}"/>
<apex:inputField value="{!candidate.English_First_Language__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="{!$Label.reg_pbs_IrelandEEO}" columns="1" rendered="{!IrelandEEO}">
<apex:outputText escape="false" value="{!layout.EEO_Text__c}"/>
<apex:inputField value="{!candidate.GenderList__c}"/>
<apex:inputField value="{!candidate.IE_Marital_Status__c}"/>
<apex:inputField value="{!candidate.IE_Family_Status__c}"/>
<apex:inputField value="{!candidate.IE_Sexual_Orientation__c}"/>
<apex:inputField value="{!candidate.IE_Religion__c}"/>
<apex:inputField value="{!candidate.IE_Age__c}"/>
<apex:inputField value="{!candidate.IE_Disability__c}"/>
<apex:inputField value="{!candidate.IE_Race__c}"/>
<apex:inputField value="{!candidate.IE_Traveller_Community__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="{!$Label.reg_pbs_terms}" columns="1" rendered="{!layout.Terms_and_Conditions__c}">
<apex:outputText escape="false" value="{!layout.Terms_and_Conditions_Text__c}"/>
<apex:pageBlockSectionItem >
<apex:inputCheckbox value="{!tnc}" id="tnc"/>
<apex:outputtext value="{!$Label.reg_text_accept}" ></apex:outputText>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockButtons style="margin-left:200px;float:left" location="bottom">
<apex:commandButton action="{!backToJobDetail}" immediate="true" value="{!$Label.btn_Cancel}"></apex:commandButton>
<apex:commandButton action="{!doRegister}" value="{!$Label.btn_Submit}" id="submit"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</div>
</div>

</apex:page>

 

  Apex (the code is 500 lines for this controller so I'm only pasting the add method. Although the apex code is irrelevant anyway)


 

//select the Skill from the first picklist and add to the second picklist
public PageReference doSelectSkill() {
Boolean isExist = false;
// We cant upload an empty Skill
if(skillSelection != ''){
System.debug('candidate.City__c: '+candidate.City__c);
System.debug('skillSelection: '+skillSelection);
// We check if Skill doesn't already exist
for(SelectOption candiSkill: candidateSkillsOptions){
if(candiSkill.getValue() == skillSelection){
isExist = true;
}
}
if(!isExist)
candidateSkillsOptions.add(new SelectOption(skillSelection, skillSelection));
}
return null;
}

 

If I hazard a guess I'd say the '>' character is being interpreted at a closure of a tag?

 

Thought I'd let you guys know as James Penfold suggested I post to the discussion board.

 

Wes

 

 

 

 I have created a Visualforce page and then set it to render as a pdf to facilitate printing. The page has several images, some that are on the SF server and some that are on our own web server. When the pdf is created, the images on the SF server are generated but the images from our server do not show up. How can I fix this?
  • April 16, 2009
  • Like
  • 0

Hi All,

 

The question relates to the use of custom CSS with Visual Force pages.

 

Say one starts off with an HTML page that includes forms and several other HTML tags, and uses a CSS to control the layout and page look-and-feel.

 

The idea is to convert the HTML/CSS combination into a Visual Force page.

 

We add the corresponding <apex:page> tags, replace the CSS references by the proper <apex:stylesheet> component pointing to the CSS in the static resources, etc.

 

We also replace the forms, input fields, etc. by the corresponding  Visual Force components.

 

When it comes to applying the style to the now Visual Force components, we use the styleClass attribute of each of the Visual Force components. This is the cost/effective way to re-use the existing HTML/CSS design.

 

My question is whether there are any restrictions on how the CSS is defined. For instance, can the CSS include all the different types of selectors -e.g. type, ID, class, etc. ? 

 

For instance, our CSS includes type selectors for the forms as follows:

 

orm.side                                             { font-size:0.8em }
form.side fieldset                                    { margin-top:5px }
form.side fieldset legend                         { font-size:1em; font-weight:bold; padding-bottom:5px }
form.side label                                     { display:block; width:80px; height:10px; padding-top:5px }
form.side .complete                             { float:right; font-size:1.1em; font-weight:bold; display:block; width:193px; height:10px; padding-top:4px }

form.side input, form textarea, form select { float:right; clear:both; border:1px solid #A5B7E0; font-size:1em; padding:0.2em }
form.side input                                     { width:186px }
form.side textarea                                 { width:273px; overflow: auto }
form.side select                                     { width:193px }
form.side select.day                             { clear:none; width:43px }
form.side select.month                         { clear:none; width:93px }
form.side select.year                             { clear:none; width:57px }
form.side input.button                            { width:100px; background-color:#f7a229; font-weight:bold; color:#333333; border:1px solid #a1a1a1 }

form.side error                                     { display: block; clear:both; width: 185px; padding-left:86px; font-size:0.9em; color:#FF0000 }

 

Do we have to use CSS classes instead so that we can then use the styleClass attribute ?.

 

Or we also have ID selector such as:

 

#main_wrapper .inner                            { padding:10px 10px 13px 10px }

 

so do we have to supply the right ID to the Visual Force component where we use that style ?.

 

Generaly speaking, are there any guidelines for how to define a CSS that is compatible with Visual Force pages ?.

 

Thank you very much in advance,

Fernando

Hi all,

 

I think the answer is no, but I'll ask anyway.

 

Is it possible to attach a visualforce page rendered as pdf that uses a custom controller, in a visualforce email template?

 

I saw a post that describes using a component, but I already have the page and the controller built...it seems that it shouldn't take much to make that available as an attachment in an email template. It's kind of silly to have to duplicate things.

 

Are there any workarounds?

 

Thanks,

 

--Alex