Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Editing Account for Existing User: Dialog2 template

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Editing Account for Existing User: Dialog2 template

    .
    Hi,
    I'm trying to modify at the same time a user's Personal data and Security data, using a Dialog2 component. The video showing how to proceed is D_SF_3. The video uses a Dialog2 template by the name of SecurityFramework-EditAccountForExistingUser.

    I built the Dialog using the template, re-created the RegisteredUsers table together with its fields as one of my tables and have put the Dialog to test. It works as described in the video. The Dialog has two sections, one for Personal data and another for Security data. On initialize, both sections are automatically filled in with the user whose id=1 (that value is hardcoded, see just below), ready for editing.

    The problem is: the user value is hardcoded. You'll find this code in Events --> Server-SIDE --> onDialogInitialize:

    '---------- Simulate a user value passed to the dialog for user with a primary key of 1
    dim id as c = "1"




    For the Dialog to be of any use, it should be able to edit any user, not just one particular hardcoded user. To that effect, I added a dropdown box to the Dialog, plus a button. The dropdown box retrieves the list of users from the RegisteredUsers table and the button, when clicked, uses the Populate Controls in a Dialog Component with Data from Tables Action Javascript. Now, when I select a user from the dropdown and click the button, the fields in the Personal data section are filled in but the fields in the Security data are left blank.

    In the template's OnDialogInitialize event, the sequence of actions is:

    a) Receive the user value (in our case, either hardcoded or passed from the dropdown), which is the primary key field id
    b) Retrieve the user's Personal data corresponding to that id from our RegisteredUsers table. Also, capture this data into a dot variable by the name of _data
    c) Retrieve the user's Security data. Which user? The one whose User Name matches the dot variable's _data.USERNAME value.

    Since the data in the Personal section are captured in a dot variable and then used in the execution of the next action (irrespective of whether the user value is hardcoded or comes from the dropdown) it should work in both cases. But it only works when the user value is hardcoded.

    I'd be grateful for any solution, suggestion or tip.

    Regards,
    Felix
    .

    #2
    Re: Editing Account for Existing User: Dialog2 template

    Hey Felix,

    I've had a look at this and found a solution... that should work... but doesn't. I haven't seen anything explained that won't let me do what I want... so here it is...

    The dialog, when first displayed, get's initialized with user 1. Let's say we're happy with that... not really, but let's continue.

    We have a dropdown that displays a UserName from the RegisteredUsers table, but, that holds the primary key value. Excellent... now we have the key into the table in the dropdown.

    My theory was to run an Ajax Callback off the onChange event of the dropdown. It is virtually a copy of the code in the Server-side OnDialogInitialize event... except for one change

    Code:
    dim id as c  = e.dataSubmitted.ddGetUserInfo
    We assign "id" the value of the dropdown, which in my case is named ddGetUserInfo. Yay... except it looks like ExecuteServerSideAction is not available in the Ajax Callback. This is the error message I'm getting. Any thoughts?
    Attached Files
    Last edited by Davidk; 04-20-2012, 08:44 PM.

    Comment


      #3
      Re: Editing Account for Existing User: Dialog2 template

      Found the solution.

      Copy the code from the OnDialogInitialize event. EDIT: And put this copy into your Ajax Callback function.

      Put your cursor on the ExecuteServerSideAction and the click on Action Scripting and then choose Convert to Xbasic.

      For the Security stuff you don't need to do any more. But for the User Information you'll need to add the one line of code...

      Code:
      getRegUsersInfo = e.javascript
      My Xbasic function is named getRegUsersInfo and we'll just assign the output of the converted Xbasic code to the function so that it will get executed. This goes at the end of the converted code for the User info stuff.

      It works. yay.
      Last edited by Davidk; 04-23-2012, 08:40 AM.

      Comment


        #4
        Editing Account for Existing User: Dialog2 template

        .
        David,
        I've taken a look at your solution and it's great that you made it work. I'll try to recreate it in my system. On Monday. Thank you for your time.


        Have a nice weekend,
        Felix
        .

        Comment


          #5
          Editing Account for Existing User: Dialog2 template

          .
          Hi David,
          I have not been able to replicate your solution. I forgot to mention that my Alpha Five and Javascript skills are just little better than beginner-level. I still am only able to retrieve the Personal data, but not the Security data.

          As you know, I replicated the video (including creating a registeredusers.dbf table) and then added a couple of controls to the Dialog, as you can see in the attached image below:



          (NOTE: In the image above, the Security data was retrieved because I left the dim id as c = "1" code in the OnDialogInitialize event, as you can see in the last image.)

          The dropdown's field name is id and gets its list of users from the registeredusers.dbf table. The Retrieve button executes an Action JavaScript called Populate Controls in a Dialog Component with data from Tables which I have filled in as shown below:



          In the OnDialogInitialize event I've deleted most of the comments and the code now looks like this:



          Now comes the tricky part. Which Action Script(s) should I modify?

          (A) Populate Controls in a Dialog Component with data from Tables
          (B) ExecuteServerSideAction("Populate Dialog from Tables::LoadUser")
          (C) ExecuteServerSideAction("Load Web Security Values::LoadSecurity")


          My understanding is that I should modify (B) by using the Convert to XBasic and then adding the code in bold letters at the end of the newly converted code:
          ... ... ...
          dim e.javascript as c = default ""
          e.javascript = e.javascript + crlf()+\
          jsPopulateControls + crlf()+\
          jsErrorMessage + crlf()+\
          jsDebuggingMessages

          getRegUsersInfo = e.javascript


          Is that right? Plus:
          Do I have to add getRegUsersInfo somewhere else?



          Thank you for your help,
          Felix
          .

          Comment


            #6
            Re: Editing Account for Existing User: Dialog2 template

            Hey Felix,

            You don't need to change anything in the OnDialogInitialize event... everything there is ok...as long as you're happy with getting that one record. If you don't want to show that record when the dialog is opened, then comment out the dim Id and Execute... statements. Then the dialog will open with nothing loaded.

            What you need to do is create a function in the XBasic functions section. I called mine "getRegUsersInfo". The easiest way to do this is to get to the user name dropdown you created and, in the onSelect event, use Action Scripting to add an Ajax Callback. A dialog will open and you fill in the name of your Ajax Callback - which is just an Xbasic function - give it the name of getRegUsersInfo - or whatever you like - but that's what I named mine. Then, in this dialog there are two links - one to show you the function - Alpha creates it for you - and then you can copy it. The other link is to open the Xbasic function section - and now you can paste in your copied function.

            Once the code is pasted in, then save it and close it. Now go to your OnDialogInitialize event and copy the code from there. Close it and, in the left side pane you'll see XBasic functions, open that and you'll see your Ajax Callback code. Paste in the code from the OnDialogInitialize event and go through the process of converting it to Xbasic code. Then... you're right, add getRegUsersInfo (or whatever you called your function) = e.javascript.

            Don't forget to modify that dim Id statement... dim id as c = e.dataSubmitted.ddGetUserInfo where ddGetUserInfo is the name of your dropdownbox (or whatever you called it).

            getRegUsersInfo is an Xbasic function that will be called when you make a selection from the dropdown - because we created that Ajax Callback off the onSelect event of the dropdown.

            id will be assigned the value of the dropdown - but you must create your dropdown to show the name of the person, but store the id of the table. This is one of the options for the dropdown.

            Once getRegUsersInfo is called the Xbasic converted code will run and will get the security info and user info.

            I'm pretty sure I've covered it, but that's from memory - not at my main system this morning. If you're still not sure or it still isn't working, I'll post a video a bit later.

            This would be a little bit easier if the "Execute..." statements worked in the Xbasic functions. Then again, we wouldn't have a solution if that excellent option to Convert wasn't there.
            Last edited by Davidk; 04-23-2012, 09:02 AM.

            Comment


              #7
              Re: Editing Account for Existing User: Dialog2 template

              .
              Hi David,
              I've tried (really hard) to do what your message says, but I must be skipping something or doing something wrong. Maybe if you could send me a zip, I could study it.

              Thanks again,
              Felix
              .

              Comment


                #8
                Re: Editing Account for Existing User: Dialog2 template

                Of course... good idea. The attached is the dialog, exported to a zip file. This one is using the dropdownbox OnChange event... I think I had it on the OnSelect event and changed it... can't remember why.
                Attached Files

                Comment


                  #9
                  Re: Editing Account for Existing User: Dialog2 template

                  .
                  David,
                  Got it running. My mistake was having the dropdown's event to OnSelect instead of OnChange. With OnSelect it does not work, at least for me. Now I'll have to study why it works!

                  Thanks a lot,
                  Felix
                  .

                  Comment


                    #10
                    Re: Editing Account for Existing User: Dialog2 template

                    Sorry Felix... that was me. This morning I was working from memory and had originally tried OnSelect. I wrote earlier about OnChange, but didn't remember that part. Yeah... I remember OnSelect didn't work for me either... sorry about that. Very glad you got it working.

                    In looking at the code... absolutely no idea... it's really good code and it works beautifully.

                    Comment


                      #11
                      Re: Editing Account for Existing User: Dialog2 template

                      Hi All
                      I am having difficulty with the data binding explained in the video D_SF_3. Looking at the template one can see that it is based on a SQL table. The video also does not explain the part where one has to add the table(s). The current security frame that I am using is based on DBF. Am I missing something here. Any pointers on this would be greatly appreciated.
                      Many Thanks

                      Peter G

                      Comment


                        #12
                        Re: Editing Account for Existing User: Dialog2 template

                        Maybe this will help. http://msgboard.alphasoftware.com/al...d-Data-Binding

                        Essentially, you need to create your own users information table.

                        Comment


                          #13
                          Re: Editing Account for Existing User: Dialog2 template

                          Hi David
                          I do have a users information table but on on MySQL. My app makes use of the DBF security framework and a users information table on MySQL to filter data based on user login. Is it possible to use both DBF and SQL tables on the same dialog?.

                          Peter G

                          Comment


                            #14
                            Re: Editing Account for Existing User: Dialog2 template

                            Peter,

                            You are "essentially" dealing with two tables, the security framework and your user info, but Alpha is looking after the security part with functions. Ceeate your MySQL Users Info table first and, once it's created, then go through the dialog videos, you'll see that data binding only occurs with your MySQL table. I thought I could "create" the user info table through data binding, but that's not possible because the table creation process thinks the security fields will be part of the table... and they're not. The security framework IS dbf - but again, you don't need to worry about it... Alpha takes care of getting and adding info through functions.

                            Comment


                              #15
                              Editing Account for Existing User: Dialog2 template

                              .
                              Hi Peter,
                              You can analyze David's zipped code that you'll find in this same thread, about three messages up. Alternatively, my suggestion is that you re-create the video and then apply it to your case. This means:

                              - Create a RegisteredUsers table. I did it in dbf format, not SQL: userid (make it character, not numeric), firstname, lastname, phone, username

                              - Create a Dialog2 using a template: SecurityFramework-EditAccountForExistingUser

                              - Add a dropdown box as the dialog's first control. Call it "id". Place it on top of the Personal Data frame, it looks nicer, and give it a Field Properties --> Height of (say) 10

                              - In the id control --> DropDownBox Properties --> Choices, select the Dynamic radio button. Table name: RegisteredUsers.dbf, Display value: Firstname + " " +Lastname, Stored value: Userid. This will make the dropdown look nicer.

                              - Still in the id control --> Javascript --> onChange, select the Action Javascript button and click the green Add New Action icon. In the right hand column, choose Ajax Callback. In the next dialog, select as Callback type: InternalXBasicFunction and as Function name: loadUserFromRegisteredUsersTable (or whatever you'd like to call it). Then, near the dialog's footer you'll see a blue link: Create function prototype. Click and choose the Without comments radio button, copy the code (which is very little) to the Clipboard and exit. Click now on the other blue link: Open Xbasic Function Declarations and paste the code. Exit.

                              - Go to the Data Binding section, and in Specify Tables delete the pre-set SQL RegisteredUser table and add your dbf RegisteredUser table. In Bind Dialog Controls to Table Fields, it should look like:


                              - Go to Events --> Server side --> onDialogInitialize. "Clean" the code till it looks like this:

                              - The hard part. The next step is to convert the two ExecuteServerSideAction(xxx) actions into XBasic. Once converted, you'll have to add this line between the first and the second converted actions: loadUserFromRegisteredUsersTable = e.javascript. How to do it? Click somewhere on the gray text ("Populate Dialog from Tables::LoadUser") so as to place there the cursor, then click the Action Scripting genie button and choose Convert to XBasic.
                              * Do this with the first server side action, the one that recovers the user's personal data from your RegisteredUser table, then at the end of the converted code add this line: loadUserFromRegisteredUsersTable = e.javascript
                              * Then convert the second server side action, the one that recovers the user's security data


                              - Now comes the cut-and-paste part. Still in onDialogInitialize you have to "Cut" the converted actions (plus the line that you added) and "Paste" it in Code --> XBasic functions which you'll find in the left pane. Once you do that, your onDialogInitialize should look like this:


                              - Open now Code --> XBasic functions which you'll find in the left pane. You'll see your loadUserFromRegisteredUsersTable function. You have to paste the code between the two lines of green text, where there's a blue comment line that reads something like 'loadUserFromRegisteredUsersTable = "javascript commands to be executed in the Browser." (you can delete the blue comments).

                              - Still in Code -->XBasic functions, you have to add this line right below the header: dim id as c = e.dataSubmitted.id





                              I think that's it. Hope it works ...



                              Regards,
                              Felix
                              .

                              Comment

                              Working...
                              X