Browse Month: May 2013

Get related list without Action Column in visualforce page


When you want to display related list on visualforce page, you can use <apex:relatedList>
tag, and it is very easy for ex:

<apex:page standardController="MyMasterObject__c">
	<apex:relatedList list="MyChildObjects__r" />

but this will display all the columns from related list including “Action” column and many times
we don’t want to display this column.

so to access your related list in the visualforce page without adding columns such as “Action“;
for example to access your products from Opportunity Page then use <apex:repeat> or <apex:dataTable>
tags from visualforce. for example here is a code to access your Estimate products which is related list
on Estimate page from visualforce page:

<apex:dataTable value="{!Estimate__c.EstimateOrder__r}" var="eorl">
<apex:column headerValue="Product" width="10%">
<apex:outputText value="{!eorl.Product_Code__c}"></apex:outputText>
<apex:column headerValue="Width" width="10%">
<apex:outputText value="{!eorl.Width__c}"></apex:outputText> </apex:column>
<apex:column headerValue="Height" width="10%">
<apex:outputText value="{!eorl.Height__c}"></apex:outputText> </apex:column>

This above code will display all your related list values on visualforce page without any column such as “Action
in a list.
To use <apex:repeat> replace <apex:dataTable> with <apex:repeat> and other fields are same.

Hope this will helpful for you.




Custom Send Email button on custom Objects


If you want to add a custom button to send email on custom object then follow below mentioned


1. Create Custom button on custom object;

2. in the content source, select URL;

3. in the value section, add following url{!Estimate__c.Bill_To_NameId__c}&rtype=003&doc_id=00Pi0000000OluX&retURL=/{!Estimate__c.Id}?srPos=0&srKp=00T

where Estimate__c.BillToNameId__c is the contact Id to whom you want to send email


Estimate__c.Id is the return URL of your custom object


java.lang.OutOfMemoryError: Java heap space

add line to or catalina.bat:

export CATALINA_OPTS=”-Xms512M -Xmx1024M”

a) The -Xmx argument defines the max memory size that the heap can reach for the JVM. A low value can cause OutOfMemoryExceptions or a very poor performance if your program’s heap memory is reaching the maximum heap size.
b) The -Xms argument sets the initial heap memory size for the JVM. This means that when you start your program the JVM will allocate this amount of memory instantly. access denied ( host connect,resolve)

The Simple solution is
:search catalina.policy file and edit green line as

// Precompiled JSPs need access to this system property.
permission java.util.PropertyPermission”org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER”,”read”;

permission “*”, “connect”;
permission “*”, “connect”;
permission “*”, “connect”;

permission java.lang.RuntimePermission “accessDeclaredMembers”;
permission java.lang.RuntimePermission “”;
permission java.lang.RuntimePermission “stopThread”;
permission java.lang.RuntimePermission “modifyThread”;
permission java.lang.RuntimePermission “modifyThreadGroup”;

The possible ways to connect to the host are

The “listen” action is only meaningful when used with “localhost”. The “resolve” action is implied when any of the other actions are present. The action “resolve” refers to host/ip name service lookups.

You can also put your Host_Address instead *.
* will allow to you connect any hostAddress as well localhost
more info :

Learning The Many Advantages of PHP

PHP, which is short for Hypertext Preprocessor, is an open source server side programming language available at free of cost that can be easily obtained from the market. It has a coding style that is quiet and easy to understand and is usually very proficient on multi-platforms like Windows, Linux, and UNIX and other more.

Today, PHP is one of the most popular server side scripting languages working. It is basically utilized for making dynamic web pages that correspond with the user offering customized information. Aside from being fast, stable, secure and easy to use, PHP offers other numerous advantages that had most developers using it.

Before even starting any website, several aspects are considered including:

  • Website design
  • Web developing
  • Web hosting
  • Maintenance
  • Flexibility
  • Usability
  • Scalability
  • Easiness of handling and
  • Overall allocated budget

Advantages of PHP

PHP is an open source

As previously mentioned, PHP is readily available and totally free for you to use. If you have been planning to hire PHP developers who have excellent background in C and Java, you will notice how easy it is for them to use PHP. And truth be told, PHP is a lot simpler compared to the rest giving you assurance of outstanding outcomes. The chief PHP source repository is rich with modules and interfaces that users have written and donated. With that source, you can gladly search for modules for flash movies, PDF files, calendars and other more.

PHP is cross-platform.

  • PHP runs on just about every platform available enabling it to operate across different operating systems. It works excellently on UNIX, Macs and Windows versions.

PHP has connective abilities.

  • It uses a modular system of extensions to cross point with a collection of libraries like graphics, XML, encryption and other more. Furthermore, programmers can stretch out PHP by writing their own extensions and gathering them into the executable or they can make their own executable and load it with the use of PHP’s dynamic loading mechanism.

PHP offers a community.

  • You can easily share with other people in the PHP community since it is an open source project. If you are searching for a specific script, chances are another user has already made something similar. You can simply check within the PHP community for availability. In the same way, if you have made a function that others can benefit, be sure to post the code for others.
  • The PHP community is a huge one. Because of its popularity, there are many PHP developers, contributors, users and employers that gladly offer PHP jobs. You can easily find people who are looking for a PHP developer job.

