You need to sign in to do that
Don't have an account?
Login page is blank while click the login button.
Hi All,
I am getting page is blank, while click the login button.I didn't get any error before saving the code. While loging the page, it will be blank page
VF CODE :
<apex:page controller="Sample" sidebar="false" >
<apex:form >
<apex:pageBlock >
<br>UserName <apex:inputText label="center" value="{!userName}"/></br>
<br>Password <apex:inputsecret value="{!password}"/></br>
<br>
<apex:commandButton value="Login" action="{!loginPage}" reRender="Error"/></br>
<br><br>
<apex:outputLink value="https://c.ap2.visual.force.com/apex/RegistrationPage">Create New Account</apex:outputLink>
</br></br>
<apex:pageMessages id="Error"></apex:pageMessages>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller :
public class Sample {
public String userName{get;set;}
public String password{get;set;}
public List<Registration__c> returns {get;set;}
public Sample(){
returns = new List<Registration__c>();
}
public PageReference loginPage(){
returns = [select ID, Name, User_Name__c, Password__c from Registration__c Where User_Name__c=:userName and Password__c=:password];
if(!returns.isEmpty()) {
Pagereference pr = new PageReference('/'+returns[0].id);
pr.setReDirect(false);
return pr;
}
else {
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Invalid UserName or Password'));
return null;
}
//Pagereference pr = new PageReference('/'+returns[0].Id);
//pr.setRedirect(true);
//return pr;
return null;
}
}
Plead Identify the error, what is missing here.
Thanks in advance
Thulasi
I am getting page is blank, while click the login button.I didn't get any error before saving the code. While loging the page, it will be blank page
VF CODE :
<apex:page controller="Sample" sidebar="false" >
<apex:form >
<apex:pageBlock >
<br>UserName <apex:inputText label="center" value="{!userName}"/></br>
<br>Password <apex:inputsecret value="{!password}"/></br>
<br>
<apex:commandButton value="Login" action="{!loginPage}" reRender="Error"/></br>
<br><br>
<apex:outputLink value="https://c.ap2.visual.force.com/apex/RegistrationPage">Create New Account</apex:outputLink>
</br></br>
<apex:pageMessages id="Error"></apex:pageMessages>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller :
public class Sample {
public String userName{get;set;}
public String password{get;set;}
public List<Registration__c> returns {get;set;}
public Sample(){
returns = new List<Registration__c>();
}
public PageReference loginPage(){
returns = [select ID, Name, User_Name__c, Password__c from Registration__c Where User_Name__c=:userName and Password__c=:password];
if(!returns.isEmpty()) {
Pagereference pr = new PageReference('/'+returns[0].id);
pr.setReDirect(false);
return pr;
}
else {
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Invalid UserName or Password'));
return null;
}
//Pagereference pr = new PageReference('/'+returns[0].Id);
//pr.setRedirect(true);
//return pr;
return null;
}
}
Plead Identify the error, what is missing here.
Thanks in advance
Thulasi
In the controller method "login Page",
if(!returns.isEmpty()) {
Pagereference pr = new PageReference('/'+returns[0].id);
pr.setReDirect(false);
return pr;
}
you need to set " pr.setReDirect" as "true" rather then false. So your method would look like this:
if(!returns.isEmpty()) {
Pagereference pr = new PageReference('/'+returns[0].id);
pr.setReDirect(true);
return pr;
}
I think this would resolve your error.
Thanks
Nitin
Thanks for ur reply, First i tried with "true" value, aftere i changed it as false. But, the same error.