15

Yep. It is handling XML escape characters (& " < >), not JavaScript. But really, most non-trival applications will use escape: false and a client-side template system to do any escaping. The default escape: true value is just a safety net to prevent XML code being dumped into the page inadvertently, for trivial applications which fail to escape ...


14

Use $ObjectType global variable, and it could print the Student__c field label like this(please change the object name as needed) <apex:outputLabel value="{!$ObjectType.CustomObject__c.fields.Student__c.Label}" />


12

Based on Ideas: Support inline (data: uri scheme) images for pdf output in VisualForce pages I don't believe it will be possible. The browser usually does the work to convert the base64 encoded image from the pages source. Whatever is doing the PDF rendering for Salesforce doesn't support it. Edit: From @sfdcfox - the PDF rendering is based on Flying Saucer....


11

I think this is the correct type: public List <ApexPages.Component> childComponents {get; set;} Here are the docs.


11

Internal Server Errors are just that; errors that occur in the runtime environment that are not accounted for. For example, the runtime knows how to express a NullPointerException, but it doesn't know how to handle something like a missing translation. You can observe this in action with the following code (as of the time of this answer, anyways): System....


10

When you submit the page, Visualforce will update the OwnerId field of your opportunity object a automatically for you. If you want to use that value elsewhere (e.g. in a save method), you can just reference the value directly: Id newApproverId = a.OwnerId; ... and you can query for the corresponding name (if you need that): String newApproverName = [...


9

These are package components with a namespace prefix. When you enable a developer/isv org to create packages you should pick a namespace. This namespace will be specific to all your custom components (but also custom fields etc) and they will be known as such in any org that deploys your package. You still define and build components the way you're used to: ...


9

From the recipe change the save button from <apex:commandButton value="Save" action="{!save}"/> to <apex:commandLink value="Save" action="{!save}" target="_parent" styleClass="btn" style="text-decoration:none;padding:4px;"> Since commandlink offers a target ...


9

No it's not possible. https://www.salesforce.com/us/developer/docs/pages/Content/pages_html_features_pass_through_attributes.htm last sentence says: Pass-through attributes aren’t supported in dynamic Visualforce.


8

If you want a quick&dirty solution you can generate totals on the fly just using an apex:variable (note that if you need the more complex calculations of the totals it is better to use apex for that): Apex class. Here just reading a data: public with sharing class MyTest { public List<Account> accounts { get; set; } public MyTest(){ ...


8

Not sure if you can do it in pure visualforce. With Apex controller you'll be able to do something like this: String objectName = 'Contact'; String fieldName = 'FirstName'; List<Schema.DescribeSObjectResult> describeSobjectsResult = Schema.describeSObjects(new List<String>{objectName}); // this can accept list of strings, we describe only one ...


8

An additional mechanism to consider in the event that you can't or don't want to use an <apex:commandLink with the target attribute set to _parent is to use a javascript statement to cause the parent page to refresh itself after successful saving. The idea here is that you only render the script panel that executes the page refresh at the time you want ...


8

This Visualforce table can display a table of arbitrary fields from arbitrary SObjects by making use of map syntax: <apex:page controller="MyController"> <apex:pageBlock> <apex:pageBlockTable value="{!items}" var="item"> <apex:repeat value="{!keys}" var="key"> <apex:column value="{!item[key....


7

We have used dynamic components in one piece of code and based on that experience since then have avoided them. When normal Visualforce tags are used, the component tree is part of the serialized view state and that is necessary for the entered values to be displayed under error conditions. (The life cycle is likely to be this or similar.) But you will ...


6

Even if available, I wouldn't recommend testing against the results of .toHtml() - if you've ever looked at the html output of a VF page, you know that there is lots of extra bits added by the system - ids, classes, event handlers - that aren't guaranteed to not change. You are much better off inspecting and asserting against the object returned. ...


6

Dont make things too complicated :) Here i am using no facets and only one inputCheckbox with some css for styling: <apex:page standardController="Account"> <style> .statusStyle { background:url(/img/loading.gif) no-repeat 0 0; padding-left:20px; margin-left:10px; padding-bottom:5px; } </style> <apex:form > &...


6

Try below String formattedStr = 'xx-xx-999999'; String[] strArr = formattedStr.split('-'); Strnig strNumber = ''; Integer myNumber; if(strArr.size() >2){ strNumber = strArr[2]; myNumber = Integer.valueOf(strNumber ); }


6

The (attempted) serialization of the not serializable component can be avoided by making the field transient: public with sharing class Sample3 { private transient Component.Flow.Interview flow; public Component.Flow.Interview getFlow() { return flow; } public Sample3() { flow = new Component.Flow.Interview(); flow....


6

One problem with your code is that LoginHistory can have many entries per UserId but your query of LoginHistory does not define the order and so does not define which entry you get. If you want the latest entry then you need e.g.: LoginHistory src = [ select SourceIp from LoginHistory where UserId =:UserInfo.getUserId() ...


6

If you look at Valid Values for the $Action Global Variable, NewCase is not listed. The correct action is New. Take a look at the Visualforce Developer Guide - Functions. The syntax is {!URLFOR(target, id, [inputs], [no override])}, so the second parameter should definitely be null if you are trying to create a new record. One last problem, you are missing ...


6

The DOM Id values in Visualforce tables include a row number (the :0: in your JavaScript) so your logic needs to incorporate that. The approach that I think works best is to use a CSS class (that has no markup associated with it) instead of the DOM Id: <apex:column headerValue="Delivered Quantity" > <apex:inputtext value="{!dw.quantity}" ...


6

In theory, yes, but realistically, no. The Visualforce reRender engine causes input elements to lose focus, repeated calls in a short period can cause the view state to become disorganized, actionFunction/actionSupport events are about 10 times slower than using AJAX, and workarounds tend to cause the input field to be wiped out, etc. I've tried this before, ...


5

Yes, you can do that, you'll just need to parse the filter fields so that you get the final sObject and use that for your generic sObject. As a reference here's some code that I used to implement .get(fieldName) method that dereferences relationships. Hope it helps. public static Object recursiveGet(sObject record, String field) { if(field.contains('.'...


5

My most likely Visualforce global candidate would be $CurrentPage but this page: <apex:page> {! $CurrentPage.Name } {! $CurrentPage.URL } {! $CurrentPage.Description } </apex:page> produces a: Field Description does not exist. error at compile time. So I think you are probably out of luck (without a controller).


5

styleClass="{!IF(account.Status__c == 'Closed','Class1', IF(account.Status__c == 'In Progress','Class2', 'Class3'))}"


5

The inputfield will have a direct binding to the a.ownerid. This binding is two-directional, so that means two things: When the page loads, the input field will be filled with a.ownerid. The reverse is also true: the value of the input field will be saved to a.ownerid. If you had a commandButton with an action that is executed on the controller, the a....


5

To identify required fields !isDefaultedOnCreate() is required in addition to !result.isNillable() && result.isCreateable(). Map fieldsMap = Schema.SObjectType.Lead.fields.getMap(); for(String key : fieldsMap.keySet()) { Schema.DescribeFieldResult result = fieldsMap.get(key).getDescribe(); if(!result.isNillable() && result.isCreateable() && ...


5

Use layout="pageDirection" in selectCheckboxes for ex. <apex:form > <apex:pageBlock > <apex:pageBlockSection columns="2"> <tr> <apex:selectCheckboxes borderVisible="true" value="{!countries}" styleClass="check" layout="pageDirection"> <apex:selectOptions value="{!items}" /> </...


5

Without resorting to client-side rendering, you can do it like this. First, create a Node class to store nodes and their children. public class Node { public String title { get; set; } public Node[] children { get; set; } } Then create a node Visualforce Component that renders itself and its children: <apex:component> <apex:attribute ...


5

Use a Field Set instead. It was designed with this scenario in mind. Working with Field Sets You can use dynamic bindings to display field sets on your Visualforce pages. A field set is a grouping of fields. For example, you could have a field set that contains fields describing a user's first name, middle name, last name, and business title. If the page is ...


Only top voted, non community-wiki answers of a minimum length are eligible