30

This is what an actionFunction is for <apex:actionFunction name="rerenderTopPanel" rerender="TopPanel" /> <apex:outputPanel id="TopPanel"> </apex:outputPanel> <script type="text/javascript"> function createTabs() { rerenderTopPanel(); } </script>


15

You should be able to control the rendering of the row using <apex:variable>: <apex:variable var="v" value="" rendered="{!NOT(ISBLANK(TheField__c))}"> <tr> <td><apex:outputLabel rendered="if field is not blank"><td> </tr> </apex:variable> <apex:outputPanel> would probably also work as long as ...


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}" />


14

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 ...


13

I'd say "you're doing it wrong" ;) Every time you're hitting a limit like that you should stop and ask if that's really what you need to do. Even if you'd be able to input 50K contacts here - what would usability of such monster be? How is user expected to scroll through this? I'd say a lookup with a search function is really the way to go, that's what it ...


12

I tend to do this directly in HTML with some CSS hackery <tr style="display: {!IF(ISBLANK(Field__c), 'none', 'table-row')};"> <td>Content of your cell</td> </tr>


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.


10

Indeed Visualforce reports the List attribute as only supporting Literal values. Fortunately it is indeed possible to achieve what you want via Dynamic Visualforce. I found an example of this in the Salesforce Visualforce Developers guide here. In the code sample you can see the RelatedList component being created and the List attribute being set dynamically....


10

Just insert two pageBlockTables to the pageBlockSection with parameter columns="2": <apex:pageBlock id="mainBlock"> <apex:pageBlockSection columns="2"> <apex:pageBlockTable value="{!alist}" var="a"> <apex:column value="{!a.name}"/> </apex:pageBlockTable> <apex:pageBlockTable value="{!...


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 = [...


10

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....


9

When you fire an action via a button or command link it submits the entire form, meaning all the required fields in the form are checked, so you're right in saying that targetted re-rendering would not solve your problem. The key is to split up your fields into logical groups, whereby when firing a specific action only the fields you want are included. You ...


9

Long introduction talk This would probably be much easier for you if you have ever played with "Dynamic Apex" and "Dynamic SOQL". Sometimes we need to work on the level of generic sObjects rather than concrete Account, User or Custom_Object__crecords. Maybe running this in Execute Anonymous will help: Map<String, Schema.SObjectField> M = Schema....


9

I have developed a solution, there are shortcomings that I hope someone knows the solution too. The following code snippet allows loading of a visualforce component onto a page dynamically. public class MyController { public transient ApexPages.Component headerComponent { get; private set; } public MyController() { Type t = Type.forName('...


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 attribute I make use of it and make the command link exactly like the button ...


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

This is impossible to do even with regular visualforce. The following page will give you the same error at compile-time that you see at runtime with dynamic vf. <apex:page> {!$ObjectType.Account.Fields.Industry.PicklistValues} </apex:page> I ran into this issue about a year ago and there is no workaround except returning the list of ...


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

Buried in the order of execution for visualforce postback requests section of the docs is this nugget of information: During a postback request, the view state is decoded and used as the basis for updating the values on the page. Note: A component with the immediate attribute set to true bypasses this phase of the request. In other words, the action ...


6

You can create Fieldset on that object and then iterate that field set on your VF page. You can iterate field set like this on VF page - <apex:repeat value="{!ACTFields}" var="f" > <apex:inputField value="{!testDetails[f.fieldPath]}" required="{!OR(f.required,f.dbrequired)}" /> ...


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

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() ...


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