You need to sign in to do that
Don't have an account?
Neil Kim
Commandbutton/onclick is clicked automatically
Hi. It worked some hours ago. Suddenly it do abnormally..
Could you please check it for me? why is this happened?
Here is visualforce page form
and controller
When I loaded visualforce page, getsendSMS function is called right away.
I'm not click commandbutton..
For avoiding this error, I insert If statement...
Is there any clue?
Please help.
Could you please check it for me? why is this happened?
Here is visualforce page form
<apex:page showHeader="true" sidebar="true" controller="Test"> <apex:form id="fr1"> <apex:inputTextarea id="text" value="{!text}" cols="4" style="width:100%; height:80px"/><br/> From : <apex:outputText value="+565656"/><br/> To : <apex:inputText id="to" value="{!to}" style="width:80%"/> <apex:commandButton onClick="{!sendSMS}" value="Send Message" immediate="false"/> </apex:form> </apex:page>
and controller
public with sharing class Test { public TwilioTest() {} public String text {get; set;} public String to {get; set;} public void getsendSMS(){ String ACCOUNT_SID = 'AAA'; String AUTH_TOKEN = 'VVV'; if( to != null ){ <------ what I added to avoid the error. String phone_to = '+82'+to.leftPad(1); TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN); Map<String,String> properties = new Map<String,String> { 'To' => phone_to, 'From' => '+AAAA, 'Body' => text }; TwilioMessage message = client.getAccount().getMessages().create(properties); } } }
When I loaded visualforce page, getsendSMS function is called right away.
I'm not click commandbutton..
For avoiding this error, I insert If statement...
Is there any clue?
Please help.
I think initially you had javascript with ActionSupport or AcionFunction. You can change OnClick event to execute action in CommandButton. Please find below modified code:
VF Page:
Controller:
All Answers
I think initially you had javascript with ActionSupport or AcionFunction. You can change OnClick event to execute action in CommandButton. Please find below modified code:
VF Page:
Controller:
Thanks. What you said is exactly right.
Really helpful!.
Best Regards,
BALAJI