Friday, 3 August 2012

If you click on button a text msg should display on vf page

VF
<apex:page controller="temp">
<apex:form >
<apex:commandButton value="Click!" action="{!hai}"> 
<apex:actionSupport event="onclick" reRender="hi"/>
</apex:commandButton>
<apex:outputPanel id="hi">
{!msg}<!--By default it won't display, After clicking on button it will display-->
</apex:outputPanel>
</apex:form>
</apex:page>

APEX
public wih sharing class temp {

    public String msg { get; set; } //By default it has null value

    public PageReference hai() {
        msg = 'Hi'; //After clicking on this button it will display this value
        return null;
    }
}

No comments:

Post a Comment

Labels