You need to sign in to do that
Don't have an account?
iyappan kandasamy 4
on successfull login redirect to new vf page
Hi ,
I am having one user object there having username and password.
In one vf page i am having username field and password field . Oncve filling ythe username and password if click on login button then i want to redirect to oyher page if ita a successfull login .
please find the below code and help on this
VF PAGE
<apex:page controller="uloginController" showHeader="false" sidebar="false" standardStylesheets="true">
<apex:form >
<p><b>Login Page</b><br /></p>
<apex:outputPanel id="getInput" rendered="{!getInput}">
<p><b>UserName</b><br/>
<apex:inputText required="true" id="username" styleClass="form-control" value="{!userName}"/></p>
<p><b>Password</b><br/>
<apex:inputSecret required="true" id="password" styleClass="form-control" value="{!password}" /></p>
<apex:commandButton value="Login" styleClass="btn btn-success btn-sm" action="{!searchUserName}" />
<apex:outputText >{!ischeck}</apex:outputText>
<apex:commandButton value="ClearButton" onclick="this.form.reset();return false;" />
<apex:outputLink > ForgetPassword<br/></apex:outputLink>
<apex:outputLink value="https://c.ap5.visual.force.com/apex/NewUserLogin"> Create new Account<br/></apex:outputLink>
</apex:outputPanel>
<apex:outputText >{!ischeck}</apex:outputText>
</apex:form>
</apex:page>
CONTROLLER
public with sharing class uloginController {
public String userName {get; set;}
public String password {get; set;}
public Boolean getInput {get;set;}
public Boolean ischeck {get;set;}
public List<User__c> ObjList{get; set;}
public uloginController() {
getInput = True;
ObjList = new List<User__c>();
}
public void searchUserName() {
getInput = False;
ObjList = [SELECT Id, Name,Password__c FROM User__c WHERE Name =: userName];
if(!ObjList.isEmpty()){
ischeck = true;
}else{
ischeck = false;
}
}
}
I am having one user object there having username and password.
In one vf page i am having username field and password field . Oncve filling ythe username and password if click on login button then i want to redirect to oyher page if ita a successfull login .
please find the below code and help on this
VF PAGE
<apex:page controller="uloginController" showHeader="false" sidebar="false" standardStylesheets="true">
<apex:form >
<p><b>Login Page</b><br /></p>
<apex:outputPanel id="getInput" rendered="{!getInput}">
<p><b>UserName</b><br/>
<apex:inputText required="true" id="username" styleClass="form-control" value="{!userName}"/></p>
<p><b>Password</b><br/>
<apex:inputSecret required="true" id="password" styleClass="form-control" value="{!password}" /></p>
<apex:commandButton value="Login" styleClass="btn btn-success btn-sm" action="{!searchUserName}" />
<apex:outputText >{!ischeck}</apex:outputText>
<apex:commandButton value="ClearButton" onclick="this.form.reset();return false;" />
<apex:outputLink > ForgetPassword<br/></apex:outputLink>
<apex:outputLink value="https://c.ap5.visual.force.com/apex/NewUserLogin"> Create new Account<br/></apex:outputLink>
</apex:outputPanel>
<apex:outputText >{!ischeck}</apex:outputText>
</apex:form>
</apex:page>
CONTROLLER
public with sharing class uloginController {
public String userName {get; set;}
public String password {get; set;}
public Boolean getInput {get;set;}
public Boolean ischeck {get;set;}
public List<User__c> ObjList{get; set;}
public uloginController() {
getInput = True;
ObjList = new List<User__c>();
}
public void searchUserName() {
getInput = False;
ObjList = [SELECT Id, Name,Password__c FROM User__c WHERE Name =: userName];
if(!ObjList.isEmpty()){
ischeck = true;
}else{
ischeck = false;
}
}
}
public with sharing class uloginController {
public String userName {get; set;}
public String password {get; set;}
public Boolean getInput {get;set;}
public Boolean ischeck {get;set;}
public List<User__c> ObjList{get; set;}
public uloginController() {
getInput = True;
ObjList = new List<User__c>();
}
public PageReference searchUserName() {
getInput = False;
ObjList = [SELECT Id, Name,Password__c FROM User__c WHERE Name =: userName];
if(!ObjList.isEmpty()){
ischeck = true;
PageReference page = new PageReference('/apex/registration');
return page.setRedirect(true);
}else{
ischeck = false;
return null;
}
}
}
If it is First time user, then the above code is correct , but now if the user is already existing candidate I want to only view/edit/save his profile.
Please guide me on the changes in the above code for my scenario. Thanks in advance.
It would be great if u please help on this. Thanks
I believe after Registration you may be storing his/her profile details to some other custom object or if you can tell me what you do after the Registration process is done. Whatever you do you can do something in the code as metion below with the comments
And one more guidance needed from you.
In the registration form and in the Edit profile form...I have a field "Job descirtion" and another custom object "JobRecruiter" also I having the field "Job description", so if the both the job description matches(Eg: in the registration & Edit profile "Job descirtion" =Salesforce and in the jobrecruiter also job description = Salesforce)then the candidate is sheduled for interview and it has to go Interview confirmation Page.Please guide me on this....Thanks.
And
in the below apex class code ...Only first time the valid login user will come to registration page else go to edit/profile page.
public with sharing class uloginController
{
public String userName{get; set;}
public String RegName{get;set;}
public String rskill{get;set;}
public String pskill{get;set;}
public String EditPName{get; set;}
public String password {get; set;}
public Boolean getInput {get;set;}
public Boolean ischeck {get;set;}
public List<User__c> ObjList{get; set;}
public List<Registration__c> Reg{get;set;}
public List<EditProfile__c> prf{get;set;}
public uloginController() {
getInput = True;
ObjList = new List<User__c>();
}
public PageReference searchUserName() {
getInput = False;
ObjList = [SELECT Id, Name,Password__c FROM User__c WHERE Name =: userName];
prf = [SELECT Id, Name,SkillSet__c FROM EditProfile__c WHERE Name =: EditPName and SkillSet__c=:pskill];
if(!ObjList.isEmpty())
{
ischeck = true;
//PageReference page = new PageReference('/apex/registration');
//return page.setRedirect(true);
PageReference page = null;
//Reg = [SELECT Id, Name,SkillSet__c FROM Registration__c WHERE Name =: RegName and SkillSet__c=:rskill];
List<Registration__c> Reg = [SELECT Id FROM Registration__c WHERE RegisterUser__c = :ObjList.get(0).Id];
if(!Reg.isEmpty())
//if(userName==RegName)
{
page = new PageReference('/apex/EditProfile');
return page.setRedirect(true);
}
else
{
page= new PageReference('/apex/registration');
return page.setRedirect(true);
}
}else{
ischeck = false;
userName = '';
password = '';
return null;
}
}
}
So please tell me in the above same apex class what modifications I have to do for both the above requirements. ...Thanks in Advance.
and also in the below visual force page code...Im trying to do "User Name" and "Password" as the required fields and I have written the
javascript validation but it is not working ...So, please guide me on this also please...
<apex:page controller="uloginController" showHeader="false" sidebar="false" standardStylesheets="true">
<script type= "text/javascript">
function validate()
{
if(document.getElementById('{!$Component.username}').value=='')
{
alert("User Name is Mandatory");
}
}
</script>
<apex:form >
<!--<p><b>Login Page</b><br /></p>-->
<apex:pageBlock title="Login Page - Welcome TO Online Job Portal">
<apex:pageBlockSection >
<table>
<tr>
<td>
<!--<apex:outputPanel id="getInput" rendered="{!getInput}">-->
<p><b>UserName</b><br/>
<apex:inputText id="username" styleClass="form-control" value="{!userName}" /></p>
<!--</apex:outputPanel>-->
</td>
</tr>
<tr>
<td>
<p><b>Password</b><br/>
<apex:inputSecret id="password" styleClass="form-control" value="{!password}" /></p>
</td>
</tr>
</table>
</apex:pageBlockSection>
<!--<apex:pageblockbuttons >-->
<!--<apex:commandButton value="Login" styleClass="btn btn-success btn-sm" rerender="getInput" action="{!searchUserName}" onclick="validate();" />-->
<apex:commandButton value="ClearButton" onclick="this.form.reset();" />
<apex:outputLink > ForgetPassword<br/></apex:outputLink>
<apex:outputLink value="https://c.ap5.visual.force.com/apex/NewUserLogin"> Create new Account<br/></apex:outputLink>
<!--</apex:outputPanel>-->
<!--</apex:pageblockbuttons>-->
</apex:pageBlock>
</apex:form>
</apex:page>
Please guide me in the above issues ...please
thanks in advance...
Controller
Visualforce page
Thanks Abdul For your response...But in the apex class I'm getting error as "Variable does not exits" and even i tried to rectify it but no response...
So the tables what I have is
Table Name:Registration
Field1:Name
Field2:SkillSet__c(this is the job description field)
Table2 Name:EditProfile
Field1:Name
Field2:SkillSet__c(this is the job description field)
Table3 Name:JobRecruiter__c
Field1:Name
Field2:SkillSet__c(this is the job description field)
So in all the 3 tables if the field "Skillset"(i.e. the job description) matches then the candidate is selected for Interview else rejected. Please can u help me out the changes in the above same apex class please....thanks.
public with sharing class uloginController
{
public String userName{get; set;}
public String RegName{get;set;}
public String rskill{get;set;}
public String pskill{get;set;}
public String EditPName{get; set;}
public String password {get; set;}
public Boolean getInput {get;set;}
public Boolean ischeck {get;set;}
public List<User__c> ObjList{get; set;}
public List<Registration__c> Reg{get;set;}
public List<EditProfile__c> prf{get;set;}
List<JobRecruiter__c> jobRec{get;set;}
public uloginController() {
getInput = True;
ObjList = new List<User__c>();
}
public PageReference searchUserName()
{
getInput = False;
ObjList = [SELECT Id, Name,Password__c FROM User__c WHERE Name =: userName];
prf = [SELECT Id, Name,SkillSet__c, JobDescription__c FROM EditProfile__c WHERE Name =: EditPName and SkillSet__c=:pskill];
if(!ObjList.isEmpty())
{
ischeck = true;
PageReference page = null;
List<Registration__c> Reg = [SELECT Id, JobDescription__c FROM Registration__c WHERE RegisterUser__c = :ObjList.get(0).Id];
if(Reg == null)//For the first time login user
page= new PageReference('/apex/registration');
List<JobRecruiter__c> jobRec = [SELECT Id, JobDescription__c FROM JobRecruiter__c WHERE SkillSet__c=:pskill];
if(page == null && !jobRec.isEmpty() && prf.JobDescription__c == 'Salesforce' && prf.JobDescription__c == Reg.JobDescription__c && Reg.JobDescription__c == jobRec.JobDescription__c)
page = new PageReference('/apex/InterviewConfirmationPage');
if(page == null)
page = new PageReference('/apex/EditProfile');
return page.setRedirect(true);
}else{
ischeck = false;
userName = '';
password = '';
return null;
}
}
}
hi
this is the schema of my objects.Any suggestions please. And also in the above code line number 36....that is in the line
"if(page == null && !jobRec.isEmpty() && prf.SkillSet__c == 'Salesforce' && prf.SkillSet__c == Reg.SkillSet__c c && Reg.SkillSet__c == jobRec.SkillSet__c )" ......I copied the fields straightly...into the code so no case issues. Please any suggestions and guidance from you.. thanks
Reg.SkillSet__c c && Reg.SkillSet__c == jobRec.SkillSet__c )"
1.I have a new user ,so it goes to New Registration form and get saved , now how to get this Registrations user to the main User table?
2.In my apex class, i have written code for insert(saving) ,when the name is saved it is getting saved but when i m giving the same name
it is throwing error and again the name is getting saved?
or the same second question ,How to remove duplicates...that is the apex class should not allow the duplicates?
3.Want to bring the job recruiters records as a picklist in the edit profile page Eg: Job Recruiter Name:TCS and Skill set = Java. in the visual force page from another object
and then do comparison.....so,then my skillset and TCS skillset matches then the candidate is scheduled for interview.
Im using the above same code
public with sharing class uloginController
{
public String userName{get; set;}
public String RegName{get;set;}
public String rskill{get;set;}
public String pskill{get;set;}
public String jrskill{get;set;}
public String EditPName{get; set;}
public String password {get; set;}
public Boolean getInput {get;set;}
public Boolean ischeck {get;set;}
public List<User__c> ObjList{get; set;}
public List<Registration__c> Reg{get;set;}
public List<EditProfile__c> prf{get;set;}
public List<JobRecruiter__c> jobRec{get;set;}
public uloginController() {
getInput = True;
ObjList = new List<User__c>();
}
//Code For saving the new registration record
Registration__c rg=new Registration__c();
public Registration__c getrg()
{
return rg;
}
public PageReference save()
{
insert rg;
return null;
}
//Code For saving the EditProfile record
EditProfile__c ep=new EditProfile__c();
public EditProfile__c getep()
{
return ep;
}
public PageReference save1()
{
insert ep;
return null;
}
public PageReference searchUserName()
{
getInput = False;
ObjList= [SELECT Id, Name,Password__c FROM User__c WHERE Name =: userName];
//prf = [SELECT Id, Name,SkillSet__c FROM EditProfile__c WHERE Name =: EditPName and SkillSet__c=:pskill];
prf = [SELECT Id, Name,SkillSet__c FROM EditProfile__c WHERE Name =: EditPName];
if(!ObjList.isEmpty())
{
ischeck = true;
PageReference page = null;
List<Registration__c> Reg = [SELECT Id, SkillSet__c FROM Registration__c WHERE RegisterUser__c = :ObjList.get(0).Id and SkillSet__c=:rskill];
//Registration__c[] Reg = [SELECT Id, SkillSet__c FROM Registration__c WHERE RegisterUser__c = :ObjList.get(0).Id and SkillSet__c=:rskill];
if(Reg == null)//For the first time login user
page= new PageReference('/apex/registration');
List<JobRecruiter__c> jobRec= [SELECT Id, SkillSet__c FROM JobRecruiter__c WHERE SkillSet__c=:jrskill];
//JobRecruiter__c[] jobRec= [SELECT Id, SkillSet__c FROM JobRecruiter__c WHERE SkillSet__c=:pskill];
//prf = [SELECT Id, Name,SkillSet__c FROM EditProfile__c WHERE Name =: EditPName and SkillSet__c=:pskill];
if(page == null && !jobRec.isEmpty() && prf.get(0).SkillSet__c == Reg.get(0).SkillSet__c && Reg.get(0).SkillSet__c == jobRec.get(0).SkillSet__c)
page = new PageReference('/apex/InterviewConfirmationPage');
if(page == null)
page = new PageReference('/apex/EditProfile');
return page.setRedirect(true);
}else{
ischeck = false;
userName = '';
password = '';
return null;
}
}
}.
Visual force pages
-----------------------
<apex:page controller="uloginController" showHeader="false" sidebar="false" standardStylesheets="true" action="{!autoRun}" >
<apex:form >
<apex:pageBlock title="Welcome to Edit Profile Form">
<apex:pageBlockSection >
<table>
<tr>
<td>
<apex:inputText required="true" id="Name" styleClass="form-control" value="{!ep.Name}"/>
</td>
</tr>
<tr>
<td>
<apex:inputText required="true" id="SkillSet" styleClass="form-control" value="{!ep.SkillSet__c}"/>
</td>
</tr>
<tr>
<td>
<apex:inputText required="true" id="JobRecruiterName" styleClass="form-control" value="{!ep.JobRecruiterName__c}"/>
</td>
</tr>
</table>
</apex:pageBlockSection>
<apex:commandButton value="save" action="{!save1}"/>
</apex:pageBlock>
</apex:form>
</apex:page>
One question, Is this a project you are working on? It seems you need a complete flow of user management for some portal. This forum might not be for that. Let me know if we can chat differently so that we can achieve you goal and I better help you properly.