Alpha Video Training
Results 1 to 10 of 10

Thread: Custom Control in Login component

  1. #1
    Member
    Real Name
    Sparticuz
    Join Date
    Jun 2009
    Location
    Clearwater, FL
    Posts
    512

    Default Custom Control in Login component

    Is there any way to put in a custom control in a Login component? I would like the user to select what 'Region' they will be working in during their session. I know I can accomplish this by using a dialog that sets it as a session variable as the login redirect page, but I would like to see if I can get it all in the login.

    ---------------------
    Username input
    Password input
    Region dropdown
    Login button
    --------------------

  2. #2
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,842

    Default Re: Custom Control in Login component

    Yes you can do this. I only tried this now, so perhaps this can be counted as a new discovery.

    Go to the login component and click Layout > Freeform. Click Revert to Default so it paints your default layout. Then insert something like this wherever you want your dropdown to appear:

    <SELECT NAME="region">
    <OPTION VALUE="">Choose a Region...
    <OPTION VALUE="region1">Region 1
    <OPTION VALUE="region2">Region 2
    <OPTION VALUE="region3">Region 3
    </SELECT>

    Save.


    Then on the A5W page that contains your login component, put this code anywhere on the page:

    <%a5

    dim session.region as c
    if eval_valid("submitbutton")
    session.region=region
    end if

    ?"my region :" + session.region
    %>

    The last line is just for testing, remove after tested. When you click submit, the selected region will be stored in session.region.

    My freeform code looks like this:

    HTML Code:
    <table border="0" cellpadding="2" cellspacing="0" class="wtdefaultFormTABLE">
        <tr>
          <td class="wtdefaultColumnTD">User ID</td>
          <td class="wtdefaultDataTD">{Userid}</td>
        </tr>
        <tr>
          <td class="wtdefaultColumnTD">Password</td>
          <td class="wtdefaultDataTD">{Password}</td>
    	</tr>
          <td class="wtdefaultColumnTD">Region</td>
          <td class="wtdefaultDataTD">
    <SELECT NAME="region">
    <OPTION VALUE="">Choose a Region...
    <OPTION VALUE="region1">Region 1
    <OPTION VALUE="region2">Region 2
    <OPTION VALUE="region3">Region 3
    </SELECT>
    </td>
        </tr>
        <tr>
          <td align="center" colspan="2" class="wtdefaultFieldCaptionTD">{SubmitButton}&nbsp;{ResetButton}</td>
        </tr>
        <tr>
          <td colspan="2" class="wtdefaultFieldCaptionTD" >{RememberMe}</td>
        </tr>
        <tr>
          <td colspan="2" class="wtdefaultFieldCaptionTD" >{LostPasswordLink}</td>
        </tr>
      </table>
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  3. #3
    Member
    Real Name
    Sparticuz
    Join Date
    Jun 2009
    Location
    Clearwater, FL
    Posts
    512

    Default Re: Custom Control in Login component

    Sweet, that looks like it will work. How would I pull in the regions from sql? I'm assuming I'd have this code run in the a5w page before the table render takes place.
    Code:
    dim cn as sql::connection
    flag = cn.Open("::Name::jkapp")
    dim sqlCommand as c 
    sqlCommand = "Select CompanyName,CompanyID from gen_regions"
    flag = cn.Execute(sqlCommand)
    dim rs as sql::ResultSet = cn.ResultSet
    Then render out the html. How could I then insert that as my Select/Options?

  4. #4
    Member
    Real Name
    Pratheep Moorthy
    Join Date
    Feb 2011
    Posts
    40

    Default Re: Custom Control in Login component

    Hi Sparticuz,

    Did you ever figure out how to pull the region from SQL and then show it in drop down box on logon page? I need to do something similar and looks like you might have solved the problem before. Let me know if this can be done. Thanks!

  5. #5
    Member
    Real Name
    Sparticuz
    Join Date
    Jun 2009
    Location
    Clearwater, FL
    Posts
    512

    Default Re: Custom Control in Login component

    pvin2011, Nope, sorry, I never got it working with sql. That wasn't really a necessary function for it to have. It would just have been nice.


    Steve, For some reason I can't get it to work correctly. I've got that code on the index.a5w page but it's not setting the session variable. I can see in Firebug that the region IS being passed to index.a5w after I click Login, but it is inaccessible when my Security Framework forwards to login.a5w.

    Code:
    'on index.a5w (where the login component is)
    'Code for region to be set on login
    if eval_valid("submitbutton")
    	session.regionnum = region
    end if
    Code:
    'login.a5w
    if eval_valid("session.regionnum") then
    	select
    	    case session.regionnum == 1
    			session.__protected__jkapp = "{A5API=MySQL.....'}"
    			session.regionname = "Tampa"
    		case session.regionnum == 2
    			session.__protected__jkapp = "{A5API=MySQL....'}"
    			session.regionname = "Orlando"
    		case else
    			session.__protected__jkapp = "{A5API=MySQL....'}"
    			session.regionname = "Tampa"
    	end select
    else
    	'Session.Regionnum not set?
    	?"Error"
    	end
    end if
    I'm getting Error every single time

  6. #6
    Member
    Real Name
    Sparticuz
    Join Date
    Jun 2009
    Location
    Clearwater, FL
    Posts
    512

    Default Re: Custom Control in Login component

    I'm literally at a stand still due to this problem. I've tried putting the eval_valid("submitbutton") on both the login and the index page, nothing is working! Any help from anyone would be greatly appreciated!!!

  7. #7
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,842

    Default Re: Custom Control in Login component

    You have to debug. First find out if submittbutton ever evaluates to true. Somethign like this:

    if eval_valid("submitbutton")
    session.regionnum = region
    save_to_file("submitbutton is true" + "|" + region,"c:\test.txt")
    end if

    If it creates a file named test.txt, you know it was true. If it includes the region, you know that has a value.

    If the region is a numeric value, it would be str(region) in the save_to_file() code.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  8. #8
    Member
    Real Name
    Sparticuz
    Join Date
    Jun 2009
    Location
    Clearwater, FL
    Posts
    512

    Default Re: Custom Control in Login component

    test.txt doesn't get created.

    It looks like submitbutton actually evaluates to 'Login'

    This is what firebug shows when I click login:
    POST index.a5w
    COMPONENT_LOGIN_forminfo=aG56XvNpsXHZCzflza4J%252bjQYIH4QyCaPMaBK8s0x2%252b6P00JXq3FD0Mf3%252bHL7AlnJ&Userid=kmcnally&Password=****&region=1&submitbutton=Login

    GET login.a5w

  9. #9
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,842

    Default Re: Custom Control in Login component

    You are not looking for the value of submitbutton, just that it exists. It exists when it is clicked. So eval_valid("submitbutton") is true just when the button is clicked.

    I know exactly what the problem is. You need to move your code. Put it at the very top, above the <DOC TYPE..> or any other HTML, right at the top.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  10. #10
    Member
    Real Name
    Sparticuz
    Join Date
    Jun 2009
    Location
    Clearwater, FL
    Posts
    512

    Default Re: Custom Control in Login component

    Yep, that was it! I did some more testing and it looks like the code just needs to be above the xbasic initialization of the component. THANKS!!!!! for all the help :)

Similar Threads

  1. Custom control on dialog component for file upload not working
    By Jay Talbott in forum Application Server Version 10 - Web/Browser Applications
    Replies: 1
    Last Post: 06-30-2010, 01:53 AM
  2. login component
    By crimmelcp in forum Application Server Version 9 - Web/Browser Applications
    Replies: 1
    Last Post: 11-16-2008, 06:09 PM
  3. Login In Component
    By jacklcs22 in forum Application Server Version 8
    Replies: 4
    Last Post: 11-05-2007, 07:06 PM
  4. Login Component
    By Louis Nickerson in forum Application Server Version 8
    Replies: 25
    Last Post: 11-01-2007, 08:29 PM
  5. Login component problem?
    By Pat Bremkamp in forum Application Server Version 8
    Replies: 1
    Last Post: 03-21-2007, 11:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •