• Chandan3955
  • 0 Points
  • Member since 2012

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 7




If you try using the isempty() function similar to the list and set methods  for strings then it will throw an error.

Instead use the below syntax


String st = 'Hello'; 
Boolean val= String.isEmpty(st);



Rakesh B


Displaying Calendar on Visualforce page

  • April 24, 2012
  • Like
  • 0

I have a VF page with a save button. i also have a apex:message in a outputpanel


<apex:pageBlockButtons id="blockbuttons">
          <apex:commandButton value="Save"  onclick="performValidation()" id="saveid"/>
          <apex:commandButton value="Cancel" action="{!ok}" />
 <apex:outputpanel id="mess">
 <apex:pageMessages />
  <apex:actionFunction name="save" action="{!Save}" rerender="mess"/>

<script  language="javascript" type="text/javascript">
        function performValidation()
        Do something


 In my controller i am validating some values and throwing an apex messages

           ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Error'));

 This message doesnt seem to be getting displayed. The whole page gets refreshed after the save method is called and probably the messages are displayed. Is there anything that can be done to refresh only the output panel and not the whole page.


Hi All,


I need to use controller class variable in javascript onClick event. For this I used below code.

I am getting NULL value instead of  "samplevariable" which hardcoded in class variable while click Javascript function and m



<apex:page id="pageForm" controller="formController">
    <apex:form id="form">
         <apex:inputHidden value="{!myObject.textdata}" id="hidBusiness"/>
        <apex:commandButton id="btnSave" onclick="javascript&colon;if(!confirmation()) return false;" value="save"/>
       function confirmation()
          var hidBusiness= document.getElementById("{!$Component.hidBusiness}");


Controller class:

public class formController {

  public class MyObject {
     public String textdata = 'samplevariable';

    public String getTextData() { return textdata; }
    public void setTextData(String data) { textdata = data; }


  • November 25, 2011
  • Like
  • 0

I'm building a form in VisualForce, and I can't get the elements of a pageBlockSection to line up. Here's my problem: the dropdown label is not in bold, it is not aligned horizontally with the dropdown, and neither label nor dropdown is aligned with the inputFields below it.


How can I get these to align? It seems I would have to group the label and dropdown somehow.





Here's my visualforce code:



<apex:pageBlockSection title="Account Information" columns="1">

<apex:outputLabel value="Record Type" for="AccountRT"/>
<apex:selectList id="AccountRT" value="{!theAccountRecordTypeID}">
<apex:selectOptions value="{!theAccountRecordTypeOptions}"/>

<apex:inputField value="{!theAccount.name}"/>






  • September 11, 2009
  • Like
  • 0

To auto populate the standard employee number field on user object I have created auto no field and using a trigger on object user on after insert I am updating also . Also as per my requirement I have to also create a contact record on the after insert of user . But is not allowing me to do both the dml operation together.


the code is as follows:

trigger employeenoautopopulate on User (after insert)
     List<Contact> Con = new List<Contact>();
     for(User usr: Trigger.new)
             System.debug('****** condition true');
             Contact con_temp = new Contact();
             con_temp.FirstName = usr.FirstName;
             con_temp.LastName = usr.LastName;
             con_temp.Date_Of_Joining__c = usr.Date_of_Joining__c;
             con_temp.User__c = usr.Id;
             con_temp.OwnerId = usr.Id;
             con_temp.Employee_Number__c = usr.Employee_Number__c;
       insert Con;
        System.debug('****** insert done');
     Set<Id> userid = new Set<Id>();
     for(User usr: Trigger.new)
     User[] usr = [select Id, EmployeeNumber,Employee_Number__c from user where Id in :userid];
     for(Integer i=0;i<usr.size();i++)
        usr[i].EmployeeNumber = usr[i].Employee_Number__c ;
      update usr;
      System.debug('****** update done');


I am getting following exception:


Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger employeenoautopopulate caused an unexpected exception, contact your administrator: employeenoautopopulate: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Contact, original object: User: []: Trigger.employeenoautopopulate: line 20, column 8


  • June 18, 2009
  • Like
  • 0
I know i can do the following to get userid,firstname,lastname by using the static UserInfo class. But there is no method to get Email address. How do i get email address in a controller??

  String userId = UserInfo.getUserId();
String firstName = UserInfo.getFirstName();
String lastName = UserInfo.getLastName();

I know i can do {!$User.Email} but that would only be in the visualforce pages.
How do I get the email address of the logged in user in controller.