8

We are having a force.com site and we are currently using a site.login method to authenticate the user. The Site.Login returns a page reference which tells us whether the login is successful or not. I am trying to override the default salesforce login failure message with our own and it does not work.

PageReference pf =  Site.login(viewstatecontroller.userID_str, 
                               viewstatecontroller.password_str,landingUrl);
If(pf == null)
    add custom apex message
else
    return pf;

Now if i do this, the login never works successfully and i am forced to do a return on the Site.Login. I tried to remove the default apex message and add our own and we don't have remove message on the ApexMessage. How can we put our own error message on the login failure on a force.com site? Does any body know how to do this? Thanks Buyan

5

I have faced the same problem. Not sure why it's not working. But I was able to overcome that by creating a pageMessage in VF page as follows:

<apex:pageMessage severity="error" summary="Login Failed.Check the userName or Password" rendered="{!isLoginFailed}"/>

<apex:commandbutton value="Login" action="{!login}"/>

In Controller:

public Boolean isLoginFailed {get; set;}
public String password { get; set; }
public String username { get; set; }

public PageReference login()
{
   PageReference ref=Site.login(username,password,'/apex/sample');
   if(ref==null)
   {
    isLoginFailed=true;
    return null;
   }
   return ref;      
}

Hopefully, this works for you.

If I use rerender attribute on commandbutton, this again does not work.

1

EDIT

I think I ran across a more definitive answer to your question this morning while reading the Force.com Sites Implementation Guide. Here's what I found:

Assigning Force.com Site Error Pages Available in: Developer, Enterprise, and Unlimited Editions User Permissions Needed To create and edit Force.com sites: “Customize Application” Force.com sites uses Visualforce pages for all site and error pages. Sample error pages use the SiteSamples static resource for their stylesheet and images. Warning: Don't rename or delete SiteSamples or you may get an error. To set the error pages for your site:

  1. From Setup, click Develop > Sites.
  2. Click the name of the site you want to modify.
  3. Click Page Assignment on the Error Pages related list.
  4. Using the lookup fields, assign a Visualforce page or static resource for each of the standard error conditions listed: • Authorization Required Page—The page users see when trying to access pages for which they do not have authorization. • Limit Exceeded Page—The page users see when your site has exceeded its bandwidth limits. • Maintenance Page—The page users see when your site is down for maintenance. • Service Not Available Page—The page users see when Salesforce servers are unavailable. This custom page is rendered from a static resource that you choose. The static resource is uploaded to the cache server when assigned as the Service Not Available page, and when updated after assignment. The custom page is shown for HTTP requests only; caching is not used for HTTPS. Not available for Developer Edition or sandbox organizations. If you haven't set a custom page for a site that uses a site prefix, the custom page for the root site is used when servers are unavailable. For example, if http://mycompany.force.com/sales doesn't have a custom page, but http://mycompany.force.com does, that custom page is used. Otherwise, the Maintenance page is shown by default. Note: The static resource: ◊ Must be a public .zip file 1 MB or smaller. ◊ Must contain a page named maintenance.html at the root level of the .zip file. Other resources in the .zip file, such as images or CSS files, can follow any directory structure. ◊ Must contain only files that have file extensions. • Page Not Found Page—The page users see when trying to access a page that cannot be found. You can use the action attribute on an component to redirect the Page Not Found error page. Using this kind of redirect on any other error pages will redirect users to the Maintenance page. • Generic Error Page—The page users see when encountering generic exceptions. 12 Assigning Force.com Site Error Pages Note: When using static resources in a custom error page—such as a large image file or a large CSS file contained in a static resource .zip file—each individual resource must be no larger than 50KB. Otherwise, a 404 not found error is returned for that resource.
  5. Click Save.
  6. On the Site Details page, click Preview to view the associated page as it would appear in a browser. Tip: Add the component right before the closing tag in your custom Visualforce error pages to view detailed site error messages in administrator preview mode.

END EDIT

Bunyan, I have two references that may be of some use. I don't think the first will directly apply to sites, but it may be worth trying to see if the same strategy will work for you.

