Monday, 4 February 2013

How to change the Date format in Visual force:-




Hi Guys ,Now i am going to tell, Changing the date format in VF page.


Example:- Here i need Today Date in this format " February 15th, 2013"


Here we go like,

<apex:outputText value="{0,date,MMMMMMMM d'th', yyyy}">
                    <apex:param value="{!Today()}" />
 </apex:outputText>


 If Date/Datetime field taking from Apex . if you want to display above format.


<apex:outputText value="{0,date,MMMMMMMM d'th', yyyy}">
                    <apex:param value="{!variablename}" />
 </apex:outputText>

Thursday, 31 January 2013

Working on Java script.


Hi guys, Here i did some Java script stuff , i am sharing with you guys,


Hi Guys Here we have a scenario, Create a VF page with two buttons. Those are
"Open in PDF" and "Open in Word" ,
When we click on any button the vf page should open in Pdf/Word format Based on Button click.
Here we go..



<apex:page controller="some class" showHeader="false" renderAs="{!ispdf}" contentType="{!isword}">

.........
......
.........


<center><br/>
    <apex:form rendered="{!isvf}" id="frm1">

        <apex:commandButton reRender="frm1" action="{!donothing}" value="Open in PDF" onclick="window.open('/apex/vf page name?id={!$CurrentPage.parameters.id}&type=pdf','_blank')"/>

        <apex:commandButton reRender="frm1" action="{!donothing}" value="Open in Word"  onclick="window.open('/apex/vf page name?id={!$CurrentPage.parameters.id}&type=word','_blank')"/>

   </apex:form>
  </center>

</apex:page>



How to get user id in Java script Buttons.
alert('{!$user.Id}');

How to get profile id in Java script Buttons.
alert('{!$Profile.Id}');


How to open a Vf page in a new Window using java script button.

{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}

var url="/apex/vf page name ?id={!Opportunity.Id}";

if('{!$Profile.Id}'=='some id' ||'{!$Profile.Id}'=='some id') // it should work for two profiles only
{
      newWin=window.open(url, 'Popup','height=800,width=1100,left=100,top=100,Right=100');
}


How to write code for save & close operation done in one button click.


<apex:commandButton action="{!save}" value="Save" rerender="AJAXTest" status="AJAXStatus"/> 
<apex:actionStatus startText="(Saving...)" stopText="" onStop="window.top.close();" ID="AJAXStatus"/>

=========================================