Apex Class: OneDigitRandomNumberController
public class OneDigitRandomNumberController {
public Integer iRandomNumber {get;set;}
public void generateOneDigitRandomNumber() {
iRandomNumber = Integer.valueof((Math.random() * 10));
System.debug('One Digit Random Number is'+iRandomNumber);
}
}
Visualforce Page:OneDigitRandomNumber
<apex:page controller="OneDigitRandomNumberController" action="{!generateOneDigitRandomNumber}">
<apex:form >
<b> One Digit Random Number: </b> {!iRandomNumber}<br/>
<apex:commandButton action="{!generateOneDigitRandomNumber}" value="Refresh"/>
</apex:form>
</apex:page>
Output:
public class OneDigitRandomNumberController {
public Integer iRandomNumber {get;set;}
public void generateOneDigitRandomNumber() {
iRandomNumber = Integer.valueof((Math.random() * 10));
System.debug('One Digit Random Number is'+iRandomNumber);
}
}
Visualforce Page:OneDigitRandomNumber
<apex:page controller="OneDigitRandomNumberController" action="{!generateOneDigitRandomNumber}">
<apex:form >
<b> One Digit Random Number: </b> {!iRandomNumber}<br/>
<apex:commandButton action="{!generateOneDigitRandomNumber}" value="Refresh"/>
</apex:form>
</apex:page>
Output:
No comments:
Post a Comment