PHP is fast and convenient.

  • It functions well with other software available and is known to be fast. PHP is also relatively stable. And because it is an open source, anyone on the PHP community can fix the bug.
  • When it comes to security, PHP offers several levels of security to avert malicious attacks.
  • PHP does not put exertion on servers because it utilizes its own inherent memory space that reduces the workload from the servers. The processing speed impulsively improves. Its script is also improved enabling the server’s job a lot easier.
  • Data handling in PHP is convenient because the programmers can simply store data, serialize, create cookies, calculate viewer by cookies and sessions and has exceptional file management system.
  • Because PHP is very fast to develop, it assures that there is consequently a quick turnaround time. When you employ PHP developers, their efficacy brings you an online answer that you were most likely searching for since a long time.

PHP is pre-configured

  • More often, hosting services have a “ready to use” PHP setup. With this, it will not require any distinctive configuration. But you can always modify if you wish to put up a high security kind of website.


Display Facebook likes / Shares PHP function

The Code
Below is a super simple function that retrieves a JSON feed of comments, likes and shares for any URL you provide.

function facebook_shares($url){

$fql = “SELECT url, normalized_url, share_count, like_count, comment_count, “;
$fql .= “total_count, commentsbox_count, comments_fbid, click_count FROM “;
$fql .= “link_stat WHERE url = ‘”.$url.”‘”;

return json_decode($fb_json);


How to use

$fb = facebook_shares(‘’);

// facebook share count
echo $fb[0]->share_count;

// facebook like count
echo $fb[0]->like_count;

// facebook comment count
echo $fb[0]->comment_count;

Show Google Plus’s – PHP function

It’s worth pointing out you must have CURL enabled on your web server, I believe it’s enabled by default on PHP5 setups. Also the Key below Isn’t a unique API key you must leave the key as is to ensure the code works properly.

function gplus_shares($url){

// G+ DATA
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “”);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, ‘[{“method”:”pos.plusones.get”,”id”:”p”,
“params”:{“nolog”:true,”id”:”‘ . $url . ‘”,”source”:”widget”,”userId”:”@viewer”,”groupId”:”@self”},
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-type: application/json’));

$result = curl_exec ($ch);
curl_close ($ch);
return json_decode($result, true);


Example Usage

$gplus = gplus_shares(‘’);

echo $gplus[0][‘result’][‘metadata’][‘globalCounts’][‘count’];

Voice Recording in Android

Put below code into your main Activity.

private static final String AUDIO_RECORDER_FILE_EXT_3GP = ".3gp";
private static final String AUDIO_RECORDER_FILE_EXT_MP4 = ".mp4";
private static final String AUDIO_RECORDER_FOLDER = "AudioRecorder";
private MediaRecorder recorder = null;
private int currentFormat = 0;
private int output_formats[] = { MediaRecorder.OutputFormat.MPEG_4, MediaRecorder.OutputFormat.THREE_GPP };
private String file_exts[] = { AUDIO_RECORDER_FILE_EXT_MP4, AUDIO_RECORDER_FILE_EXT_3GP };

public void onCreate(Bundle savedInstanceState) {

private void setButtonHandlers() {
((Button) findViewById(;
((Button) findViewById(;
((Button) findViewById(;

private void enableButton(int id, boolean isEnable) {
((Button) findViewById(id)).setEnabled(isEnable);

private void enableButtons(boolean isRecording) {
enableButton(, !isRecording);
enableButton(, !isRecording);
enableButton(, isRecording);

private void setFormatButtonCaption() {
((Button) findViewById( + " (" + file_exts[currentFormat] + ")");

private String getFilename() {
String filepath = Environment.getExternalStorageDirectory().getPath();
File file = new File(filepath, AUDIO_RECORDER_FOLDER);
if (!file.exists()) {
return (file.getAbsolutePath() + "/" + System.currentTimeMillis() + file_exts[currentFormat]);

private void startRecording() {
recorder = new MediaRecorder();
try {
} catch (IllegalStateException e) {
} catch (IOException e) {

private void stopRecording() {
if (null != recorder) {
recorder = null;

private void displayFormatDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
String formats[] = { "MPEG 4", "3GPP" };
builder.setTitle(getString(R.string.choose_format_title)).setSingleChoiceItems(formats, currentFormat, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
currentFormat = which;

private MediaRecorder.OnErrorListener errorListener = new MediaRecorder.OnErrorListener() {
public void onError(MediaRecorder mr, int what, int extra) {
Toast.makeText(AudioRecordingActivity.this, "Error: " + what + ", " + extra, Toast.LENGTH_SHORT).show();

private MediaRecorder.OnInfoListener infoListener = new MediaRecorder.OnInfoListener() {
public void onInfo(MediaRecorder mr, int what, int extra) {
Toast.makeText(AudioRecordingActivity.this, "Warning: " + what + ", " + extra, Toast.LENGTH_SHORT).show();

private View.OnClickListener btnClick = new View.OnClickListener() {
public void onClick(View v) {
switch (v.getId()) {
case {
Toast.makeText(AudioRecordingActivity.this, "Start Recording", Toast.LENGTH_SHORT).show();
case {
Toast.makeText(AudioRecordingActivity.this, "Stop Recording", Toast.LENGTH_SHORT).show();
case {

How to Add Smiley/Emojis in Edittext? :-


import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.Html;
import android.text.Html.ImageGetter;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Emoji extends Activity implements OnClickListener {
EditText edttxtemoji;
Button btnsubmit, btnselectemoji;
TextView txtviewdisplay;

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
edttxtemoji = (EditText) findViewById(;
btnsubmit = (Button) findViewById(;
btnselectemoji = (Button) findViewById(;
txtviewdisplay = (TextView) findViewById(;

public void onClick(View v) {
// TODO Auto-generated method stub
if (v == btnsubmit) {
} else if (v == btnselectemoji) {
Intent in = new Intent(this, Select_Emoji_Activity.class);

CharSequence cs;
Custom_List_Emoji cstlistemoji;
int index;

protected void onRestart() {
// TODO Auto-generated method stub

cstlistemoji = new Custom_List_Emoji(this);
SharedPreferences myPrefs = this.getSharedPreferences("myPrefs",
index = myPrefs.getInt("key1", 0);
System.out.println("Pref Data index is:- " + index);
ImageGetter imageGetter = new ImageGetter() {
public Drawable getDrawable(String source) {
Drawable d = getResources().getDrawable(
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
return d;
cs = Html.fromHtml(
"", imageGetter, null);
System.out.println("cs is:- " + cs);
} :-


import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class Select_Emoji_Activity extends Activity implements OnItemClickListener{
ListView lstviewemojis;
Custom_List_Emoji cstlistemoji;
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
cstlistemoji=new Custom_List_Emoji(this);
public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
SharedPreferences myPrefs = this.getSharedPreferences("myPrefs", MODE_WORLD_READABLE);
SharedPreferences.Editor prefsEditor = myPrefs.edit();
System.out.println("Emoji is:- " +arg2);
prefsEditor.putInt("key1", arg2);

Custom_List_Emoji :-


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class Custom_List_Emoji extends BaseAdapter {

public Activity context;
public LayoutInflater inflater;

public Custom_List_Emoji(Activity context) {
// TODO Auto-generated constructor stub
this.context = context;
this.inflater = (LayoutInflater) context

public int getCount() {
// TODO Auto-generated method stub
return emojis.length;

public Object getItem(int position) {
// TODO Auto-generated method stub
String temp = emojis[position];
return temp;

public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;

TextView txtview1;
ImageView image;

public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if (convertView == null) {
convertView = inflater.inflate(R.layout.custom_emojis, null);
txtview1 = (TextView) convertView.findViewById(;
image = (ImageView) convertView.findViewById(;

return convertView;


public final int[] images = new int[] { R.drawable.emo_im_happy,
R.drawable.emo_im_sad, R.drawable.emo_im_winking,
R.drawable.emo_im_tongue_sticking_out, R.drawable.emo_im_surprised,
R.drawable.emo_im_kissing, R.drawable.emo_im_yelling,
R.drawable.emo_im_cool, R.drawable.emo_im_money_mouth,
R.drawable.emo_im_foot_in_mouth, R.drawable.emo_im_embarrassed,
R.drawable.emo_im_angel, R.drawable.emo_im_undecided,
R.drawable.emo_im_crying, R.drawable.emo_im_lips_are_sealed,
R.drawable.emo_im_laughing, R.drawable.emo_im_wtf };
public final String[] _strEmoticonLabels = new String[] { "Happy", "Sad",
"Winking", "Tongue sticking out", "Surprised", "Kissing",
"Yelling", "Cool", "Money Mouth", "Foot in mouth", "Embarrased",
"Angel", "Undecided", "Crying", "Lips are sealed", "Laughing",
"Confused" };
public final String[] emojis = new String[] { ":-)", ":-(", ";-)", ":-P",
"=-O", ":-*", ":O", "B-)", ":-$", ":-!", ":-[", "O:-)", ":-\",
":'(", ":-X", ":-D", "o_O" };

Draw flexible lines on touches Moved in iphone View Based application

// .h ———File
CGPoint lastPoint;
UIImageView *drawImage;
BOOL mouseSwiped;
int mouseMoved;

//.m ———File
– (void)viewDidLoad
[super viewDidLoad];

drawImage = [[UIImageView alloc] initWithImage:nil];
drawImage.frame = self.view.frame;
[self.view addSubview:drawImage];
self.view.backgroundColor = [UIColor yellowColor];

– (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
UITouch *touch = [touches anyObject];
if ([touch tapCount] == 2)
drawImage.image = nil;

lastPoint = [touch locationInView:self.view];
lastPoint.y -= 20;

– (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.view];
currentPoint.y -= 20;

[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();

lastPoint = currentPoint;