Replacing Salesforce Online Help Organizations that have renamed standard tabs, objects, fields, and other related user interface labels can also replace the Salesforce online help with another URL. Users can view this URL whenever they click on any context-sensitive help link on an end-user page or within Personal Setup. After you replace the help, the Help & Training link at the very top of every page and all Administration Setup pages will continue to display Salesforce online help. 1. Click Your Name > Setup > Customize > Tab Names and Labels > Help Settings. 2. Enter the complete URL for your help file that you would like to replace the Salesforce online help. 3. Click Save. Notes about Replacing Online Help • When you replace the Salesforce online help with your own help file, the Help & Training link still displays Salesforce online help but the Help for this Page links on all pages other than within Administration Setup are no longer context-sensitive. That is, your help file will open at the same place regardless of which page the user is viewing when they click the link. • You can make your help context-sensitive by taking advantage of the context-specific parameters that are passed with each help link. For example, the help link from the Opportunities tab home page is constructed as follows (without any linebreaks): http://your_help_file.com?loc=help&body=%2Fhelp%2Fdoc%2Fen%2Fhelp2.jsp &target=opp_overview.htm&section=Opportunities The values of the target and section parameters are unique for every page within the application. You can parse these parameters to display context-sensitive help content for your users. • If your online help file is compatible with the Web browser on your users' mobile devices, you can contact salesforce.com to enable a custom URL for the online help in Salesforce Mobile. If you enable a mobile help URL, the Help link in the mobile application launches the custom help URL instead of the Salesforce Mobile online help. Don't deploy customized mobile help without testing it thoroughly on all the device models carried by your users. Even if all of your users have the same type of mobile device, the experience can vary widely depending on which operating system version is installed on the device.

The second, comes from the Sites Help section and is related to the Site Map. From the Site Overview Tab, I'd strongly suspect you'll be able to locate the page you're looking for. Unfortunately, I can't verify this at the moment. I'm about to start a new site for a client, but don't have access to their org today. Here's a copy/paste from the relevant help section.

About the Site Map and Page Hierarchy Available for purchase in: Enterprise and Unlimited Editions Available (with limitations) in: Developer Edition The Site Pages view on the Overview tab contains the pages and site map links of your website. The Site Map folder reflects the hierarchy or tree structure of your site by housing site pages and links that are included in the site map. When you create new pages or site map links, they're automatically added to this folder. The Landing Pages folder houses standalone pages that are excluded from the site map, making it ideal for temporary pages, such as promotional or competition pages. Tip: If you can’t see the Site Map folder in the Site Pages view on the Overview tab, click enter image description here.

enter image description here

When adding a navigation menu to your site, it's important to organize the hierarchy of your site pages and links accurately, because this structure is used to generate the menu. Pages and site map links are displayed in navigation menus in the order you arrange them. In this representation of the site hierarchy, you can more clearly see the tree structure. 1. The Site Map folder, which contains four site pages. 2. A top-level page in the site hierarchy. 3314 Creating Websites About the Site Map and Page Hierarchy 3. A top-level, parent page with two child pages. A child page is a page at a lower level in the site hierarchy than its parent page. 4. Two child pages. 5. The Landing Pages folder, which contains a temporary page that's not part of the site map or navigation menu. Tip: If a page has child pages, the icon appears beside it indicating that you can expand the branch. By default, when you create a menu, it’s generated from the pages and site map links in the Site Map folder in the Site Pages view. However, you can also create a menu that’s generated from the pages in the Landing Pages folder or from the child or sibling pages of a site page. You can hide a page in menus, breadcrumbs, and the site map by selecting the Hide Page checkbox found on the Properties pane for each page. This setting also prevents website visitors from accessing the page’s direct URL. By default, all pages are visible.

As much as anything, I'd be looking for any options in Site Configuration if you're unable to do it with a JavaScript redirect. From what the Help File shows, there's a limited number of event actions that are directly supported by Sites.

1
  • @bunyan kumar Please see the additional info I ran across this morning & the edited answer to your question above.
    – crmprogdev
    Jun 1 '13 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.