• Ashish Biswas
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 21
    Replies
Hi,
I have controler method that takes 2 string parameter as input and accordingly after processing internal logic return a boolean value. For Ex. the below
UserCredentialcheck(){
        if(ud <> UID && pw <> PWD){
           return false;
        }
        else{
            return true;
        }
}

Here UID and PWD are predefined values defined earlier on top of the class.
I would like to call this method from VF page along with the parameter. How shall I acheive this. Please suggest and guide.

Thanks in advance
Ashish
Hi,
I am trying to build a login screen with VF, it has 2 text boxes and a command button. The value entered in th text boxes are setting the value of userid and password properties in my controll class. I have a method define in control class that will return true/false based on the credential. Below is the VF page
<apex:page controller="apxLoginCheck" showHeader="false" sidebar="false">
    <apex:form id="frmLogin">
        <apex:pageBlock title="Enter User details" id="pbLogin">
            <apex:pageBlockSection id="pbc">
                <apex:inputText id="txtID" value="{!UID}"/>
                <apex:inputText id="txtPWD" value="{!PWD}"/>
                
                <apex:commandButton id="btnOk" value="Click to Login" action="{!UserDetails}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>

Below is the Controller
public class apxLoginCheck {
    public String UID{get;  set;}
    public string PWD{get;  set;}
    
    public apxLoginCheck(){

    }
    
    public boolean UserDetails(){
        string newID ='ashish.biswas';
        string newPWD = 'ayushi@23';
        System.debug('B4 conditional check');
        if(UID==newID && PWD==newPWD){
            return true;
            System.debug('Method has been called');
        }
        return false;
    }
}
Can anyone please guide me, how shall I catch the boolean return value in VF on click of command button and call a JS function accordingly.

Thanks in advance
I have written a simple Javascript query as given below. The function are not called on click event. No error being displayed though - need help

<apex:page controller="clsEmployee">
    <apex:form id="frmEmp">
        <apex:pageBlock title="Enter Employee Name" id="pbEmp">
            <apex:pageBlockSection columns="2" id="pbsEmp">
                <apex:inputText label="Employee Name" value="{!empName}" id="txtEmpName"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection columns="2">
                <apex:commandButton value="Save Data"  onclick="CheckField()" action="{!InsertName}"/>
                <apex:commandButton value="Clear Text" onclick="ClearValue()"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
    <script>
        function ClearValue(){
            document.getElimentById('{!$Component.frmEmp.pbEmp.pbsEmp.txtEmpName}').value = '';
            alert("Value cleared");
        }
    
        function CheckField(){
            if(document.getElimentById('{!$Component.frmEmp.pbEmp.pbsEmp.txtEmpName}').value == null ||
                  document.getElimentById('{!$Component.frmEmp.pbEmp.pbsEmp.txtEmpName}').value = ''){
                
                alert("Employee Name can not be empty, Please enter Employee Name!");
            }
        }
    </script>
</apex:page>

I have System Administrator profile, still "Reset Security Token" is not visible for me. I have tried to receive the S.Token inmy mail box by resetting the password, still didnt receive any email. Can anyone suggest the workaround.